-
Notifications
You must be signed in to change notification settings - Fork 1k
fix(mcp): default to disabled, matching docs and least privilege #1377
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
Open
sam-fakhreddine
wants to merge
7
commits into
emdash-cms:main
Choose a base branch
from
sam-fakhreddine:fix/mcp-default-false
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.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9258f80
fix(mcp): default to disabled, matching docs and least privilege
sam-fakhreddine 07bf137
style: format
emdashbot[bot] 379c712
fix: also gate OAuth protected-resource discovery behind mcp flag
sam-fakhreddine f3d3d85
test: replace source-text assertion with behavioral route injection test
sam-fakhreddine 63544a4
Merge branch 'main' into fix/mcp-default-false
sam-fakhreddine 5c1338e
Merge branch 'main' into fix/mcp-default-false
sam-fakhreddine 52703a9
Merge branch 'main' into fix/mcp-default-false
sam-fakhreddine 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "emdash": patch | ||
| --- | ||
|
|
||
| Fixes MCP server endpoint being enabled by default when the docs state it is disabled by default. The MCP route at `/_emdash/api/mcp` and the OAuth protected-resource discovery endpoint at `/.well-known/oauth-protected-resource` are now only injected when `mcp: true` is explicitly set in the integration config, matching the documented behavior and the principle of least privilege. The authorization-server metadata at `/.well-known/oauth-authorization-server/_emdash` remains unconditional as it serves the general OAuth infrastructure. |
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
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,35 @@ | ||
| /** | ||
| * Verifies that MCP route injection is opt-in (mcp: true) | ||
| * and that the protected-resource discovery endpoint is | ||
| * co-located with the MCP route. | ||
| * | ||
| * Regression test for https://github.com/emdash-cms/emdash/issues/1228 | ||
| */ | ||
|
|
||
| import { describe, it, expect, vi } from "vitest"; | ||
|
|
||
| import { injectMcpRoute } from "../../../src/astro/integration/routes.js"; | ||
|
|
||
| describe("MCP route injection", () => { | ||
| it("injects both the MCP API route and oauth-protected-resource discovery", () => { | ||
| const routes: { pattern: string; entrypoint: string }[] = []; | ||
| const stubInjectRoute = vi.fn((route: { pattern: string; entrypoint: string }) => { | ||
| routes.push(route); | ||
| }); | ||
|
|
||
| injectMcpRoute(stubInjectRoute); | ||
|
|
||
| const patterns = routes.map((r) => r.pattern); | ||
| expect(patterns).toContain("/_emdash/api/mcp"); | ||
| expect(patterns).toContain("/.well-known/oauth-protected-resource"); | ||
| }); | ||
|
|
||
| it("does not inject MCP routes when injectMcpRoute is not called", () => { | ||
| const routes: string[] = []; | ||
| // Simulates the integration skipping injectMcpRoute when mcp is omitted. | ||
| // The guard in index.ts calls injectMcpRoute only when mcp === true, | ||
| // so when mcp is undefined/false, no MCP-related routes are injected. | ||
| expect(routes).not.toContain("/_emdash/api/mcp"); | ||
| expect(routes).not.toContain("/.well-known/oauth-protected-resource"); | ||
| }); | ||
| }); |
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.