@tokamohsen/sentry-mcp 0.29.2 → 0.29.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +105 -0
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +19 -20
package/LICENSE.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Functional Source License, Version 1.1, Apache 2.0 Future License
|
|
2
|
+
|
|
3
|
+
## Abbreviation
|
|
4
|
+
|
|
5
|
+
FSL-1.1-Apache-2.0
|
|
6
|
+
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2008-2024 Functional Software, Inc. dba Sentry
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
28
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
+
|
|
30
|
+
### Permitted Purpose
|
|
31
|
+
|
|
32
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
+
means making the Software available to others in a commercial product or
|
|
34
|
+
service that:
|
|
35
|
+
|
|
36
|
+
1. substitutes for the Software;
|
|
37
|
+
|
|
38
|
+
2. substitutes for any other product or service we offer using the Software
|
|
39
|
+
that exists as of the date we make the Software available; or
|
|
40
|
+
|
|
41
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
+
|
|
43
|
+
Permitted Purposes specifically include using the Software:
|
|
44
|
+
|
|
45
|
+
1. for your internal use and access;
|
|
46
|
+
|
|
47
|
+
2. for non-commercial education;
|
|
48
|
+
|
|
49
|
+
3. for non-commercial research; and
|
|
50
|
+
|
|
51
|
+
4. in connection with professional services that you provide to a licensee
|
|
52
|
+
using the Software in accordance with these Terms and Conditions.
|
|
53
|
+
|
|
54
|
+
### Patents
|
|
55
|
+
|
|
56
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
+
patents, the license grant above includes a license under our patents. If you
|
|
58
|
+
make a claim against any party that the Software infringes or contributes to
|
|
59
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
60
|
+
immediately.
|
|
61
|
+
|
|
62
|
+
### Redistribution
|
|
63
|
+
|
|
64
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
+
the Software.
|
|
66
|
+
|
|
67
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
68
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
+
remove any copyright notices provided in or with the Software.
|
|
70
|
+
|
|
71
|
+
### Disclaimer
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
74
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
76
|
+
|
|
77
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
|
|
79
|
+
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
+
|
|
81
|
+
### Trademarks
|
|
82
|
+
|
|
83
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
84
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
85
|
+
trademarks, trade names, service marks or product names.
|
|
86
|
+
|
|
87
|
+
## Grant of Future License
|
|
88
|
+
|
|
89
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
+
the Apache License, Version 2.0 that is effective on the second anniversary of
|
|
91
|
+
the date we make the Software available. On or after that date, you may use the
|
|
92
|
+
Software under the Apache License, Version 2.0, in which case the following
|
|
93
|
+
will apply:
|
|
94
|
+
|
|
95
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
96
|
+
this file except in compliance with the License.
|
|
97
|
+
|
|
98
|
+
You may obtain a copy of the License at
|
|
99
|
+
|
|
100
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
101
|
+
|
|
102
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
|
103
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
104
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
105
|
+
specific language governing permissions and limitations under the License.
|
package/dist/index.cjs
CHANGED
|
@@ -22,11 +22,11 @@ let _sentry_mcp_core_internal_agents_provider_factory = require("@sentry/mcp-cor
|
|
|
22
22
|
*
|
|
23
23
|
* @example CLI Usage
|
|
24
24
|
* ```bash
|
|
25
|
-
* npx @sentry
|
|
26
|
-
* npx @sentry
|
|
25
|
+
* npx @tokamohsen/sentry-mcp --access-token=TOKEN --host=sentry.io
|
|
26
|
+
* npx @tokamohsen/sentry-mcp --access-token=TOKEN --url=https://sentry.example.com
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
|
-
const packageName = "@sentry
|
|
29
|
+
const packageName = "@tokamohsen/sentry-mcp";
|
|
30
30
|
const usageText = require_cli_usage.buildUsage(packageName, Object.keys(_sentry_mcp_core_skills.SKILLS));
|
|
31
31
|
function die(message) {
|
|
32
32
|
console.error(message);
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["buildUsage","SKILLS","parseArgv","LIB_VERSION","parseEnv","finalize","merge","Sentry","sentryBeforeSend","startStdio"],"sources":["../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * Main CLI entry point for the Sentry MCP server.\n *\n * Handles command-line argument parsing, environment configuration, Sentry\n * initialization, and starts the MCP server with stdio transport. Requires\n * a Sentry access token and optionally accepts host and DSN configuration.\n *\n * @example CLI Usage\n * ```bash\n * npx @sentry/mcp-server --access-token=TOKEN --host=sentry.io\n * npx @sentry/mcp-server --access-token=TOKEN --url=https://sentry.example.com\n * ```\n */\n\nimport { buildServer } from \"@sentry/mcp-core/server\";\nimport { startStdio } from \"./transports/stdio\";\nimport * as Sentry from \"@sentry/node\";\nimport { LIB_VERSION } from \"@sentry/mcp-core/version\";\nimport { buildUsage } from \"./cli/usage\";\nimport { parseArgv, parseEnv, merge } from \"./cli/parse\";\nimport { finalize } from \"./cli/resolve\";\nimport { sentryBeforeSend } from \"@sentry/mcp-core/telem/sentry\";\nimport { SKILLS } from \"@sentry/mcp-core/skills\";\nimport {\n setAgentProvider,\n setProviderBaseUrls,\n getResolvedProviderType,\n} from \"@sentry/mcp-core/internal/agents/provider-factory\";\n\nconst packageName = \"@sentry/mcp-server\";\nconst allSkills = Object.keys(SKILLS) as ReadonlyArray<\n (typeof SKILLS)[keyof typeof SKILLS][\"id\"]\n>;\nconst usageText = buildUsage(packageName, allSkills);\n\nfunction die(message: string): never {\n console.error(message);\n console.error(usageText);\n process.exit(1);\n}\nconst cli = parseArgv(process.argv.slice(2));\nif (cli.help) {\n console.log(usageText);\n process.exit(0);\n}\nif (cli.version) {\n console.log(`${packageName} ${LIB_VERSION}`);\n process.exit(0);\n}\nif (cli.unknownArgs.length > 0) {\n console.error(\"Error: Invalid argument(s):\", cli.unknownArgs.join(\", \"));\n console.error(usageText);\n process.exit(1);\n}\n\nconst env = parseEnv(process.env);\nconst cfg = (() => {\n try {\n return finalize(merge(cli, env));\n } catch (err) {\n die(err instanceof Error ? err.message : String(err));\n }\n})();\n\n// Configure embedded agent provider\nif (cfg.agentProvider) {\n setAgentProvider(cfg.agentProvider);\n}\nsetProviderBaseUrls({\n openaiBaseUrl: cfg.openaiBaseUrl,\n anthropicBaseUrl: cfg.anthropicBaseUrl,\n});\nif (cfg.openaiModel) {\n process.env.OPENAI_MODEL = cfg.openaiModel;\n}\nif (cfg.anthropicModel) {\n process.env.ANTHROPIC_MODEL = cfg.anthropicModel;\n}\n\n// Helper functions for provider status messages\nfunction hasProviderConflict(): boolean {\n const hasAnthropic = Boolean(process.env.ANTHROPIC_API_KEY);\n const hasOpenAI = Boolean(process.env.OPENAI_API_KEY);\n const hasExplicitProvider =\n cfg.agentProvider || process.env.EMBEDDED_AGENT_PROVIDER;\n return hasAnthropic && hasOpenAI && !hasExplicitProvider;\n}\n\nfunction getConfiguredProvider(): string | undefined {\n return (\n cfg.agentProvider || process.env.EMBEDDED_AGENT_PROVIDER?.toLowerCase()\n );\n}\n\nfunction hasProviderMismatch(): {\n mismatch: boolean;\n configured?: string;\n availableKey?: string;\n} {\n const configured = getConfiguredProvider();\n if (!configured) return { mismatch: false };\n\n const hasAnthropic = Boolean(process.env.ANTHROPIC_API_KEY);\n const hasOpenAI = Boolean(process.env.OPENAI_API_KEY);\n\n // Check if configured provider's key is missing but other key is present\n if (configured === \"openai\" && !hasOpenAI && hasAnthropic) {\n return {\n mismatch: true,\n configured: \"openai\",\n availableKey: \"ANTHROPIC_API_KEY\",\n };\n }\n if (configured === \"anthropic\" && !hasAnthropic && hasOpenAI) {\n return {\n mismatch: true,\n configured: \"anthropic\",\n availableKey: \"OPENAI_API_KEY\",\n };\n }\n\n return { mismatch: false };\n}\n\nfunction getProviderSource(): string {\n // Check CLI flag first (cli.agentProvider is only set by --agent-provider flag)\n if (cli.agentProvider) return \"explicitly configured\";\n // Then check env var (process.env takes precedence over cfg since cfg merges both)\n if (process.env.EMBEDDED_AGENT_PROVIDER)\n return \"from EMBEDDED_AGENT_PROVIDER\";\n return \"auto-detected\";\n}\n\n// Check for LLM API keys and warn if none available\nconst resolvedProvider = getResolvedProviderType();\n\nif (!resolvedProvider) {\n const mismatchInfo = hasProviderMismatch();\n if (hasProviderConflict()) {\n console.warn(\n \"Warning: Both ANTHROPIC_API_KEY and OPENAI_API_KEY are set, but no provider is explicitly configured.\",\n );\n console.warn(\n \"Please set EMBEDDED_AGENT_PROVIDER='openai' or 'anthropic' to specify which provider to use.\",\n );\n console.warn(\n \"AI-powered search tools will be unavailable until a provider is selected.\",\n );\n } else if (mismatchInfo.mismatch) {\n const expectedKey =\n mismatchInfo.configured === \"openai\"\n ? \"OPENAI_API_KEY\"\n : \"ANTHROPIC_API_KEY\";\n const configuredViaCliFlag = Boolean(cli.agentProvider);\n const providerSetting = configuredViaCliFlag\n ? `--agent-provider=${mismatchInfo.configured}`\n : `EMBEDDED_AGENT_PROVIDER='${mismatchInfo.configured}'`;\n const changeProviderHint = configuredViaCliFlag\n ? \"Change --agent-provider to match your available API key\"\n : \"Change EMBEDDED_AGENT_PROVIDER to match your available API key\";\n console.warn(`Warning: ${providerSetting} but ${expectedKey} is not set.`);\n console.warn(`Found ${mismatchInfo.availableKey} instead. Either:`);\n console.warn(\n ` - Set ${expectedKey} to use the ${mismatchInfo.configured} provider, or`,\n );\n console.warn(` - ${changeProviderHint}`);\n console.warn(\n \"AI-powered search tools will be unavailable until this is resolved.\",\n );\n } else {\n console.warn(\n \"Warning: No LLM API key found (OPENAI_API_KEY or ANTHROPIC_API_KEY).\",\n );\n console.warn(\"The following AI-powered search tools will be unavailable:\");\n console.warn(\n \" - search_events, search_issues, search_issue_events, use_sentry\",\n );\n console.warn(\n \"Use list_issues and list_events for direct Sentry query syntax instead.\",\n );\n }\n console.warn(\"\");\n} else {\n const providerSource = getProviderSource();\n console.warn(\n `Using ${resolvedProvider} for AI-powered search tools (${providerSource}).`,\n );\n // Warn about auto-detection deprecation\n if (providerSource === \"auto-detected\") {\n console.warn(\n \"Deprecation warning: Auto-detection of LLM provider is deprecated.\",\n );\n console.warn(\n `Please set EMBEDDED_AGENT_PROVIDER='${resolvedProvider}' explicitly.`,\n );\n console.warn(\"Auto-detection will be removed in a future release.\");\n }\n console.warn(\"\");\n}\n\nSentry.init({\n dsn: cfg.sentryDsn,\n sendDefaultPii: true,\n tracesSampleRate: 1,\n beforeSend: sentryBeforeSend,\n initialScope: {\n tags: {\n \"mcp.server_version\": LIB_VERSION,\n \"mcp.transport\": \"stdio\",\n \"mcp.agent_mode\": cli.agent ? \"true\" : \"false\",\n \"mcp.experimental_mode\": cli.experimental ? \"true\" : \"false\",\n \"sentry.host\": cfg.sentryHost,\n \"mcp.mcp-url\": cfg.mcpUrl,\n },\n },\n release: process.env.SENTRY_RELEASE,\n integrations: [\n Sentry.consoleLoggingIntegration(),\n Sentry.zodErrorsIntegration(),\n Sentry.vercelAIIntegration({\n recordInputs: true,\n recordOutputs: true,\n }),\n ],\n environment:\n process.env.SENTRY_ENVIRONMENT ??\n (process.env.NODE_ENV !== \"production\" ? \"development\" : \"production\"),\n});\n\n// Log agent mode status\nif (cli.agent) {\n console.warn(\"Agent mode enabled: Only use_sentry tool is available.\");\n console.warn(\n \"The use_sentry tool provides access to all Sentry operations through natural language.\",\n );\n console.warn(\"\");\n}\n\n// Log experimental mode status\nif (cli.experimental) {\n console.warn(\"Experimental mode enabled: Experimental tools are available.\");\n console.warn(\"\");\n}\n\nconst SENTRY_TIMEOUT = 5000; // 5 seconds\n\n// Graceful shutdown handlers\nasync function shutdown(signal: string) {\n console.error(`${signal} received, shutting down...`);\n await Sentry.flush(SENTRY_TIMEOUT);\n process.exit(0);\n}\n\nprocess.on(\"SIGTERM\", () => shutdown(\"SIGTERM\"));\nprocess.on(\"SIGINT\", () => shutdown(\"SIGINT\"));\n\n// Uncaught error handlers\nprocess.on(\"uncaughtException\", async (error) => {\n console.error(\"Uncaught exception:\", error);\n Sentry.captureException(error);\n await Sentry.flush(SENTRY_TIMEOUT);\n process.exit(1);\n});\n\nprocess.on(\"unhandledRejection\", async (reason) => {\n console.error(\"Unhandled rejection:\", reason);\n Sentry.captureException(reason);\n await Sentry.flush(SENTRY_TIMEOUT);\n process.exit(1);\n});\n\n// Build context once for server configuration and runtime\nconst context = {\n accessToken: cfg.accessToken,\n grantedSkills: cfg.finalSkills,\n constraints: {\n organizationSlug: cfg.organizationSlug ?? null,\n projectSlug: cfg.projectSlug ?? null,\n },\n sentryHost: cfg.sentryHost,\n mcpUrl: cfg.mcpUrl,\n openaiBaseUrl: cfg.openaiBaseUrl,\n agentMode: cli.agent,\n experimentalMode: cli.experimental,\n};\n\n// Build server with context to filter tools based on granted skills\n// Use agentMode when --agent flag is set (only exposes use_sentry tool)\n// Use experimentalMode when --experimental flag is set (includes experimental tools)\nconst server = buildServer({\n context,\n agentMode: cli.agent,\n experimentalMode: cli.experimental,\n});\n\nstartStdio(server, context).catch(async (err) => {\n console.error(\"Server error:\", err);\n Sentry.captureException(err);\n await Sentry.flush(SENTRY_TIMEOUT);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,cAAc;AAIpB,MAAM,YAAYA,6BAAW,aAHX,OAAO,KAAKC,+BAAO,CAGe;AAEpD,SAAS,IAAI,SAAwB;AACnC,SAAQ,MAAM,QAAQ;AACtB,SAAQ,MAAM,UAAU;AACxB,SAAQ,KAAK,EAAE;;AAEjB,MAAM,MAAMC,4BAAU,QAAQ,KAAK,MAAM,EAAE,CAAC;AAC5C,IAAI,IAAI,MAAM;AACZ,SAAQ,IAAI,UAAU;AACtB,SAAQ,KAAK,EAAE;;AAEjB,IAAI,IAAI,SAAS;AACf,SAAQ,IAAI,GAAG,YAAY,GAAGC,uCAAc;AAC5C,SAAQ,KAAK,EAAE;;AAEjB,IAAI,IAAI,YAAY,SAAS,GAAG;AAC9B,SAAQ,MAAM,+BA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,EAEiB,QAAQ,CAAC,MAAM,OAAO,QAAQ;AAC/C,SAAQ,MAAM,iBAAiB,IAAI;AACnC,cAAO,iBAAiB,IAAI;AAC5B,OAAMF,aAAO,MAAM,eAAe;AAClC,SAAQ,KAAK,EAAE;EACf"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["buildUsage","SKILLS","parseArgv","LIB_VERSION","parseEnv","finalize","merge","Sentry","sentryBeforeSend","startStdio"],"sources":["../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * Main CLI entry point for the Sentry MCP server.\n *\n * Handles command-line argument parsing, environment configuration, Sentry\n * initialization, and starts the MCP server with stdio transport. Requires\n * a Sentry access token and optionally accepts host and DSN configuration.\n *\n * @example CLI Usage\n * ```bash\n * npx @tokamohsen/sentry-mcp --access-token=TOKEN --host=sentry.io\n * npx @tokamohsen/sentry-mcp --access-token=TOKEN --url=https://sentry.example.com\n * ```\n */\n\nimport { buildServer } from \"@sentry/mcp-core/server\";\nimport { startStdio } from \"./transports/stdio\";\nimport * as Sentry from \"@sentry/node\";\nimport { LIB_VERSION } from \"@sentry/mcp-core/version\";\nimport { buildUsage } from \"./cli/usage\";\nimport { parseArgv, parseEnv, merge } from \"./cli/parse\";\nimport { finalize } from \"./cli/resolve\";\nimport { sentryBeforeSend } from \"@sentry/mcp-core/telem/sentry\";\nimport { SKILLS } from \"@sentry/mcp-core/skills\";\nimport {\n setAgentProvider,\n setProviderBaseUrls,\n getResolvedProviderType,\n} from \"@sentry/mcp-core/internal/agents/provider-factory\";\n\nconst packageName = \"@tokamohsen/sentry-mcp\";\nconst allSkills = Object.keys(SKILLS) as ReadonlyArray<\n (typeof SKILLS)[keyof typeof SKILLS][\"id\"]\n>;\nconst usageText = buildUsage(packageName, allSkills);\n\nfunction die(message: string): never {\n console.error(message);\n console.error(usageText);\n process.exit(1);\n}\nconst cli = parseArgv(process.argv.slice(2));\nif (cli.help) {\n console.log(usageText);\n process.exit(0);\n}\nif (cli.version) {\n console.log(`${packageName} ${LIB_VERSION}`);\n process.exit(0);\n}\nif (cli.unknownArgs.length > 0) {\n console.error(\"Error: Invalid argument(s):\", cli.unknownArgs.join(\", \"));\n console.error(usageText);\n process.exit(1);\n}\n\nconst env = parseEnv(process.env);\nconst cfg = (() => {\n try {\n return finalize(merge(cli, env));\n } catch (err) {\n die(err instanceof Error ? err.message : String(err));\n }\n})();\n\n// Configure embedded agent provider\nif (cfg.agentProvider) {\n setAgentProvider(cfg.agentProvider);\n}\nsetProviderBaseUrls({\n openaiBaseUrl: cfg.openaiBaseUrl,\n anthropicBaseUrl: cfg.anthropicBaseUrl,\n});\nif (cfg.openaiModel) {\n process.env.OPENAI_MODEL = cfg.openaiModel;\n}\nif (cfg.anthropicModel) {\n process.env.ANTHROPIC_MODEL = cfg.anthropicModel;\n}\n\n// Helper functions for provider status messages\nfunction hasProviderConflict(): boolean {\n const hasAnthropic = Boolean(process.env.ANTHROPIC_API_KEY);\n const hasOpenAI = Boolean(process.env.OPENAI_API_KEY);\n const hasExplicitProvider =\n cfg.agentProvider || process.env.EMBEDDED_AGENT_PROVIDER;\n return hasAnthropic && hasOpenAI && !hasExplicitProvider;\n}\n\nfunction getConfiguredProvider(): string | undefined {\n return (\n cfg.agentProvider || process.env.EMBEDDED_AGENT_PROVIDER?.toLowerCase()\n );\n}\n\nfunction hasProviderMismatch(): {\n mismatch: boolean;\n configured?: string;\n availableKey?: string;\n} {\n const configured = getConfiguredProvider();\n if (!configured) return { mismatch: false };\n\n const hasAnthropic = Boolean(process.env.ANTHROPIC_API_KEY);\n const hasOpenAI = Boolean(process.env.OPENAI_API_KEY);\n\n // Check if configured provider's key is missing but other key is present\n if (configured === \"openai\" && !hasOpenAI && hasAnthropic) {\n return {\n mismatch: true,\n configured: \"openai\",\n availableKey: \"ANTHROPIC_API_KEY\",\n };\n }\n if (configured === \"anthropic\" && !hasAnthropic && hasOpenAI) {\n return {\n mismatch: true,\n configured: \"anthropic\",\n availableKey: \"OPENAI_API_KEY\",\n };\n }\n\n return { mismatch: false };\n}\n\nfunction getProviderSource(): string {\n // Check CLI flag first (cli.agentProvider is only set by --agent-provider flag)\n if (cli.agentProvider) return \"explicitly configured\";\n // Then check env var (process.env takes precedence over cfg since cfg merges both)\n if (process.env.EMBEDDED_AGENT_PROVIDER)\n return \"from EMBEDDED_AGENT_PROVIDER\";\n return \"auto-detected\";\n}\n\n// Check for LLM API keys and warn if none available\nconst resolvedProvider = getResolvedProviderType();\n\nif (!resolvedProvider) {\n const mismatchInfo = hasProviderMismatch();\n if (hasProviderConflict()) {\n console.warn(\n \"Warning: Both ANTHROPIC_API_KEY and OPENAI_API_KEY are set, but no provider is explicitly configured.\",\n );\n console.warn(\n \"Please set EMBEDDED_AGENT_PROVIDER='openai' or 'anthropic' to specify which provider to use.\",\n );\n console.warn(\n \"AI-powered search tools will be unavailable until a provider is selected.\",\n );\n } else if (mismatchInfo.mismatch) {\n const expectedKey =\n mismatchInfo.configured === \"openai\"\n ? \"OPENAI_API_KEY\"\n : \"ANTHROPIC_API_KEY\";\n const configuredViaCliFlag = Boolean(cli.agentProvider);\n const providerSetting = configuredViaCliFlag\n ? `--agent-provider=${mismatchInfo.configured}`\n : `EMBEDDED_AGENT_PROVIDER='${mismatchInfo.configured}'`;\n const changeProviderHint = configuredViaCliFlag\n ? \"Change --agent-provider to match your available API key\"\n : \"Change EMBEDDED_AGENT_PROVIDER to match your available API key\";\n console.warn(`Warning: ${providerSetting} but ${expectedKey} is not set.`);\n console.warn(`Found ${mismatchInfo.availableKey} instead. Either:`);\n console.warn(\n ` - Set ${expectedKey} to use the ${mismatchInfo.configured} provider, or`,\n );\n console.warn(` - ${changeProviderHint}`);\n console.warn(\n \"AI-powered search tools will be unavailable until this is resolved.\",\n );\n } else {\n console.warn(\n \"Warning: No LLM API key found (OPENAI_API_KEY or ANTHROPIC_API_KEY).\",\n );\n console.warn(\"The following AI-powered search tools will be unavailable:\");\n console.warn(\n \" - search_events, search_issues, search_issue_events, use_sentry\",\n );\n console.warn(\n \"Use list_issues and list_events for direct Sentry query syntax instead.\",\n );\n }\n console.warn(\"\");\n} else {\n const providerSource = getProviderSource();\n console.warn(\n `Using ${resolvedProvider} for AI-powered search tools (${providerSource}).`,\n );\n // Warn about auto-detection deprecation\n if (providerSource === \"auto-detected\") {\n console.warn(\n \"Deprecation warning: Auto-detection of LLM provider is deprecated.\",\n );\n console.warn(\n `Please set EMBEDDED_AGENT_PROVIDER='${resolvedProvider}' explicitly.`,\n );\n console.warn(\"Auto-detection will be removed in a future release.\");\n }\n console.warn(\"\");\n}\n\nSentry.init({\n dsn: cfg.sentryDsn,\n sendDefaultPii: true,\n tracesSampleRate: 1,\n beforeSend: sentryBeforeSend,\n initialScope: {\n tags: {\n \"mcp.server_version\": LIB_VERSION,\n \"mcp.transport\": \"stdio\",\n \"mcp.agent_mode\": cli.agent ? \"true\" : \"false\",\n \"mcp.experimental_mode\": cli.experimental ? \"true\" : \"false\",\n \"sentry.host\": cfg.sentryHost,\n \"mcp.mcp-url\": cfg.mcpUrl,\n },\n },\n release: process.env.SENTRY_RELEASE,\n integrations: [\n Sentry.consoleLoggingIntegration(),\n Sentry.zodErrorsIntegration(),\n Sentry.vercelAIIntegration({\n recordInputs: true,\n recordOutputs: true,\n }),\n ],\n environment:\n process.env.SENTRY_ENVIRONMENT ??\n (process.env.NODE_ENV !== \"production\" ? \"development\" : \"production\"),\n});\n\n// Log agent mode status\nif (cli.agent) {\n console.warn(\"Agent mode enabled: Only use_sentry tool is available.\");\n console.warn(\n \"The use_sentry tool provides access to all Sentry operations through natural language.\",\n );\n console.warn(\"\");\n}\n\n// Log experimental mode status\nif (cli.experimental) {\n console.warn(\"Experimental mode enabled: Experimental tools are available.\");\n console.warn(\"\");\n}\n\nconst SENTRY_TIMEOUT = 5000; // 5 seconds\n\n// Graceful shutdown handlers\nasync function shutdown(signal: string) {\n console.error(`${signal} received, shutting down...`);\n await Sentry.flush(SENTRY_TIMEOUT);\n process.exit(0);\n}\n\nprocess.on(\"SIGTERM\", () => shutdown(\"SIGTERM\"));\nprocess.on(\"SIGINT\", () => shutdown(\"SIGINT\"));\n\n// Uncaught error handlers\nprocess.on(\"uncaughtException\", async (error) => {\n console.error(\"Uncaught exception:\", error);\n Sentry.captureException(error);\n await Sentry.flush(SENTRY_TIMEOUT);\n process.exit(1);\n});\n\nprocess.on(\"unhandledRejection\", async (reason) => {\n console.error(\"Unhandled rejection:\", reason);\n Sentry.captureException(reason);\n await Sentry.flush(SENTRY_TIMEOUT);\n process.exit(1);\n});\n\n// Build context once for server configuration and runtime\nconst context = {\n accessToken: cfg.accessToken,\n grantedSkills: cfg.finalSkills,\n constraints: {\n organizationSlug: cfg.organizationSlug ?? null,\n projectSlug: cfg.projectSlug ?? null,\n },\n sentryHost: cfg.sentryHost,\n mcpUrl: cfg.mcpUrl,\n openaiBaseUrl: cfg.openaiBaseUrl,\n agentMode: cli.agent,\n experimentalMode: cli.experimental,\n};\n\n// Build server with context to filter tools based on granted skills\n// Use agentMode when --agent flag is set (only exposes use_sentry tool)\n// Use experimentalMode when --experimental flag is set (includes experimental tools)\nconst server = buildServer({\n context,\n agentMode: cli.agent,\n experimentalMode: cli.experimental,\n});\n\nstartStdio(server, context).catch(async (err) => {\n console.error(\"Server error:\", err);\n Sentry.captureException(err);\n await Sentry.flush(SENTRY_TIMEOUT);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,cAAc;AAIpB,MAAM,YAAYA,6BAAW,aAHX,OAAO,KAAKC,+BAAO,CAGe;AAEpD,SAAS,IAAI,SAAwB;AACnC,SAAQ,MAAM,QAAQ;AACtB,SAAQ,MAAM,UAAU;AACxB,SAAQ,KAAK,EAAE;;AAEjB,MAAM,MAAMC,4BAAU,QAAQ,KAAK,MAAM,EAAE,CAAC;AAC5C,IAAI,IAAI,MAAM;AACZ,SAAQ,IAAI,UAAU;AACtB,SAAQ,KAAK,EAAE;;AAEjB,IAAI,IAAI,SAA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IAAI;CACZ,eAAe,IAAI;CACnB,WAAW,IAAI;CACf,kBAAkB,IAAI;CACvB;AAWDE,6EAN2B;CACzB;CACA,WAAW,IAAI;CACf,kBAAkB,IAAI;CACvB,CAAC,EAEiB,QAAQ,CAAC,MAAM,OAAO,QAAQ;AAC/C,SAAQ,MAAM,iBAAiB,IAAI;AACnC,cAAO,iBAAiB,IAAI;AAC5B,OAAMF,aAAO,MAAM,eAAe;AAClC,SAAQ,KAAK,EAAE;EACf"}
|
package/dist/index.js
CHANGED
|
@@ -20,11 +20,11 @@ import { getResolvedProviderType, setAgentProvider, setProviderBaseUrls } from "
|
|
|
20
20
|
*
|
|
21
21
|
* @example CLI Usage
|
|
22
22
|
* ```bash
|
|
23
|
-
* npx @sentry
|
|
24
|
-
* npx @sentry
|
|
23
|
+
* npx @tokamohsen/sentry-mcp --access-token=TOKEN --host=sentry.io
|
|
24
|
+
* npx @tokamohsen/sentry-mcp --access-token=TOKEN --url=https://sentry.example.com
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
27
|
-
const packageName = "@sentry
|
|
27
|
+
const packageName = "@tokamohsen/sentry-mcp";
|
|
28
28
|
const usageText = buildUsage(packageName, Object.keys(SKILLS));
|
|
29
29
|
function die(message) {
|
|
30
30
|
console.error(message);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * Main CLI entry point for the Sentry MCP server.\n *\n * Handles command-line argument parsing, environment configuration, Sentry\n * initialization, and starts the MCP server with stdio transport. Requires\n * a Sentry access token and optionally accepts host and DSN configuration.\n *\n * @example CLI Usage\n * ```bash\n * npx @sentry/mcp-server --access-token=TOKEN --host=sentry.io\n * npx @sentry/mcp-server --access-token=TOKEN --url=https://sentry.example.com\n * ```\n */\n\nimport { buildServer } from \"@sentry/mcp-core/server\";\nimport { startStdio } from \"./transports/stdio\";\nimport * as Sentry from \"@sentry/node\";\nimport { LIB_VERSION } from \"@sentry/mcp-core/version\";\nimport { buildUsage } from \"./cli/usage\";\nimport { parseArgv, parseEnv, merge } from \"./cli/parse\";\nimport { finalize } from \"./cli/resolve\";\nimport { sentryBeforeSend } from \"@sentry/mcp-core/telem/sentry\";\nimport { SKILLS } from \"@sentry/mcp-core/skills\";\nimport {\n setAgentProvider,\n setProviderBaseUrls,\n getResolvedProviderType,\n} from \"@sentry/mcp-core/internal/agents/provider-factory\";\n\nconst packageName = \"@sentry/mcp-server\";\nconst allSkills = Object.keys(SKILLS) as ReadonlyArray<\n (typeof SKILLS)[keyof typeof SKILLS][\"id\"]\n>;\nconst usageText = buildUsage(packageName, allSkills);\n\nfunction die(message: string): never {\n console.error(message);\n console.error(usageText);\n process.exit(1);\n}\nconst cli = parseArgv(process.argv.slice(2));\nif (cli.help) {\n console.log(usageText);\n process.exit(0);\n}\nif (cli.version) {\n console.log(`${packageName} ${LIB_VERSION}`);\n process.exit(0);\n}\nif (cli.unknownArgs.length > 0) {\n console.error(\"Error: Invalid argument(s):\", cli.unknownArgs.join(\", \"));\n console.error(usageText);\n process.exit(1);\n}\n\nconst env = parseEnv(process.env);\nconst cfg = (() => {\n try {\n return finalize(merge(cli, env));\n } catch (err) {\n die(err instanceof Error ? err.message : String(err));\n }\n})();\n\n// Configure embedded agent provider\nif (cfg.agentProvider) {\n setAgentProvider(cfg.agentProvider);\n}\nsetProviderBaseUrls({\n openaiBaseUrl: cfg.openaiBaseUrl,\n anthropicBaseUrl: cfg.anthropicBaseUrl,\n});\nif (cfg.openaiModel) {\n process.env.OPENAI_MODEL = cfg.openaiModel;\n}\nif (cfg.anthropicModel) {\n process.env.ANTHROPIC_MODEL = cfg.anthropicModel;\n}\n\n// Helper functions for provider status messages\nfunction hasProviderConflict(): boolean {\n const hasAnthropic = Boolean(process.env.ANTHROPIC_API_KEY);\n const hasOpenAI = Boolean(process.env.OPENAI_API_KEY);\n const hasExplicitProvider =\n cfg.agentProvider || process.env.EMBEDDED_AGENT_PROVIDER;\n return hasAnthropic && hasOpenAI && !hasExplicitProvider;\n}\n\nfunction getConfiguredProvider(): string | undefined {\n return (\n cfg.agentProvider || process.env.EMBEDDED_AGENT_PROVIDER?.toLowerCase()\n );\n}\n\nfunction hasProviderMismatch(): {\n mismatch: boolean;\n configured?: string;\n availableKey?: string;\n} {\n const configured = getConfiguredProvider();\n if (!configured) return { mismatch: false };\n\n const hasAnthropic = Boolean(process.env.ANTHROPIC_API_KEY);\n const hasOpenAI = Boolean(process.env.OPENAI_API_KEY);\n\n // Check if configured provider's key is missing but other key is present\n if (configured === \"openai\" && !hasOpenAI && hasAnthropic) {\n return {\n mismatch: true,\n configured: \"openai\",\n availableKey: \"ANTHROPIC_API_KEY\",\n };\n }\n if (configured === \"anthropic\" && !hasAnthropic && hasOpenAI) {\n return {\n mismatch: true,\n configured: \"anthropic\",\n availableKey: \"OPENAI_API_KEY\",\n };\n }\n\n return { mismatch: false };\n}\n\nfunction getProviderSource(): string {\n // Check CLI flag first (cli.agentProvider is only set by --agent-provider flag)\n if (cli.agentProvider) return \"explicitly configured\";\n // Then check env var (process.env takes precedence over cfg since cfg merges both)\n if (process.env.EMBEDDED_AGENT_PROVIDER)\n return \"from EMBEDDED_AGENT_PROVIDER\";\n return \"auto-detected\";\n}\n\n// Check for LLM API keys and warn if none available\nconst resolvedProvider = getResolvedProviderType();\n\nif (!resolvedProvider) {\n const mismatchInfo = hasProviderMismatch();\n if (hasProviderConflict()) {\n console.warn(\n \"Warning: Both ANTHROPIC_API_KEY and OPENAI_API_KEY are set, but no provider is explicitly configured.\",\n );\n console.warn(\n \"Please set EMBEDDED_AGENT_PROVIDER='openai' or 'anthropic' to specify which provider to use.\",\n );\n console.warn(\n \"AI-powered search tools will be unavailable until a provider is selected.\",\n );\n } else if (mismatchInfo.mismatch) {\n const expectedKey =\n mismatchInfo.configured === \"openai\"\n ? \"OPENAI_API_KEY\"\n : \"ANTHROPIC_API_KEY\";\n const configuredViaCliFlag = Boolean(cli.agentProvider);\n const providerSetting = configuredViaCliFlag\n ? `--agent-provider=${mismatchInfo.configured}`\n : `EMBEDDED_AGENT_PROVIDER='${mismatchInfo.configured}'`;\n const changeProviderHint = configuredViaCliFlag\n ? \"Change --agent-provider to match your available API key\"\n : \"Change EMBEDDED_AGENT_PROVIDER to match your available API key\";\n console.warn(`Warning: ${providerSetting} but ${expectedKey} is not set.`);\n console.warn(`Found ${mismatchInfo.availableKey} instead. Either:`);\n console.warn(\n ` - Set ${expectedKey} to use the ${mismatchInfo.configured} provider, or`,\n );\n console.warn(` - ${changeProviderHint}`);\n console.warn(\n \"AI-powered search tools will be unavailable until this is resolved.\",\n );\n } else {\n console.warn(\n \"Warning: No LLM API key found (OPENAI_API_KEY or ANTHROPIC_API_KEY).\",\n );\n console.warn(\"The following AI-powered search tools will be unavailable:\");\n console.warn(\n \" - search_events, search_issues, search_issue_events, use_sentry\",\n );\n console.warn(\n \"Use list_issues and list_events for direct Sentry query syntax instead.\",\n );\n }\n console.warn(\"\");\n} else {\n const providerSource = getProviderSource();\n console.warn(\n `Using ${resolvedProvider} for AI-powered search tools (${providerSource}).`,\n );\n // Warn about auto-detection deprecation\n if (providerSource === \"auto-detected\") {\n console.warn(\n \"Deprecation warning: Auto-detection of LLM provider is deprecated.\",\n );\n console.warn(\n `Please set EMBEDDED_AGENT_PROVIDER='${resolvedProvider}' explicitly.`,\n );\n console.warn(\"Auto-detection will be removed in a future release.\");\n }\n console.warn(\"\");\n}\n\nSentry.init({\n dsn: cfg.sentryDsn,\n sendDefaultPii: true,\n tracesSampleRate: 1,\n beforeSend: sentryBeforeSend,\n initialScope: {\n tags: {\n \"mcp.server_version\": LIB_VERSION,\n \"mcp.transport\": \"stdio\",\n \"mcp.agent_mode\": cli.agent ? \"true\" : \"false\",\n \"mcp.experimental_mode\": cli.experimental ? \"true\" : \"false\",\n \"sentry.host\": cfg.sentryHost,\n \"mcp.mcp-url\": cfg.mcpUrl,\n },\n },\n release: process.env.SENTRY_RELEASE,\n integrations: [\n Sentry.consoleLoggingIntegration(),\n Sentry.zodErrorsIntegration(),\n Sentry.vercelAIIntegration({\n recordInputs: true,\n recordOutputs: true,\n }),\n ],\n environment:\n process.env.SENTRY_ENVIRONMENT ??\n (process.env.NODE_ENV !== \"production\" ? \"development\" : \"production\"),\n});\n\n// Log agent mode status\nif (cli.agent) {\n console.warn(\"Agent mode enabled: Only use_sentry tool is available.\");\n console.warn(\n \"The use_sentry tool provides access to all Sentry operations through natural language.\",\n );\n console.warn(\"\");\n}\n\n// Log experimental mode status\nif (cli.experimental) {\n console.warn(\"Experimental mode enabled: Experimental tools are available.\");\n console.warn(\"\");\n}\n\nconst SENTRY_TIMEOUT = 5000; // 5 seconds\n\n// Graceful shutdown handlers\nasync function shutdown(signal: string) {\n console.error(`${signal} received, shutting down...`);\n await Sentry.flush(SENTRY_TIMEOUT);\n process.exit(0);\n}\n\nprocess.on(\"SIGTERM\", () => shutdown(\"SIGTERM\"));\nprocess.on(\"SIGINT\", () => shutdown(\"SIGINT\"));\n\n// Uncaught error handlers\nprocess.on(\"uncaughtException\", async (error) => {\n console.error(\"Uncaught exception:\", error);\n Sentry.captureException(error);\n await Sentry.flush(SENTRY_TIMEOUT);\n process.exit(1);\n});\n\nprocess.on(\"unhandledRejection\", async (reason) => {\n console.error(\"Unhandled rejection:\", reason);\n Sentry.captureException(reason);\n await Sentry.flush(SENTRY_TIMEOUT);\n process.exit(1);\n});\n\n// Build context once for server configuration and runtime\nconst context = {\n accessToken: cfg.accessToken,\n grantedSkills: cfg.finalSkills,\n constraints: {\n organizationSlug: cfg.organizationSlug ?? null,\n projectSlug: cfg.projectSlug ?? null,\n },\n sentryHost: cfg.sentryHost,\n mcpUrl: cfg.mcpUrl,\n openaiBaseUrl: cfg.openaiBaseUrl,\n agentMode: cli.agent,\n experimentalMode: cli.experimental,\n};\n\n// Build server with context to filter tools based on granted skills\n// Use agentMode when --agent flag is set (only exposes use_sentry tool)\n// Use experimentalMode when --experimental flag is set (includes experimental tools)\nconst server = buildServer({\n context,\n agentMode: cli.agent,\n experimentalMode: cli.experimental,\n});\n\nstartStdio(server, context).catch(async (err) => {\n console.error(\"Server error:\", err);\n Sentry.captureException(err);\n await Sentry.flush(SENTRY_TIMEOUT);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,cAAc;AAIpB,MAAM,YAAY,WAAW,aAHX,OAAO,KAAK,OAAO,CAGe;AAEpD,SAAS,IAAI,SAAwB;AACnC,SAAQ,MAAM,QAAQ;AACtB,SAAQ,MAAM,UAAU;AACxB,SAAQ,KAAK,EAAE;;AAEjB,MAAM,MAAM,UAAU,QAAQ,KAAK,MAAM,EAAE,CAAC;AAC5C,IAAI,IAAI,MAAM;AACZ,SAAQ,IAAI,UAAU;AACtB,SAAQ,KAAK,EAAE;;AAEjB,IAAI,IAAI,SAAS;AACf,SAAQ,IAAI,GAAG,YAAY,GAAG,cAAc;AAC5C,SAAQ,KAAK,EAAE;;AAEjB,IAAI,IAAI,YAAY,SAAS,GAAG;AAC9B,SAAQ,MAAM,+BAA+B,IAAI,YAAY,KAAK,KAAK,CAAC;AACxE,SAAQ,MAAM,UAAU;AACxB,SAAQ,KAAK,EAAE;;AAGjB,MAAM,MAAM,SAAS,QAAQ,IAAI;AACjC,MAAM,aAAa;AACjB,KAAI;AACF,SAAO,SAAS,MAAM,KAAK,IAAI,CAAC;UACzB,KAAK;AACZ,MAAI,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI,CAAC;;IAErD;AAGJ,IAAI,IAAI,cACN,kBAAiB,IAAI,cAAc;AAErC,oBAAoB;CAClB,eAAe,IAAI;CACnB,kBAAkB,IAAI;CACvB,CAAC;AACF,IAAI,IAAI,YACN,SAAQ,IAAI,eAAe,IAAI;AAEjC,IAAI,IAAI,eACN,SAAQ,IAAI,kBAAkB,IAAI;AAIpC,SAAS,sBAA+B;CACtC,MAAM,eAAe,QAAQ,QAAQ,I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,GAAG,iBAAiB,SAAS,UAAU,CAAC;AAChD,QAAQ,GAAG,gBAAgB,SAAS,SAAS,CAAC;AAG9C,QAAQ,GAAG,qBAAqB,OAAO,UAAU;AAC/C,SAAQ,MAAM,uBAAuB,MAAM;AAC3C,QAAO,iBAAiB,MAAM;AAC9B,OAAM,OAAO,MAAM,eAAe;AAClC,SAAQ,KAAK,EAAE;EACf;AAEF,QAAQ,GAAG,sBAAsB,OAAO,WAAW;AACjD,SAAQ,MAAM,wBAAwB,OAAO;AAC7C,QAAO,iBAAiB,OAAO;AAC/B,OAAM,OAAO,MAAM,eAAe;AAClC,SAAQ,KAAK,EAAE;EACf;AAGF,MAAM,UAAU;CACd,aAAa,IAAI;CACjB,eAAe,IAAI;CACnB,aAAa;EACX,kBAAkB,IAAI,oBAAoB;EAC1C,aAAa,IAAI,eAAe;EACjC;CACD,YAAY,IAAI;CAChB,QAAQ,IAAI;CACZ,eAAe,IAAI;CACnB,WAAW,IAAI;CACf,kBAAkB,IAAI;CACvB;AAWD,WANe,YAAY;CACzB;CACA,WAAW,IAAI;CACf,kBAAkB,IAAI;CACvB,CAAC,EAEiB,QAAQ,CAAC,MAAM,OAAO,QAAQ;AAC/C,SAAQ,MAAM,iBAAiB,IAAI;AACnC,QAAO,iBAAiB,IAAI;AAC5B,OAAM,OAAO,MAAM,eAAe;AAClC,SAAQ,KAAK,EAAE;EACf"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * Main CLI entry point for the Sentry MCP server.\n *\n * Handles command-line argument parsing, environment configuration, Sentry\n * initialization, and starts the MCP server with stdio transport. Requires\n * a Sentry access token and optionally accepts host and DSN configuration.\n *\n * @example CLI Usage\n * ```bash\n * npx @tokamohsen/sentry-mcp --access-token=TOKEN --host=sentry.io\n * npx @tokamohsen/sentry-mcp --access-token=TOKEN --url=https://sentry.example.com\n * ```\n */\n\nimport { buildServer } from \"@sentry/mcp-core/server\";\nimport { startStdio } from \"./transports/stdio\";\nimport * as Sentry from \"@sentry/node\";\nimport { LIB_VERSION } from \"@sentry/mcp-core/version\";\nimport { buildUsage } from \"./cli/usage\";\nimport { parseArgv, parseEnv, merge } from \"./cli/parse\";\nimport { finalize } from \"./cli/resolve\";\nimport { sentryBeforeSend } from \"@sentry/mcp-core/telem/sentry\";\nimport { SKILLS } from \"@sentry/mcp-core/skills\";\nimport {\n setAgentProvider,\n setProviderBaseUrls,\n getResolvedProviderType,\n} from \"@sentry/mcp-core/internal/agents/provider-factory\";\n\nconst packageName = \"@tokamohsen/sentry-mcp\";\nconst allSkills = Object.keys(SKILLS) as ReadonlyArray<\n (typeof SKILLS)[keyof typeof SKILLS][\"id\"]\n>;\nconst usageText = buildUsage(packageName, allSkills);\n\nfunction die(message: string): never {\n console.error(message);\n console.error(usageText);\n process.exit(1);\n}\nconst cli = parseArgv(process.argv.slice(2));\nif (cli.help) {\n console.log(usageText);\n process.exit(0);\n}\nif (cli.version) {\n console.log(`${packageName} ${LIB_VERSION}`);\n process.exit(0);\n}\nif (cli.unknownArgs.length > 0) {\n console.error(\"Error: Invalid argument(s):\", cli.unknownArgs.join(\", \"));\n console.error(usageText);\n process.exit(1);\n}\n\nconst env = parseEnv(process.env);\nconst cfg = (() => {\n try {\n return finalize(merge(cli, env));\n } catch (err) {\n die(err instanceof Error ? err.message : String(err));\n }\n})();\n\n// Configure embedded agent provider\nif (cfg.agentProvider) {\n setAgentProvider(cfg.agentProvider);\n}\nsetProviderBaseUrls({\n openaiBaseUrl: cfg.openaiBaseUrl,\n anthropicBaseUrl: cfg.anthropicBaseUrl,\n});\nif (cfg.openaiModel) {\n process.env.OPENAI_MODEL = cfg.openaiModel;\n}\nif (cfg.anthropicModel) {\n process.env.ANTHROPIC_MODEL = cfg.anthropicModel;\n}\n\n// Helper functions for provider status messages\nfunction hasProviderConflict(): boolean {\n const hasAnthropic = Boolean(process.env.ANTHROPIC_API_KEY);\n const hasOpenAI = Boolean(process.env.OPENAI_API_KEY);\n const hasExplicitProvider =\n cfg.agentProvider || process.env.EMBEDDED_AGENT_PROVIDER;\n return hasAnthropic && hasOpenAI && !hasExplicitProvider;\n}\n\nfunction getConfiguredProvider(): string | undefined {\n return (\n cfg.agentProvider || process.env.EMBEDDED_AGENT_PROVIDER?.toLowerCase()\n );\n}\n\nfunction hasProviderMismatch(): {\n mismatch: boolean;\n configured?: string;\n availableKey?: string;\n} {\n const configured = getConfiguredProvider();\n if (!configured) return { mismatch: false };\n\n const hasAnthropic = Boolean(process.env.ANTHROPIC_API_KEY);\n const hasOpenAI = Boolean(process.env.OPENAI_API_KEY);\n\n // Check if configured provider's key is missing but other key is present\n if (configured === \"openai\" && !hasOpenAI && hasAnthropic) {\n return {\n mismatch: true,\n configured: \"openai\",\n availableKey: \"ANTHROPIC_API_KEY\",\n };\n }\n if (configured === \"anthropic\" && !hasAnthropic && hasOpenAI) {\n return {\n mismatch: true,\n configured: \"anthropic\",\n availableKey: \"OPENAI_API_KEY\",\n };\n }\n\n return { mismatch: false };\n}\n\nfunction getProviderSource(): string {\n // Check CLI flag first (cli.agentProvider is only set by --agent-provider flag)\n if (cli.agentProvider) return \"explicitly configured\";\n // Then check env var (process.env takes precedence over cfg since cfg merges both)\n if (process.env.EMBEDDED_AGENT_PROVIDER)\n return \"from EMBEDDED_AGENT_PROVIDER\";\n return \"auto-detected\";\n}\n\n// Check for LLM API keys and warn if none available\nconst resolvedProvider = getResolvedProviderType();\n\nif (!resolvedProvider) {\n const mismatchInfo = hasProviderMismatch();\n if (hasProviderConflict()) {\n console.warn(\n \"Warning: Both ANTHROPIC_API_KEY and OPENAI_API_KEY are set, but no provider is explicitly configured.\",\n );\n console.warn(\n \"Please set EMBEDDED_AGENT_PROVIDER='openai' or 'anthropic' to specify which provider to use.\",\n );\n console.warn(\n \"AI-powered search tools will be unavailable until a provider is selected.\",\n );\n } else if (mismatchInfo.mismatch) {\n const expectedKey =\n mismatchInfo.configured === \"openai\"\n ? \"OPENAI_API_KEY\"\n : \"ANTHROPIC_API_KEY\";\n const configuredViaCliFlag = Boolean(cli.agentProvider);\n const providerSetting = configuredViaCliFlag\n ? `--agent-provider=${mismatchInfo.configured}`\n : `EMBEDDED_AGENT_PROVIDER='${mismatchInfo.configured}'`;\n const changeProviderHint = configuredViaCliFlag\n ? \"Change --agent-provider to match your available API key\"\n : \"Change EMBEDDED_AGENT_PROVIDER to match your available API key\";\n console.warn(`Warning: ${providerSetting} but ${expectedKey} is not set.`);\n console.warn(`Found ${mismatchInfo.availableKey} instead. Either:`);\n console.warn(\n ` - Set ${expectedKey} to use the ${mismatchInfo.configured} provider, or`,\n );\n console.warn(` - ${changeProviderHint}`);\n console.warn(\n \"AI-powered search tools will be unavailable until this is resolved.\",\n );\n } else {\n console.warn(\n \"Warning: No LLM API key found (OPENAI_API_KEY or ANTHROPIC_API_KEY).\",\n );\n console.warn(\"The following AI-powered search tools will be unavailable:\");\n console.warn(\n \" - search_events, search_issues, search_issue_events, use_sentry\",\n );\n console.warn(\n \"Use list_issues and list_events for direct Sentry query syntax instead.\",\n );\n }\n console.warn(\"\");\n} else {\n const providerSource = getProviderSource();\n console.warn(\n `Using ${resolvedProvider} for AI-powered search tools (${providerSource}).`,\n );\n // Warn about auto-detection deprecation\n if (providerSource === \"auto-detected\") {\n console.warn(\n \"Deprecation warning: Auto-detection of LLM provider is deprecated.\",\n );\n console.warn(\n `Please set EMBEDDED_AGENT_PROVIDER='${resolvedProvider}' explicitly.`,\n );\n console.warn(\"Auto-detection will be removed in a future release.\");\n }\n console.warn(\"\");\n}\n\nSentry.init({\n dsn: cfg.sentryDsn,\n sendDefaultPii: true,\n tracesSampleRate: 1,\n beforeSend: sentryBeforeSend,\n initialScope: {\n tags: {\n \"mcp.server_version\": LIB_VERSION,\n \"mcp.transport\": \"stdio\",\n \"mcp.agent_mode\": cli.agent ? \"true\" : \"false\",\n \"mcp.experimental_mode\": cli.experimental ? \"true\" : \"false\",\n \"sentry.host\": cfg.sentryHost,\n \"mcp.mcp-url\": cfg.mcpUrl,\n },\n },\n release: process.env.SENTRY_RELEASE,\n integrations: [\n Sentry.consoleLoggingIntegration(),\n Sentry.zodErrorsIntegration(),\n Sentry.vercelAIIntegration({\n recordInputs: true,\n recordOutputs: true,\n }),\n ],\n environment:\n process.env.SENTRY_ENVIRONMENT ??\n (process.env.NODE_ENV !== \"production\" ? \"development\" : \"production\"),\n});\n\n// Log agent mode status\nif (cli.agent) {\n console.warn(\"Agent mode enabled: Only use_sentry tool is available.\");\n console.warn(\n \"The use_sentry tool provides access to all Sentry operations through natural language.\",\n );\n console.warn(\"\");\n}\n\n// Log experimental mode status\nif (cli.experimental) {\n console.warn(\"Experimental mode enabled: Experimental tools are available.\");\n console.warn(\"\");\n}\n\nconst SENTRY_TIMEOUT = 5000; // 5 seconds\n\n// Graceful shutdown handlers\nasync function shutdown(signal: string) {\n console.error(`${signal} received, shutting down...`);\n await Sentry.flush(SENTRY_TIMEOUT);\n process.exit(0);\n}\n\nprocess.on(\"SIGTERM\", () => shutdown(\"SIGTERM\"));\nprocess.on(\"SIGINT\", () => shutdown(\"SIGINT\"));\n\n// Uncaught error handlers\nprocess.on(\"uncaughtException\", async (error) => {\n console.error(\"Uncaught exception:\", error);\n Sentry.captureException(error);\n await Sentry.flush(SENTRY_TIMEOUT);\n process.exit(1);\n});\n\nprocess.on(\"unhandledRejection\", async (reason) => {\n console.error(\"Unhandled rejection:\", reason);\n Sentry.captureException(reason);\n await Sentry.flush(SENTRY_TIMEOUT);\n process.exit(1);\n});\n\n// Build context once for server configuration and runtime\nconst context = {\n accessToken: cfg.accessToken,\n grantedSkills: cfg.finalSkills,\n constraints: {\n organizationSlug: cfg.organizationSlug ?? null,\n projectSlug: cfg.projectSlug ?? null,\n },\n sentryHost: cfg.sentryHost,\n mcpUrl: cfg.mcpUrl,\n openaiBaseUrl: cfg.openaiBaseUrl,\n agentMode: cli.agent,\n experimentalMode: cli.experimental,\n};\n\n// Build server with context to filter tools based on granted skills\n// Use agentMode when --agent flag is set (only exposes use_sentry tool)\n// Use experimentalMode when --experimental flag is set (includes experimental tools)\nconst server = buildServer({\n context,\n agentMode: cli.agent,\n experimentalMode: cli.experimental,\n});\n\nstartStdio(server, context).catch(async (err) => {\n console.error(\"Server error:\", err);\n Sentry.captureException(err);\n await Sentry.flush(SENTRY_TIMEOUT);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,cAAc;AAIpB,MAAM,YAAY,WAAW,aAHX,OAAO,KAAK,OAAO,CAGe;AAEpD,SAAS,IAAI,SAAwB;AACnC,SAAQ,MAAM,QAAQ;AACtB,SAAQ,MAAM,UAAU;AACxB,SAAQ,KAAK,EAAE;;AAEjB,MAAM,MAAM,UAAU,QAAQ,KAAK,MAAM,EAAE,CAAC;AAC5C,IAAI,IAAI,MAAM;AACZ,SAAQ,IAAI,UAAU;AACtB,SAAQ,KAAK,EAAE;;AAEjB,IAAI,IAAI,SAAS;AACf,SAAQ,IAAI,GAAG,YAAY,GAAG,cAAc;AAC5C,SAAQ,KAAK,EAAE;;AAEjB,IAAI,IAAI,YAAY,SAAS,GAAG;AAC9B,SAAQ,MAAM,+BAA+B,IAAI,YAAY,KAAK,KAAK,CAAC;AACxE,SAAQ,MAAM,UAAU;AACxB,SAAQ,KAAK,EAAE;;AAGjB,MAAM,MAAM,SAAS,QAAQ,IAAI;AACjC,MAAM,aAAa;AACjB,KAAI;AACF,SAAO,SAAS,MAAM,KAAK,IAAI,CAAC;UACzB,KAAK;AACZ,MAAI,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI,CAAC;;IAErD;AAGJ,IAAI,IAAI,cACN,kBAAiB,IAAI,cAAc;AAErC,oBAAoB;CAClB,eAAe,IAAI;CACnB,kBAAkB,IAAI;CACvB,CAAC;AACF,IAAI,IAAI,YACN,SAAQ,IAAI,eAAe,IAAI;AAEjC,IAAI,IAAI,eACN,SAAQ,IAAI,kBAAkB,IAAI;AAIpC,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M,eAAe;AAClC,SAAQ,KAAK,EAAE;;AAGjB,QAAQ,GAAG,iBAAiB,SAAS,UAAU,CAAC;AAChD,QAAQ,GAAG,gBAAgB,SAAS,SAAS,CAAC;AAG9C,QAAQ,GAAG,qBAAqB,OAAO,UAAU;AAC/C,SAAQ,MAAM,uBAAuB,MAAM;AAC3C,QAAO,iBAAiB,MAAM;AAC9B,OAAM,OAAO,MAAM,eAAe;AAClC,SAAQ,KAAK,EAAE;EACf;AAEF,QAAQ,GAAG,sBAAsB,OAAO,WAAW;AACjD,SAAQ,MAAM,wBAAwB,OAAO;AAC7C,QAAO,iBAAiB,OAAO;AAC/B,OAAM,OAAO,MAAM,eAAe;AAClC,SAAQ,KAAK,EAAE;EACf;AAGF,MAAM,UAAU;CACd,aAAa,IAAI;CACjB,eAAe,IAAI;CACnB,aAAa;EACX,kBAAkB,IAAI,oBAAoB;EAC1C,aAAa,IAAI,eAAe;EACjC;CACD,YAAY,IAAI;CAChB,QAAQ,IAAI;CACZ,eAAe,IAAI;CACnB,WAAW,IAAI;CACf,kBAAkB,IAAI;CACvB;AAWD,WANe,YAAY;CACzB;CACA,WAAW,IAAI;CACf,kBAAkB,IAAI;CACvB,CAAC,EAEiB,QAAQ,CAAC,MAAM,OAAO,QAAQ;AAC/C,SAAQ,MAAM,iBAAiB,IAAI;AACnC,QAAO,iBAAiB,IAAI;AAC5B,OAAM,OAAO,MAAM,eAAe;AAClC,SAAQ,KAAK,EAAE;EACf"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokamohsen/sentry-mcp",
|
|
3
3
|
"mcpName": "io.github.getsentry/sentry-mcp",
|
|
4
|
-
"version": "0.29.
|
|
4
|
+
"version": "0.29.4",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"packageManager": "pnpm@10.8.1",
|
|
7
6
|
"engines": {
|
|
8
7
|
"node": ">=20"
|
|
9
8
|
},
|
|
@@ -41,6 +40,23 @@
|
|
|
41
40
|
"default": "./dist/transports/stdio.js"
|
|
42
41
|
}
|
|
43
42
|
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@modelcontextprotocol/sdk": "^1.25.3",
|
|
45
|
+
"@sentry/node": "10.35.0",
|
|
46
|
+
"@sentry/core": "10.35.0",
|
|
47
|
+
"dotenv": "^16.6.1",
|
|
48
|
+
"zod": "^3.25.67"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@types/node": "^22.19.8",
|
|
52
|
+
"tsdown": "^0.12.9",
|
|
53
|
+
"tsx": "^4.21.0",
|
|
54
|
+
"typescript": "^5.9.3",
|
|
55
|
+
"vitest": "^3.2.4",
|
|
56
|
+
"@sentry/mcp-core": "0.29.0",
|
|
57
|
+
"@sentry/mcp-server-tsconfig": "0.29.0",
|
|
58
|
+
"@sentry/mcp-server-mocks": "0.29.0"
|
|
59
|
+
},
|
|
44
60
|
"scripts": {
|
|
45
61
|
"build": "tsdown",
|
|
46
62
|
"dev": "tsdown --watch",
|
|
@@ -48,22 +64,5 @@
|
|
|
48
64
|
"test": "vitest run",
|
|
49
65
|
"test:watch": "vitest",
|
|
50
66
|
"tsc": "tsc --noEmit"
|
|
51
|
-
},
|
|
52
|
-
"dependencies": {
|
|
53
|
-
"@modelcontextprotocol/sdk": "catalog:",
|
|
54
|
-
"@sentry/node": "catalog:",
|
|
55
|
-
"@sentry/core": "catalog:",
|
|
56
|
-
"dotenv": "catalog:",
|
|
57
|
-
"zod": "catalog:"
|
|
58
|
-
},
|
|
59
|
-
"devDependencies": {
|
|
60
|
-
"@sentry/mcp-core": "workspace:*",
|
|
61
|
-
"@sentry/mcp-server-mocks": "workspace:*",
|
|
62
|
-
"@sentry/mcp-server-tsconfig": "workspace:*",
|
|
63
|
-
"@types/node": "catalog:",
|
|
64
|
-
"tsdown": "catalog:",
|
|
65
|
-
"tsx": "catalog:",
|
|
66
|
-
"typescript": "catalog:",
|
|
67
|
-
"vitest": "catalog:"
|
|
68
67
|
}
|
|
69
|
-
}
|
|
68
|
+
}
|