From a03f1529adc103421be8a3597b85e5eca1764608 Mon Sep 17 00:00:00 2001 From: Claude Lin & Lay Date: Thu, 23 Apr 2026 23:45:14 +0900 Subject: [PATCH] fix(mcp): retain RagMcpAgent as stub to satisfy migration history Post-merge deploy of #109 failed with: New version of script does not export class 'RagMcpAgent' which is depended on by existing Durable Objects. [code: 10064] The v1 migration still declares RagMcpAgent as an sqlite class, and Cloudflare requires every declared class to exist in the script (or be removed via a deleted_classes migration). Since the goal of the rename was to reach a fresh DO namespace for RagMcpAgentV2, a renamed_classes migration would defeat that by preserving state. Instead, keep RagMcpAgent as an empty DurableObject stub that receives no traffic (no binding points to it). Follow-up work: delete RagMcpAgent entirely via deleted_classes once the V2 switch is confirmed stable. Closes #111 Refs #109 --- src/index.ts | 3 +++ src/mcp.ts | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/index.ts b/src/index.ts index 394ca43..117bb0f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -38,6 +38,9 @@ import { RagMcpAgentV2 } from "./mcp.js"; // Durable Object: issue/PR state store (SQLite-backed) export { IssueStore } from "./store.js"; +// Durable Object: MCP server — legacy stub (retained for migration compatibility only). +export { RagMcpAgent } from "./mcp.js"; + // Durable Object: MCP server (tools: search_issues, get_issue_context, list_recent_activity) export { RagMcpAgentV2 } from "./mcp.js"; diff --git a/src/mcp.ts b/src/mcp.ts index 19ecd7b..7d382d0 100644 --- a/src/mcp.ts +++ b/src/mcp.ts @@ -12,6 +12,7 @@ * idFromName("user-{githubUserId}"). */ +import { DurableObject } from "cloudflare:workers"; import { McpAgent } from "agents/mcp"; import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { z } from "zod"; @@ -65,6 +66,20 @@ function githubHeaders(token: string): Record { */ const INCLUDE_CONTENT_MAX_DOCS = 5; +/** + * Legacy class retained solely to satisfy Cloudflare's "class must exist in + * script for classes declared in past migrations (v1 new_sqlite_classes)" + * constraint. MCP_OBJECT binding points to RagMcpAgentV2 now, so this class + * never receives live traffic. It exists only so `wrangler deploy` does not + * fail with "script does not export class 'RagMcpAgent'". A follow-up PR can + * delete this class together with a deleted_classes migration. + */ +export class RagMcpAgent extends DurableObject { + async fetch(): Promise { + return new Response("RagMcpAgent has been retired; use RagMcpAgentV2", { status: 410 }); + } +} + export class RagMcpAgentV2 extends McpAgent { // @ts-expect-error -- McpServer version mismatch between top-level SDK and agents' bundled copy (same issue as webhook-mcp; wrangler resolves at bundle time) server = new McpServer({