const require_chunk = require('./chunk-DWy1uDak.cjs');
const require_errors = require('./errors-BtJEw2Z-.cjs');
const require_define = require('./define-BfP4rFlE.cjs');
const require_errors$1 = require('./errors-Bmqdg5Q6.cjs');
const require_fetch_utils = require('./fetch-utils-Cp3P-Ai3.cjs');
const __sentry_core = require_chunk.__toESM(require("@sentry/core"));
const zod = require_chunk.__toESM(require("zod"));

//#region src/tools/get-doc.ts
var get_doc_default = require_define.defineTool({
	name: "get_doc",
	requiredScopes: [],
	description: [
		"Fetch the full markdown content of a Sentry documentation page.",
		"",
		"Use this tool when you need to:",
		"- Read the complete documentation for a specific topic",
		"- Get detailed implementation examples or code snippets",
		"- Access the full context of a documentation page",
		"- Extract specific sections from documentation",
		"",
		"<examples>",
		"### Get the Next.js integration guide",
		"",
		"```",
		"get_doc(path='/platforms/javascript/guides/nextjs.md')",
		"```",
		"</examples>",
		"",
		"<hints>",
		"- Use the path from search_docs results for accurate fetching",
		"- Paths should end with .md extension",
		"</hints>"
	].join("\n"),
	inputSchema: { path: zod.z.string().trim().describe("The documentation path (e.g., '/platforms/javascript/guides/nextjs.md'). Get this from search_docs results.") },
	annotations: {
		readOnlyHint: true,
		openWorldHint: true
	},
	async handler(params, context) {
		(0, __sentry_core.setTag)("doc.path", params.path);
		let output = `# Documentation Content\n\n`;
		output += `**Path**: ${params.path}\n\n`;
		if (!params.path.endsWith(".md")) throw new require_errors.UserInputError("Invalid documentation path. Path must end with .md extension.");
		const baseUrl = "https://docs.sentry.io";
		const docUrl = new URL(params.path, baseUrl);
		const allowedDomains = ["docs.sentry.io", "develop.sentry.io"];
		if (!allowedDomains.includes(docUrl.hostname)) throw new require_errors.UserInputError(`Invalid domain. Documentation can only be fetched from allowed domains: ${allowedDomains.join(", ")}`);
		const response = await require_fetch_utils.fetchWithTimeout(docUrl.toString(), { headers: {
			Accept: "text/plain, text/markdown",
			"User-Agent": "Sentry-MCP/1.0"
		} }, 15e3);
		if (!response.ok) {
			if (response.status === 404) {
				output += `**Error**: Documentation not found at this path.\n\n`;
				output += `Please verify the path is correct. Common issues:\n`;
				output += `- Path should start with / (e.g., /platforms/javascript/guides/nextjs.md)\n`;
				output += `- Path should match exactly what's shown in search_docs results\n`;
				output += `- Some pages may have been moved or renamed\n\n`;
				output += `Try searching again with \`search_docs()\` to find the correct path.\n`;
				return output;
			}
			throw new require_errors$1.ApiError(`Failed to fetch documentation: ${response.statusText}`, response.status);
		}
		const content = await response.text();
		if (content.trim().startsWith("<!DOCTYPE") || content.trim().startsWith("<html")) {
			output += `> **Error**: Received HTML instead of markdown. The path may be incorrect.\n\n`;
			output += `Make sure to use the .md extension in the path.\n`;
			output += `Example: /platforms/javascript/guides/nextjs.md\n`;
			return output;
		}
		output += "---\n\n";
		output += content;
		output += "\n\n---\n\n";
		output += "## Using this documentation\n\n";
		output += "- This is the raw markdown content from Sentry's documentation\n";
		output += "- Code examples and configuration snippets can be copied directly\n";
		output += "- Links in the documentation are relative to https://docs.sentry.io\n";
		output += "- For more related topics, use `search_docs()` to find additional pages\n";
		return output;
	}
});

//#endregion
Object.defineProperty(exports, 'get_doc_default', {
  enumerable: true,
  get: function () {
    return get_doc_default;
  }
});
//# sourceMappingURL=get-doc-MxWNTA8R.cjs.map