#!/usr/bin/env node
const require_chunk = require('./chunk-DWy1uDak.cjs');
const require_constants = require('./constants-DJrjLmh5.cjs');
require('./errors-BtJEw2Z-.cjs');
require('./define-BfP4rFlE.cjs');
require('./url-utils-Bn5EoScr.cjs');
require('./logging-CkAJKyq2.cjs');
require('./schema-DoWJbcHt.cjs');
require('./errors-Bmqdg5Q6.cjs');
require('./client-C2TwbSm-.cjs');
require('./types-D10T4PdD.cjs');
require('./api-client-BsHWi0-I.cjs');
require('./validate-region-url-dzz6t54w.cjs');
require('./api-CZD9zwQ-.cjs');
require('./whoami-DBlwuDZf.cjs');
require('./slug-validation-DMk8Dyuh.cjs');
require('./schema-Cv_VNAHz.cjs');
require('./find-organizations-BGI_WW2q.cjs');
require('./find-teams-BuH2ddaL.cjs');
require('./find-projects-B80qSPpP.cjs');
require('./find-releases-Cy-Q-Qje.cjs');
require('./issue-helpers-DbPTv_qC.cjs');
require('./seer-B63P5CPi.cjs');
require('./formatting-Cu1Skk_Y.cjs');
require('./issue-B7cgiWKp.cjs');
require('./enhance-error-DzXrKg85.cjs');
require('./get-issue-details-lQmdKAfJ.cjs');
require('./get-trace-details-iDp34mms.cjs');
require('./get-event-attachment-CrtS0QRV.cjs');
require('./formatting-EM76FrY3.cjs');
require('./update-issue-eELBq_Uy.cjs');
const require_openai_provider = require('./openai-provider-DhSY7kTj.cjs');
require('./callEmbeddedAgent-KKTSTD7W.cjs');
require('./utils-DUJcA3eH.cjs');
require('./otel-semantics-onvZv7i9.cjs');
require('./whoami-DBSqcCGl.cjs');
require('./utils-C5DuiZoe.cjs');
require('./config-CllFlx5w.cjs');
require('./agent-DzfX6_dM.cjs');
require('./formatters-DMlTJcHW.cjs');
require('./handler-TWOoomKr.cjs');
require('./search-events-Bc2a_R3A.cjs');
require('./create-team-DmqKw2c1.cjs');
require('./create-project-CZBklXm8.cjs');
require('./update-project-DMRBdOZ5.cjs');
require('./create-dsn-ggGt0lZf.cjs');
require('./find-dsns-Ct6uFZMB.cjs');
require('./fetch-utils-Cp3P-Ai3.cjs');
require('./analyze-issue-with-seer-CI8pvCnf.cjs');
require('./search-docs-CTT1Bt1U.cjs');
require('./get-doc-MxWNTA8R.cjs');
require('./dataset-fields-C0m-vwNH.cjs');
require('./config-DbQP60oo.cjs');
require('./agent-BMCJjVaJ.cjs');
require('./formatters-CkbVfXEE.cjs');
require('./handler-Fsqncg_W.cjs');
require('./search-issues-AaiYCZ6J.cjs');
require('./config-ClFI6orZ.cjs');
require('./agent-DT4ic52w.cjs');
const require_server = require('./server-J1RALwYS.cjs');
require('./error-handling-ZVmZRXZb.cjs');
const require_version = require('./version-CdN5Kpjv.cjs');
const require_permissions = require('./permissions-CpuEzSxz.cjs');
require('./constraint-helpers-BJPdGLZ3.cjs');
const require_stdio = require('./stdio-CV8Yynj8.cjs');
const require_usage = require('./usage-BV4cegeX.cjs');
const require_parse = require('./parse-BOPxttSm.cjs');
const require_resolve = require('./resolve-D6Cfnjdj.cjs');
const require_sentry = require('./sentry-Da9wc8eP.cjs');
const require_agent_tools = require('./agent-tools-1J_Oub8P.cjs');
const __sentry_node = require_chunk.__toESM(require("@sentry/node"));

//#region src/index.ts
const packageName = "@sentry/mcp-server";
const usageText = require_usage.buildUsage(packageName, require_constants.DEFAULT_SCOPES, require_permissions.ALL_SCOPES);
function die(message) {
	console.error(message);
	console.error(usageText);
	process.exit(1);
}
const cli = require_parse.parseArgv(process.argv.slice(2));
if (cli.help) {
	console.log(usageText);
	process.exit(0);
}
if (cli.version) {
	console.log(`${packageName} ${require_version.LIB_VERSION}`);
	process.exit(0);
}
if (cli.unknownArgs.length > 0) {
	console.error("Error: Invalid argument(s):", cli.unknownArgs.join(", "));
	console.error(usageText);
	process.exit(1);
}
const env = require_parse.parseEnv(process.env);
const cfg = (() => {
	try {
		return require_resolve.finalize(require_parse.merge(cli, env));
	} catch (err) {
		die(err instanceof Error ? err.message : String(err));
	}
})();
if (!process.env.OPENAI_API_KEY) {
	console.warn("Warning: OPENAI_API_KEY environment variable is not set.");
	console.warn("The following AI-powered search tools will be unavailable:");
	console.warn("  - search_events (natural language event search)");
	console.warn("  - search_issues (natural language issue search)");
	console.warn("All other tools will function normally. To enable AI-powered search, set OPENAI_API_KEY.");
	console.warn("");
}
require_openai_provider.configureOpenAIProvider({ baseUrl: cfg.openaiBaseUrl });
__sentry_node.init({
	dsn: cfg.sentryDsn,
	sendDefaultPii: true,
	tracesSampleRate: 1,
	beforeSend: require_sentry.sentryBeforeSend,
	initialScope: { tags: {
		"mcp.server_version": require_version.LIB_VERSION,
		"mcp.transport": "stdio",
		"mcp.agent_mode": cli.agent ? "true" : "false",
		"sentry.host": cfg.sentryHost,
		"mcp.mcp-url": cfg.mcpUrl
	} },
	release: "0.20.0",
	integrations: [
		__sentry_node.consoleLoggingIntegration(),
		__sentry_node.zodErrorsIntegration(),
		__sentry_node.vercelAIIntegration({
			recordInputs: true,
			recordOutputs: true
		})
	],
	environment: "stdio"
});
if (cli.agent) {
	console.warn("Agent mode enabled: Only use_sentry tool is available.");
	console.warn("The use_sentry tool provides access to all Sentry operations through natural language.");
	console.warn("");
}
const SENTRY_TIMEOUT = 5e3;
const context = {
	accessToken: cfg.accessToken,
	grantedScopes: cfg.finalScopes,
	constraints: {
		organizationSlug: cfg.organizationSlug ?? null,
		projectSlug: cfg.projectSlug ?? null
	},
	sentryHost: cfg.sentryHost,
	mcpUrl: cfg.mcpUrl,
	openaiBaseUrl: cfg.openaiBaseUrl
};
const server = require_server.buildServer({
	context,
	tools: cli.agent ? require_agent_tools.agent_tools_default : void 0
});
require_stdio.startStdio(server, context).catch((err) => {
	console.error("Server error:", err);
	__sentry_node.flush(SENTRY_TIMEOUT);
	process.exit(1);
});
__sentry_node.flush(SENTRY_TIMEOUT);

//#endregion
//# sourceMappingURL=index.cjs.map