agents 0.0.0-295f4dd → 0.0.0-29938d4
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/README.md +121 -0
- package/dist/ai-chat-agent.d.ts +142 -17
- package/dist/ai-chat-agent.js +346 -40
- package/dist/ai-chat-agent.js.map +1 -1
- package/dist/ai-chat-v5-migration.js +154 -2
- package/dist/ai-chat-v5-migration.js.map +1 -0
- package/dist/ai-react.d.ts +136 -17
- package/dist/ai-react.js +216 -53
- package/dist/ai-react.js.map +1 -1
- package/dist/{ai-types-D_hTbf25.d.ts → ai-types-0OnT3FHg.d.ts} +26 -2
- package/dist/{ai-types-CwgHzwUb.js → ai-types-DEtF_8Km.js} +5 -1
- package/dist/ai-types-DEtF_8Km.js.map +1 -0
- package/dist/ai-types.d.ts +1 -1
- package/dist/ai-types.js +1 -1
- package/dist/{client-ClORm6f0.d.ts → client-CdM5I962.d.ts} +2 -2
- package/dist/{client-C_M5uPrn.d.ts → client-DFotUKH_.d.ts} +9 -9
- package/dist/{client-CcyhkGfN.js → client-DjTPRM8-.js} +2 -2
- package/dist/{client-CcyhkGfN.js.map → client-DjTPRM8-.js.map} +1 -1
- package/dist/client.d.ts +1 -2
- package/dist/client.js +1 -2
- package/dist/codemode/ai.js +3 -4
- package/dist/codemode/ai.js.map +1 -1
- package/dist/{context-_sPQqJWv.d.ts → context-DcbQ8o7k.d.ts} +1 -1
- package/dist/context.d.ts +1 -1
- package/dist/{do-oauth-client-provider-B-ryFIPr.d.ts → do-oauth-client-provider--To1Tsjj.d.ts} +1 -1
- package/dist/{index-DUnsVDnf.d.ts → index-CT2tCrLr.d.ts} +14 -14
- package/dist/{index-CyDpAVHZ.d.ts → index-DLuxm_9W.d.ts} +2 -2
- package/dist/index.d.ts +4 -7
- package/dist/index.js +2 -3
- package/dist/mcp/client.d.ts +1 -3
- package/dist/mcp/do-oauth-client-provider.d.ts +1 -1
- package/dist/mcp/index.d.ts +18 -12
- package/dist/mcp/index.js +21 -49
- package/dist/mcp/index.js.map +1 -1
- package/dist/{mcp-CzbSsLfc.d.ts → mcp-CPSfGUgd.d.ts} +1 -1
- package/dist/observability/index.d.ts +1 -2
- package/dist/observability/index.js +2 -3
- package/dist/react.d.ts +133 -14
- package/dist/react.js +50 -57
- package/dist/react.js.map +1 -1
- package/dist/schedule.d.ts +18 -72
- package/dist/{serializable-C4GLimgv.d.ts → serializable-Crsj26mx.d.ts} +1 -1
- package/dist/serializable.d.ts +1 -1
- package/dist/{src-BmbDclOA.js → src-BZDh910Z.js} +3 -3
- package/dist/src-BZDh910Z.js.map +1 -0
- package/package.json +28 -13
- package/dist/ai-chat-v5-migration-DguhuLKF.js +0 -155
- package/dist/ai-chat-v5-migration-DguhuLKF.js.map +0 -1
- package/dist/ai-types-CwgHzwUb.js.map +0 -1
- package/dist/react-DIGWa87z.d.ts +0 -137
- package/dist/src-BmbDclOA.js.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { n as AgentEmail } from "./context-
|
|
1
|
+
import { n as AgentEmail } from "./context-DcbQ8o7k.js";
|
|
2
2
|
import {
|
|
3
3
|
h as TransportType,
|
|
4
4
|
t as MCPClientManager,
|
|
5
5
|
u as MCPConnectionState
|
|
6
|
-
} from "./client-
|
|
7
|
-
import { t as Observability } from "./index-
|
|
8
|
-
import { n as MessageType } from "./ai-types-
|
|
6
|
+
} from "./client-DFotUKH_.js";
|
|
7
|
+
import { t as Observability } from "./index-DLuxm_9W.js";
|
|
8
|
+
import { n as MessageType } from "./ai-types-0OnT3FHg.js";
|
|
9
9
|
import {
|
|
10
10
|
Connection,
|
|
11
11
|
Connection as Connection$1,
|
|
@@ -21,7 +21,6 @@ import {
|
|
|
21
21
|
ServerCapabilities,
|
|
22
22
|
Tool
|
|
23
23
|
} from "@modelcontextprotocol/sdk/types.js";
|
|
24
|
-
import { env } from "cloudflare:workers";
|
|
25
24
|
|
|
26
25
|
//#region src/index.d.ts
|
|
27
26
|
|
|
@@ -91,7 +90,7 @@ declare const unstable_callable: (metadata?: CallableMetadata) => void;
|
|
|
91
90
|
type QueueItem<T = string> = {
|
|
92
91
|
id: string;
|
|
93
92
|
payload: T;
|
|
94
|
-
callback: keyof Agent<
|
|
93
|
+
callback: keyof Agent<Cloudflare.Env>;
|
|
95
94
|
created_at: number;
|
|
96
95
|
};
|
|
97
96
|
/**
|
|
@@ -159,7 +158,7 @@ type MCPServer = {
|
|
|
159
158
|
capabilities: ServerCapabilities | null;
|
|
160
159
|
};
|
|
161
160
|
declare function getCurrentAgent<
|
|
162
|
-
T extends Agent<
|
|
161
|
+
T extends Agent<Cloudflare.Env> = Agent<Cloudflare.Env>
|
|
163
162
|
>(): {
|
|
164
163
|
agent: T | undefined;
|
|
165
164
|
connection: Connection | undefined;
|
|
@@ -172,7 +171,7 @@ declare function getCurrentAgent<
|
|
|
172
171
|
* @template State State type to store within the Agent
|
|
173
172
|
*/
|
|
174
173
|
declare class Agent<
|
|
175
|
-
Env =
|
|
174
|
+
Env extends Cloudflare.Env = Cloudflare.Env,
|
|
176
175
|
State = unknown,
|
|
177
176
|
Props extends Record<string, unknown> = Record<string, unknown>
|
|
178
177
|
> extends Server<Env, Props> {
|
|
@@ -417,8 +416,9 @@ declare class Agent<
|
|
|
417
416
|
/**
|
|
418
417
|
* Namespace for creating Agent instances
|
|
419
418
|
* @template Agentic Type of the Agent class
|
|
419
|
+
* @deprecated Use DurableObjectNamespace instead
|
|
420
420
|
*/
|
|
421
|
-
type AgentNamespace<Agentic extends Agent<
|
|
421
|
+
type AgentNamespace<Agentic extends Agent<Cloudflare.Env>> =
|
|
422
422
|
DurableObjectNamespace<Agentic>;
|
|
423
423
|
/**
|
|
424
424
|
* Agent's durable context
|
|
@@ -485,7 +485,7 @@ type EmailRoutingOptions<Env> = AgentOptions<Env> & {
|
|
|
485
485
|
* @param options The options for routing the email
|
|
486
486
|
* @returns A promise that resolves when the email has been routed
|
|
487
487
|
*/
|
|
488
|
-
declare function routeAgentEmail<Env>(
|
|
488
|
+
declare function routeAgentEmail<Env extends Cloudflare.Env = Cloudflare.Env>(
|
|
489
489
|
email: ForwardableEmailMessage,
|
|
490
490
|
env: Env,
|
|
491
491
|
options: EmailRoutingOptions<Env>
|
|
@@ -511,11 +511,11 @@ type EmailSendOptions = {
|
|
|
511
511
|
* @returns Promise resolving to an Agent instance stub
|
|
512
512
|
*/
|
|
513
513
|
declare function getAgentByName<
|
|
514
|
-
Env,
|
|
515
|
-
T extends Agent<Env>,
|
|
514
|
+
Env extends Cloudflare.Env = Cloudflare.Env,
|
|
515
|
+
T extends Agent<Env> = Agent<Env>,
|
|
516
516
|
Props extends Record<string, unknown> = Record<string, unknown>
|
|
517
517
|
>(
|
|
518
|
-
namespace:
|
|
518
|
+
namespace: DurableObjectNamespace<T>,
|
|
519
519
|
name: string,
|
|
520
520
|
options?: {
|
|
521
521
|
jurisdiction?: DurableObjectJurisdiction;
|
|
@@ -574,4 +574,4 @@ export {
|
|
|
574
574
|
callable as x,
|
|
575
575
|
StreamingResponse as y
|
|
576
576
|
};
|
|
577
|
-
//# sourceMappingURL=index-
|
|
577
|
+
//# sourceMappingURL=index-CT2tCrLr.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as BaseEvent, t as MCPObservabilityEvent } from "./mcp-
|
|
1
|
+
import { n as BaseEvent, t as MCPObservabilityEvent } from "./mcp-CPSfGUgd.js";
|
|
2
2
|
|
|
3
3
|
//#region src/observability/agent.d.ts
|
|
4
4
|
|
|
@@ -55,4 +55,4 @@ export {
|
|
|
55
55
|
genericObservability as r,
|
|
56
56
|
Observability as t
|
|
57
57
|
};
|
|
58
|
-
//# sourceMappingURL=index-
|
|
58
|
+
//# sourceMappingURL=index-DLuxm_9W.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { n as AgentEmail } from "./context-
|
|
2
|
-
import { h as TransportType } from "./client-
|
|
3
|
-
import "./
|
|
4
|
-
import "./do-oauth-client-provider-B-ryFIPr.js";
|
|
5
|
-
import "./index-CyDpAVHZ.js";
|
|
6
|
-
import "./ai-types-D_hTbf25.js";
|
|
1
|
+
import { n as AgentEmail } from "./context-DcbQ8o7k.js";
|
|
2
|
+
import { h as TransportType } from "./client-DFotUKH_.js";
|
|
3
|
+
import "./ai-types-0OnT3FHg.js";
|
|
7
4
|
import {
|
|
8
5
|
C as createCatchAllEmailResolver,
|
|
9
6
|
D as routeAgentEmail,
|
|
@@ -34,7 +31,7 @@ import {
|
|
|
34
31
|
w as createHeaderBasedEmailResolver,
|
|
35
32
|
x as callable,
|
|
36
33
|
y as StreamingResponse
|
|
37
|
-
} from "./index-
|
|
34
|
+
} from "./index-CT2tCrLr.js";
|
|
38
35
|
export {
|
|
39
36
|
Agent,
|
|
40
37
|
AgentContext,
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import "./context-BkKbAa1R.js";
|
|
2
|
-
import "./
|
|
3
|
-
import "./client-CcyhkGfN.js";
|
|
2
|
+
import "./client-DjTPRM8-.js";
|
|
4
3
|
import "./client-QZa2Rq0l.js";
|
|
5
4
|
import "./do-oauth-client-provider-B1fVIshX.js";
|
|
6
|
-
import { a as createCatchAllEmailResolver, c as getCurrentAgent, d as unstable_callable, i as createAddressBasedEmailResolver, l as routeAgentEmail, n as StreamingResponse, o as createHeaderBasedEmailResolver, r as callable, s as getAgentByName, t as Agent, u as routeAgentRequest } from "./src-
|
|
5
|
+
import { a as createCatchAllEmailResolver, c as getCurrentAgent, d as unstable_callable, i as createAddressBasedEmailResolver, l as routeAgentEmail, n as StreamingResponse, o as createHeaderBasedEmailResolver, r as callable, s as getAgentByName, t as Agent, u as routeAgentRequest } from "./src-BZDh910Z.js";
|
|
7
6
|
|
|
8
7
|
export { Agent, StreamingResponse, callable, createAddressBasedEmailResolver, createCatchAllEmailResolver, createHeaderBasedEmailResolver, getAgentByName, getCurrentAgent, routeAgentEmail, routeAgentRequest, unstable_callable };
|
package/dist/mcp/client.d.ts
CHANGED
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
import { a as MCPConnectionResult, c as RegisterServerOptions, i as MCPClientOAuthResult, l as getNamespacedData, n as MCPClientManagerOptions, o as MCPDiscoverResult, r as MCPClientOAuthCallbackConfig, s as MCPServerOptions, t as MCPClientManager } from "../client-
|
|
2
|
-
import "../mcp-CzbSsLfc.js";
|
|
3
|
-
import "../do-oauth-client-provider-B-ryFIPr.js";
|
|
1
|
+
import { a as MCPConnectionResult, c as RegisterServerOptions, i as MCPClientOAuthResult, l as getNamespacedData, n as MCPClientManagerOptions, o as MCPDiscoverResult, r as MCPClientOAuthCallbackConfig, s as MCPServerOptions, t as MCPClientManager } from "../client-DFotUKH_.js";
|
|
4
2
|
export { MCPClientManager, MCPClientManagerOptions, MCPClientOAuthCallbackConfig, MCPClientOAuthResult, MCPConnectionResult, MCPDiscoverResult, MCPServerOptions, RegisterServerOptions, getNamespacedData };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as DurableObjectOAuthClientProvider, t as AgentsOAuthProvider } from "../do-oauth-client-provider
|
|
1
|
+
import { n as DurableObjectOAuthClientProvider, t as AgentsOAuthProvider } from "../do-oauth-client-provider--To1Tsjj.js";
|
|
2
2
|
export { AgentsOAuthProvider, DurableObjectOAuthClientProvider };
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import "../context-
|
|
2
|
-
import { a as MCPConnectionResult, d as BaseTransportType, f as CORSOptions, i as MCPClientOAuthResult, m as ServeOptions, o as MCPDiscoverResult, p as MaybePromise, r as MCPClientOAuthCallbackConfig, s as MCPServerOptions } from "../client-
|
|
3
|
-
import "../
|
|
4
|
-
import "../
|
|
5
|
-
import "../index-CyDpAVHZ.js";
|
|
6
|
-
import "../ai-types-D_hTbf25.js";
|
|
7
|
-
import { o as Connection, s as ConnectionContext, t as Agent } from "../index-DUnsVDnf.js";
|
|
1
|
+
import "../context-DcbQ8o7k.js";
|
|
2
|
+
import { a as MCPConnectionResult, d as BaseTransportType, f as CORSOptions, i as MCPClientOAuthResult, m as ServeOptions, o as MCPDiscoverResult, p as MaybePromise, r as MCPClientOAuthCallbackConfig, s as MCPServerOptions } from "../client-DFotUKH_.js";
|
|
3
|
+
import "../ai-types-0OnT3FHg.js";
|
|
4
|
+
import { o as Connection, s as ConnectionContext, t as Agent } from "../index-CT2tCrLr.js";
|
|
8
5
|
import { SSEClientTransport, SSEClientTransportOptions } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
9
6
|
import { StreamableHTTPClientTransport, StreamableHTTPClientTransportOptions } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
10
7
|
import { ElicitRequest, ElicitRequestSchema, ElicitResult, ElicitResult as ElicitResult$1, JSONRPCMessage, MessageExtraInfo } from "@modelcontextprotocol/sdk/types.js";
|
|
@@ -27,8 +24,6 @@ declare class StreamableHTTPEdgeClientTransport extends StreamableHTTPClientTran
|
|
|
27
24
|
}
|
|
28
25
|
//#endregion
|
|
29
26
|
//#region src/mcp/worker-transport.d.ts
|
|
30
|
-
declare const SUPPORTED_PROTOCOL_VERSIONS: readonly ["2025-03-26", "2025-06-18"];
|
|
31
|
-
type ProtocolVersion = (typeof SUPPORTED_PROTOCOL_VERSIONS)[number];
|
|
32
27
|
interface MCPStorageApi {
|
|
33
28
|
get(): Promise<TransportState | undefined> | TransportState | undefined;
|
|
34
29
|
set(state: TransportState): Promise<void> | void;
|
|
@@ -36,7 +31,6 @@ interface MCPStorageApi {
|
|
|
36
31
|
interface TransportState {
|
|
37
32
|
sessionId?: string;
|
|
38
33
|
initialized: boolean;
|
|
39
|
-
protocolVersion?: ProtocolVersion;
|
|
40
34
|
}
|
|
41
35
|
interface WorkerTransportOptions {
|
|
42
36
|
sessionIdGenerator?: () => string;
|
|
@@ -64,7 +58,6 @@ declare class WorkerTransport implements Transport {
|
|
|
64
58
|
private requestToStreamMapping;
|
|
65
59
|
private requestResponseMap;
|
|
66
60
|
private corsOptions?;
|
|
67
|
-
private protocolVersion?;
|
|
68
61
|
private storage?;
|
|
69
62
|
private stateRestored;
|
|
70
63
|
sessionId?: string;
|
|
@@ -82,6 +75,19 @@ declare class WorkerTransport implements Transport {
|
|
|
82
75
|
*/
|
|
83
76
|
private saveState;
|
|
84
77
|
start(): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Validates the MCP-Protocol-Version header on incoming requests.
|
|
80
|
+
*
|
|
81
|
+
* This performs a simple check: if a version header is present, it must be
|
|
82
|
+
* in the SUPPORTED_PROTOCOL_VERSIONS list. We do not track the negotiated
|
|
83
|
+
* version or enforce version consistency across requests - the SDK handles
|
|
84
|
+
* version negotiation during initialization, and we simply reject any
|
|
85
|
+
* explicitly unsupported versions.
|
|
86
|
+
*
|
|
87
|
+
* - Header present and supported: Accept
|
|
88
|
+
* - Header present and unsupported: 400 Bad Request
|
|
89
|
+
* - Header missing: Accept (version validation is optional)
|
|
90
|
+
*/
|
|
85
91
|
private validateProtocolVersion;
|
|
86
92
|
private getHeaders;
|
|
87
93
|
handleRequest(request: Request, parsedBody?: unknown): Promise<Response>;
|
|
@@ -127,7 +133,7 @@ declare function createMcpHandler(server: McpServer | Server, options?: CreateMc
|
|
|
127
133
|
declare function experimental_createMcpHandler(server: McpServer | Server, options?: CreateMcpHandlerOptions): (request: Request, env: unknown, ctx: ExecutionContext) => Promise<Response>;
|
|
128
134
|
//#endregion
|
|
129
135
|
//#region src/mcp/index.d.ts
|
|
130
|
-
declare abstract class McpAgent<Env =
|
|
136
|
+
declare abstract class McpAgent<Env extends Cloudflare.Env = Cloudflare.Env, State = unknown, Props extends Record<string, unknown> = Record<string, unknown>> extends Agent<Env, State, Props> {
|
|
131
137
|
private _transport?;
|
|
132
138
|
props?: Props;
|
|
133
139
|
abstract server: MaybePromise<McpServer | Server>;
|
package/dist/mcp/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import "../context-BkKbAa1R.js";
|
|
2
|
-
import { t as MessageType } from "../ai-types-
|
|
3
|
-
import "../client-
|
|
2
|
+
import { t as MessageType } from "../ai-types-DEtF_8Km.js";
|
|
3
|
+
import "../client-DjTPRM8-.js";
|
|
4
4
|
import "../client-QZa2Rq0l.js";
|
|
5
5
|
import "../do-oauth-client-provider-B1fVIshX.js";
|
|
6
|
-
import { c as getCurrentAgent, s as getAgentByName, t as Agent } from "../src-
|
|
6
|
+
import { c as getCurrentAgent, s as getAgentByName, t as Agent } from "../src-BZDh910Z.js";
|
|
7
7
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
8
8
|
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
9
9
|
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
10
|
-
import { ElicitRequestSchema, InitializeRequestSchema, JSONRPCMessageSchema, isInitializeRequest, isJSONRPCError, isJSONRPCNotification, isJSONRPCRequest, isJSONRPCResponse } from "@modelcontextprotocol/sdk/types.js";
|
|
10
|
+
import { ElicitRequestSchema, InitializeRequestSchema, JSONRPCMessageSchema, SUPPORTED_PROTOCOL_VERSIONS, isInitializeRequest, isJSONRPCError, isJSONRPCNotification, isJSONRPCRequest, isJSONRPCResponse } from "@modelcontextprotocol/sdk/types.js";
|
|
11
11
|
|
|
12
12
|
//#region src/mcp/utils.ts
|
|
13
13
|
/**
|
|
@@ -694,8 +694,6 @@ var StreamableHTTPEdgeClientTransport = class extends StreamableHTTPClientTransp
|
|
|
694
694
|
|
|
695
695
|
//#endregion
|
|
696
696
|
//#region src/mcp/worker-transport.ts
|
|
697
|
-
const SUPPORTED_PROTOCOL_VERSIONS = ["2025-03-26", "2025-06-18"];
|
|
698
|
-
const DEFAULT_PROTOCOL_VERSION = "2025-03-26";
|
|
699
697
|
const MCP_PROTOCOL_VERSION_HEADER = "MCP-Protocol-Version";
|
|
700
698
|
var WorkerTransport = class {
|
|
701
699
|
constructor(options) {
|
|
@@ -723,7 +721,6 @@ var WorkerTransport = class {
|
|
|
723
721
|
if (state) {
|
|
724
722
|
this.sessionId = state.sessionId;
|
|
725
723
|
this.initialized = state.initialized;
|
|
726
|
-
this.protocolVersion = state.protocolVersion;
|
|
727
724
|
}
|
|
728
725
|
this.stateRestored = true;
|
|
729
726
|
}
|
|
@@ -734,8 +731,7 @@ var WorkerTransport = class {
|
|
|
734
731
|
if (!this.storage) return;
|
|
735
732
|
const state = {
|
|
736
733
|
sessionId: this.sessionId,
|
|
737
|
-
initialized: this.initialized
|
|
738
|
-
protocolVersion: this.protocolVersion
|
|
734
|
+
initialized: this.initialized
|
|
739
735
|
};
|
|
740
736
|
await Promise.resolve(this.storage.set(state));
|
|
741
737
|
}
|
|
@@ -743,44 +739,26 @@ var WorkerTransport = class {
|
|
|
743
739
|
if (this.started) throw new Error("Transport already started");
|
|
744
740
|
this.started = true;
|
|
745
741
|
}
|
|
742
|
+
/**
|
|
743
|
+
* Validates the MCP-Protocol-Version header on incoming requests.
|
|
744
|
+
*
|
|
745
|
+
* This performs a simple check: if a version header is present, it must be
|
|
746
|
+
* in the SUPPORTED_PROTOCOL_VERSIONS list. We do not track the negotiated
|
|
747
|
+
* version or enforce version consistency across requests - the SDK handles
|
|
748
|
+
* version negotiation during initialization, and we simply reject any
|
|
749
|
+
* explicitly unsupported versions.
|
|
750
|
+
*
|
|
751
|
+
* - Header present and supported: Accept
|
|
752
|
+
* - Header present and unsupported: 400 Bad Request
|
|
753
|
+
* - Header missing: Accept (version validation is optional)
|
|
754
|
+
*/
|
|
746
755
|
validateProtocolVersion(request) {
|
|
747
|
-
const
|
|
748
|
-
if (!
|
|
749
|
-
if (!this.protocolVersion || this.protocolVersion === DEFAULT_PROTOCOL_VERSION) return;
|
|
750
|
-
return new Response(JSON.stringify({
|
|
751
|
-
jsonrpc: "2.0",
|
|
752
|
-
error: {
|
|
753
|
-
code: -32e3,
|
|
754
|
-
message: `Bad Request: ${MCP_PROTOCOL_VERSION_HEADER} header is required`
|
|
755
|
-
},
|
|
756
|
-
id: null
|
|
757
|
-
}), {
|
|
758
|
-
status: 400,
|
|
759
|
-
headers: {
|
|
760
|
-
"Content-Type": "application/json",
|
|
761
|
-
...this.getHeaders()
|
|
762
|
-
}
|
|
763
|
-
});
|
|
764
|
-
}
|
|
765
|
-
if (!SUPPORTED_PROTOCOL_VERSIONS.includes(versionHeader)) return new Response(JSON.stringify({
|
|
766
|
-
jsonrpc: "2.0",
|
|
767
|
-
error: {
|
|
768
|
-
code: -32e3,
|
|
769
|
-
message: `Bad Request: Unsupported ${MCP_PROTOCOL_VERSION_HEADER}: ${versionHeader}. Supported versions: ${SUPPORTED_PROTOCOL_VERSIONS.join(", ")}`
|
|
770
|
-
},
|
|
771
|
-
id: null
|
|
772
|
-
}), {
|
|
773
|
-
status: 400,
|
|
774
|
-
headers: {
|
|
775
|
-
"Content-Type": "application/json",
|
|
776
|
-
...this.getHeaders()
|
|
777
|
-
}
|
|
778
|
-
});
|
|
779
|
-
if (this.protocolVersion && versionHeader !== this.protocolVersion) return new Response(JSON.stringify({
|
|
756
|
+
const protocolVersion = request.headers.get(MCP_PROTOCOL_VERSION_HEADER);
|
|
757
|
+
if (protocolVersion !== null && !SUPPORTED_PROTOCOL_VERSIONS.includes(protocolVersion)) return new Response(JSON.stringify({
|
|
780
758
|
jsonrpc: "2.0",
|
|
781
759
|
error: {
|
|
782
760
|
code: -32e3,
|
|
783
|
-
message: `Bad Request:
|
|
761
|
+
message: `Bad Request: Unsupported protocol version: ${protocolVersion} (supported versions: ${SUPPORTED_PROTOCOL_VERSIONS.join(", ")})`
|
|
784
762
|
},
|
|
785
763
|
id: null
|
|
786
764
|
}), {
|
|
@@ -983,12 +961,6 @@ var WorkerTransport = class {
|
|
|
983
961
|
...this.getHeaders()
|
|
984
962
|
}
|
|
985
963
|
});
|
|
986
|
-
const initRequest = messages.find(isInitializeRequest);
|
|
987
|
-
if (initRequest?.params) {
|
|
988
|
-
const version = initRequest.params.protocolVersion;
|
|
989
|
-
if (version && SUPPORTED_PROTOCOL_VERSIONS.includes(version)) this.protocolVersion = version;
|
|
990
|
-
else this.protocolVersion = DEFAULT_PROTOCOL_VERSION;
|
|
991
|
-
}
|
|
992
964
|
this.sessionId = this.sessionIdGenerator?.();
|
|
993
965
|
this.initialized = true;
|
|
994
966
|
await this.saveState();
|