Skip to content

⭐️⭐️⭐️ Open-source, self-hosted alternative to Linear and Plane. Project management and issue tracking where teams and AI agents work side by side to plan and ship products.

fix(api): the MCP endpoint answers 405 to GET and DELETE instead of 404 (#610)

Croffdb96dc39f551
diff --git a/apps/api/src/app.ts b/apps/api/src/app.ts
index f48ae596..06c54119 100644
--- a/apps/api/src/app.ts
+++ b/apps/api/src/app.ts
@@ -322,7 +322,7 @@ export const app = new Elysia()
// Planner API: projects, issues, and their dependent entities.
.use(planner);
-// MCP endpoint (POST /mcp). Added after the chain so `type App` (the Eden client
+// MCP endpoint (/mcp). Added after the chain so `type App` (the Eden client
// type) stays the REST surface; the MCP endpoint is JSON-RPC, not called via Eden.
// Its tools are generated from the routes tagged with mcpTool().
mountMcp(app);
diff --git a/apps/api/src/mcp/__tests__/integration/mcp-auth.test.ts b/apps/api/src/mcp/__tests__/integration/mcp-auth.test.ts
index bff0c33d..81d17c04 100644
--- a/apps/api/src/mcp/__tests__/integration/mcp-auth.test.ts
+++ b/apps/api/src/mcp/__tests__/integration/mcp-auth.test.ts
@@ -46,6 +46,17 @@ describe('MCP authentication', () => {
expect(res.status).toBe(401);
});
+ it('answers GET and DELETE with 405', async () => {
+ for (const method of ['GET', 'DELETE']) {
+ const res = await app.handle(
+ new Request('http://localhost/mcp', { method, headers: { accept: 'text/event-stream' } }),
+ );
+
+ expect(res.status).toBe(405);
+ expect(res.headers.get('allow')).toBe('POST');
+ }
+ });
+
it('refuses a key whose account was deactivated over SCIM', async () => {
const { scim } = await setupScim();
const member = await signUpTestUser({ email: '[email protected]' });
diff --git a/apps/api/src/mcp/mount.ts b/apps/api/src/mcp/mount.ts
index 8a50af08..e78c9ee0 100644
--- a/apps/api/src/mcp/mount.ts
+++ b/apps/api/src/mcp/mount.ts
@@ -12,7 +12,7 @@ function extractApiKey(request: Request): string | null {
return bearer ?? request.headers.get('x-api-key') ?? null;
}
-// Adds the MCP endpoint (POST /mcp) to the app and returns the same app. Mounted on
+// Adds the MCP endpoint (/mcp) to the app. Mounted on
// the root app, outside the planner session guard, because the MCP handshake is not
// a planner route: auth is resolved here and the key is forwarded to the loopback
// requests the tools make. `app` is captured so the tool generator can read
@@ -21,8 +21,8 @@ function extractApiKey(request: Request): string | null {
// Stateless transport (sessionIdGenerator undefined): a fresh server and transport
// per request. Personal API keys remain supported for existing integrations; native
// OAuth is the default route for clients that discover this resource, such as ChatGPT.
-// Typed as `any` because it is the composition root: it needs Elysia's `.post` to
-// register the route, and Elysia's generics are invariant, so a precise parameter
+// Typed as `any` because it is the composition root: it needs Elysia's route methods to
+// register the routes, and Elysia's generics are invariant, so a precise parameter
// type would reject the concrete app. The captured `app` is passed on as McpApp.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function mountMcp(app: any): void {
@@ -65,4 +65,15 @@ export function mountMcp(app: any): void {
detail: { summary: 'MCP Streamable HTTP endpoint', hide: true },
},
);
+ // The spec allows only an SSE stream or 405 on GET. A stateless server has no stream to
+ // offer and no session to end, and a client that gets 404 instead drops the connection.
+ app.get('/mcp', methodNotAllowed, { detail: { hide: true } });
+ app.delete('/mcp', methodNotAllowed, { detail: { hide: true } });
+}
+
+function methodNotAllowed(): Response {
+ return Response.json(
+ { jsonrpc: '2.0', error: { code: -32000, message: 'Method not allowed.' }, id: null },
+ { status: 405, headers: { allow: 'POST' } },
+ );
}