Repository navigation
feat(cli): add local MCP server command #1401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
MathurAditya724
wants to merge
10
commits into
main
Choose a base branch
from
codex/cli-mcp-auth
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+866
−28
Draft
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
463da16
feat(cli): Add local MCP server command
MathurAditya724 4d105a3
fix(cli): Resolve MCP lint errors
MathurAditya724 63cf965
fix(cli): Address MCP startup edge cases
MathurAditya724 ef22986
fix(cli): Keep MCP server running
MathurAditya724 964c35c
Merge origin/main into codex/cli-mcp-auth
MathurAditya724 3b48558
fix(cli): Build bundle before E2E tests
MathurAditya724 08e6ab9
fix(cli): Auto-login and refresh tokens for sentry mcp
MathurAditya724 ab5c8d2
test(cli): Lock in MCP startup and host-translation edge cases
MathurAditya724 9ed76d3
Merge origin/main into codex/cli-mcp-auth
MathurAditya724 4d4e0fc
fix(cli): Format MCP files with oxfmt and sync skill version
MathurAditya724 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
|
|
||
| `sentry mcp` starts the local stdio Sentry MCP server using the active Sentry CLI session. Authenticate once with `sentry auth login`; no separate MCP login or token cache is required. | ||
|
|
||
| ## Configure an MCP client | ||
|
|
||
| Point your MCP client at the installed Sentry CLI: | ||
|
|
||
| ```json | ||
| { | ||
| "mcpServers": { | ||
| "sentry": { | ||
| "command": "sentry", | ||
| "args": ["mcp"] | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| For a self-hosted instance, first authenticate the CLI against that host. You can also override the target for this MCP server invocation: | ||
|
|
||
| ```json | ||
| { | ||
| "mcpServers": { | ||
| "sentry": { | ||
| "command": "sentry", | ||
| "args": ["mcp", "--host=sentry.example.com"] | ||
| } | ||
| } | ||
| } | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
packages/cli/plugins/sentry-cli/skills/sentry-cli/references/mcp.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| --- | ||
| name: sentry-cli-mcp | ||
| version: 0.48.0-dev.0 | ||
| description: Start a local Sentry MCP server | ||
| requires: | ||
| bins: ["sentry"] | ||
| auth: true | ||
| --- | ||
|
|
||
| # Mcp Commands | ||
|
|
||
| Start a local Sentry MCP server | ||
|
|
||
| ### `sentry mcp` | ||
|
|
||
| Start a local Sentry MCP server | ||
|
|
||
| All commands also support `--json`, `--fields`, `--help`, `--log-level`, and `--verbose` flags. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { spawn } from "node:child_process"; | ||
|
|
||
| const pnpm = process.platform === "win32" ? "pnpm.cmd" : "pnpm"; | ||
| const child = spawn(pnpm, ["run", "bundle"], { | ||
| env: { | ||
| ...process.env, | ||
| SENTRY_CLIENT_ID: process.env.SENTRY_CLIENT_ID ?? "test-client-id", | ||
| }, | ||
| stdio: "inherit", | ||
| }); | ||
|
Check notice on line 10 in packages/cli/script/prepare-e2e-bundle.ts
|
||
|
|
||
| const exitCode = await new Promise<number>((resolve, reject) => { | ||
| child.once("error", reject); | ||
| child.once("close", (code) => resolve(code ?? 1)); | ||
| }); | ||
|
|
||
| if (exitCode !== 0) { | ||
| process.exitCode = exitCode; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import type { SentryContext } from "../context.js"; | ||
| import { buildCommand } from "../lib/command.js"; | ||
| import { CommandOutput } from "../lib/formatters/output.js"; | ||
|
|
||
| /** Documentation route for the stdio handoff in {@link runCli}. */ | ||
| export const mcpCommand = buildCommand({ | ||
| auth: false, | ||
| docs: { | ||
| brief: "Start a local Sentry MCP server", | ||
| fullDescription: | ||
| "Start the local stdio MCP server using the current Sentry CLI session. " + | ||
| "Configure an MCP client with `sentry mcp`; authenticate first with `sentry auth login`.", | ||
| }, | ||
| output: { human: (message: string) => message }, | ||
| parameters: {}, | ||
| // biome-ignore lint/suspicious/useAwait: async generator required by buildCommand | ||
| async *func(this: SentryContext) { | ||
| yield new CommandOutput( | ||
| "The local MCP server is started by running `sentry mcp` from an MCP client configuration.", | ||
| ); | ||
| }, | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.