agents 0.0.0-c3e8618 → 0.0.0-c4c9271

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.
Files changed (43) hide show
  1. package/dist/ai-chat-agent.d.ts +73 -23
  2. package/dist/ai-chat-agent.js +230 -0
  3. package/dist/ai-chat-agent.js.map +1 -0
  4. package/dist/ai-react.d.ts +85 -44
  5. package/dist/ai-react.js +203 -0
  6. package/dist/ai-react.js.map +1 -0
  7. package/dist/ai-types.d.ts +65 -40
  8. package/dist/ai-types.js +1 -0
  9. package/dist/ai-types.js.map +1 -0
  10. package/dist/chunk-6RPGDIE2.js +786 -0
  11. package/dist/chunk-6RPGDIE2.js.map +1 -0
  12. package/dist/chunk-BZXOAZUX.js +106 -0
  13. package/dist/chunk-BZXOAZUX.js.map +1 -0
  14. package/dist/chunk-OYJXQRRH.js +465 -0
  15. package/dist/chunk-OYJXQRRH.js.map +1 -0
  16. package/dist/chunk-VCSB47AK.js +116 -0
  17. package/dist/chunk-VCSB47AK.js.map +1 -0
  18. package/dist/client.d.ts +71 -37
  19. package/dist/client.js +11 -0
  20. package/dist/client.js.map +1 -0
  21. package/dist/index.d.ts +331 -179
  22. package/dist/index.js +22 -0
  23. package/dist/index.js.map +1 -0
  24. package/dist/mcp/client.d.ts +142 -34
  25. package/dist/mcp/client.js +9 -0
  26. package/dist/mcp/client.js.map +1 -0
  27. package/dist/mcp/do-oauth-client-provider.d.ts +41 -0
  28. package/dist/mcp/do-oauth-client-provider.js +7 -0
  29. package/dist/mcp/do-oauth-client-provider.js.map +1 -0
  30. package/dist/mcp/index.d.ts +50 -7
  31. package/dist/mcp/index.js +782 -0
  32. package/dist/mcp/index.js.map +1 -0
  33. package/dist/react.d.ts +104 -15
  34. package/dist/react.js +116 -0
  35. package/dist/react.js.map +1 -0
  36. package/dist/schedule.d.ts +30 -20
  37. package/dist/schedule.js +71 -0
  38. package/dist/schedule.js.map +1 -0
  39. package/dist/serializable.d.ts +32 -0
  40. package/dist/serializable.js +1 -0
  41. package/dist/serializable.js.map +1 -0
  42. package/package.json +28 -5
  43. package/src/index.ts +396 -60
@@ -1,32 +1,48 @@
1
1
  import * as zod from 'zod';
2
- import { Tool, Prompt as Prompt$1, Resource, ResourceTemplate, ServerCapabilities, ClientCapabilities, CallToolRequest, CallToolResultSchema, CompatibilityCallToolResultSchema, ReadResourceRequest, GetPromptRequest } from '@modelcontextprotocol/sdk/types.js';
2
+ import { Tool, Prompt, Resource, ResourceTemplate, ServerCapabilities, CallToolRequest, CallToolResultSchema, CompatibilityCallToolResultSchema, ReadResourceRequest, GetPromptRequest } from '@modelcontextprotocol/sdk/types.js';
3
3
  import { Client } from '@modelcontextprotocol/sdk/client/index.js';
4
- import { SSEClientTransport, SSEClientTransportOptions } from '@modelcontextprotocol/sdk/client/sse.js';
4
+ import { SSEClientTransportOptions } from '@modelcontextprotocol/sdk/client/sse.js';
5
+ import { AgentsOAuthProvider } from './do-oauth-client-provider.js';
5
6
  import { RequestOptions } from '@modelcontextprotocol/sdk/shared/protocol.js';
7
+ import { ToolSet } from 'ai';
8
+ import '@modelcontextprotocol/sdk/client/auth.js';
9
+ import '@modelcontextprotocol/sdk/shared/auth.js';
6
10
 
7
11
  declare class MCPClientConnection {
8
- private info;
12
+ url: URL;
13
+ options: {
14
+ transport: SSEClientTransportOptions & {
15
+ authProvider?: AgentsOAuthProvider;
16
+ };
17
+ client: ConstructorParameters<typeof Client>[1];
18
+ };
9
19
  client: Client;
10
- transport: SSEClientTransport;
11
- connected: boolean;
20
+ connectionState: "authenticating" | "connecting" | "ready" | "discovering" | "failed";
12
21
  instructions?: string;
13
22
  tools: Tool[];
14
- prompts: Prompt$1[];
23
+ prompts: Prompt[];
15
24
  resources: Resource[];
16
25
  resourceTemplates: ResourceTemplate[];
17
26
  serverCapabilities: ServerCapabilities | undefined;
18
- constructor(url: URL, info: ConstructorParameters<typeof Client>[0], opts?: {
19
- transport: SSEClientTransportOptions;
27
+ constructor(url: URL, info: ConstructorParameters<typeof Client>[0], options?: {
28
+ transport: SSEClientTransportOptions & {
29
+ authProvider?: AgentsOAuthProvider;
30
+ };
20
31
  client: ConstructorParameters<typeof Client>[1];
21
- capabilities: ClientCapabilities;
22
32
  });
23
- init(): Promise<void>;
33
+ /**
34
+ * Initialize a client connection
35
+ *
36
+ * @param code Optional OAuth code to initialize the connection with if auth hasn't been initialized
37
+ * @returns
38
+ */
39
+ init(code?: string): Promise<void>;
24
40
  /**
25
41
  * Notification handler registration
26
42
  */
27
43
  registerTools(): Promise<Tool[]>;
28
44
  registerResources(): Promise<Resource[]>;
29
- registerPrompts(): Promise<Prompt$1[]>;
45
+ registerPrompts(): Promise<Prompt[]>;
30
46
  registerResourceTemplates(): Promise<ResourceTemplate[]>;
31
47
  fetchTools(): Promise<{
32
48
  [x: string]: unknown;
@@ -39,6 +55,14 @@ declare class MCPClientConnection {
39
55
  } | undefined;
40
56
  };
41
57
  description?: string | undefined;
58
+ annotations?: {
59
+ [x: string]: unknown;
60
+ title?: string | undefined;
61
+ readOnlyHint?: boolean | undefined;
62
+ destructiveHint?: boolean | undefined;
63
+ idempotentHint?: boolean | undefined;
64
+ openWorldHint?: boolean | undefined;
65
+ } | undefined;
42
66
  }[]>;
43
67
  fetchResources(): Promise<{
44
68
  [x: string]: unknown;
@@ -71,7 +95,16 @@ declare class MCPClientConnection {
71
95
  * Utility class that aggregates multiple MCP clients into one
72
96
  */
73
97
  declare class MCPClientManager {
98
+ private _name;
99
+ private _version;
74
100
  mcpConnections: Record<string, MCPClientConnection>;
101
+ private _callbackUrls;
102
+ /**
103
+ * @param _name Name of the MCP client
104
+ * @param _version Version of the MCP Client
105
+ * @param auth Auth paramters if being used to create a DurableObjectOAuthClientProvider
106
+ */
107
+ constructor(_name: string, _version: string);
75
108
  /**
76
109
  * Connect to and register an MCP server
77
110
  *
@@ -79,15 +112,42 @@ declare class MCPClientManager {
79
112
  * @param clientConfig Client config
80
113
  * @param capabilities Client capabilities (i.e. if the client supports roots/sampling)
81
114
  */
82
- connectToServer(url: URL, info: ConstructorParameters<typeof Client>[0], opts?: {
83
- transport: SSEClientTransportOptions;
84
- client: ConstructorParameters<typeof Client>[1];
85
- capabilities: ClientCapabilities;
86
- }): Promise<void>;
115
+ connect(url: string, options?: {
116
+ reconnect?: {
117
+ id: string;
118
+ oauthClientId?: string;
119
+ oauthCode?: string;
120
+ };
121
+ transport?: SSEClientTransportOptions & {
122
+ authProvider?: AgentsOAuthProvider;
123
+ };
124
+ client?: ConstructorParameters<typeof Client>[1];
125
+ }): Promise<{
126
+ id: string;
127
+ authUrl?: string;
128
+ clientId?: string;
129
+ }>;
130
+ isCallbackRequest(req: Request): boolean;
131
+ handleCallbackRequest(req: Request): Promise<{
132
+ serverId: string;
133
+ }>;
87
134
  /**
88
135
  * @returns namespaced list of tools
89
136
  */
90
137
  listTools(): NamespacedData["tools"];
138
+ /**
139
+ * @returns a set of tools that you can use with the AI SDK
140
+ */
141
+ unstable_getAITools(): ToolSet;
142
+ /**
143
+ * Closes all connections to MCP servers
144
+ */
145
+ closeAllConnections(): Promise<void[]>;
146
+ /**
147
+ * Closes a connection to an MCP server
148
+ * @param id The id of the connection to close
149
+ */
150
+ closeConnection(id: string): Promise<void>;
91
151
  /**
92
152
  * @returns namespaced list of prompts
93
153
  */
@@ -104,10 +164,10 @@ declare class MCPClientManager {
104
164
  * Namespaced version of callTool
105
165
  */
106
166
  callTool(params: CallToolRequest["params"] & {
107
- serverName: string;
108
- }, resultSchema: typeof CallToolResultSchema | typeof CompatibilityCallToolResultSchema, options: RequestOptions): Promise<zod.objectOutputType<zod.objectUtil.extendShape<{
167
+ serverId: string;
168
+ }, resultSchema?: typeof CallToolResultSchema | typeof CompatibilityCallToolResultSchema, options?: RequestOptions): Promise<zod.objectOutputType<{
109
169
  _meta: zod.ZodOptional<zod.ZodObject<{}, "passthrough", zod.ZodTypeAny, zod.objectOutputType<{}, zod.ZodTypeAny, "passthrough">, zod.objectInputType<{}, zod.ZodTypeAny, "passthrough">>>;
110
- }, {
170
+ } & {
111
171
  content: zod.ZodArray<zod.ZodUnion<[zod.ZodObject<{
112
172
  type: zod.ZodLiteral<"text">;
113
173
  text: zod.ZodString;
@@ -129,6 +189,18 @@ declare class MCPClientManager {
129
189
  type: zod.ZodLiteral<"image">;
130
190
  data: zod.ZodString;
131
191
  mimeType: zod.ZodString;
192
+ }, zod.ZodTypeAny, "passthrough">>, zod.ZodObject<{
193
+ type: zod.ZodLiteral<"audio">;
194
+ data: zod.ZodString;
195
+ mimeType: zod.ZodString;
196
+ }, "passthrough", zod.ZodTypeAny, zod.objectOutputType<{
197
+ type: zod.ZodLiteral<"audio">;
198
+ data: zod.ZodString;
199
+ mimeType: zod.ZodString;
200
+ }, zod.ZodTypeAny, "passthrough">, zod.objectInputType<{
201
+ type: zod.ZodLiteral<"audio">;
202
+ data: zod.ZodString;
203
+ mimeType: zod.ZodString;
132
204
  }, zod.ZodTypeAny, "passthrough">>, zod.ZodObject<{
133
205
  type: zod.ZodLiteral<"resource">;
134
206
  resource: zod.ZodUnion<[zod.ZodObject<zod.objectUtil.extendShape<{
@@ -230,19 +302,19 @@ declare class MCPClientManager {
230
302
  }>, zod.ZodTypeAny, "passthrough">>]>;
231
303
  }, zod.ZodTypeAny, "passthrough">>]>, "many">;
232
304
  isError: zod.ZodOptional<zod.ZodDefault<zod.ZodBoolean>>;
233
- }>, zod.ZodTypeAny, "passthrough"> | zod.objectOutputType<zod.objectUtil.extendShape<{
305
+ }, zod.ZodTypeAny, "passthrough"> | zod.objectOutputType<{
234
306
  _meta: zod.ZodOptional<zod.ZodObject<{}, "passthrough", zod.ZodTypeAny, zod.objectOutputType<{}, zod.ZodTypeAny, "passthrough">, zod.objectInputType<{}, zod.ZodTypeAny, "passthrough">>>;
235
- }, {
307
+ } & {
236
308
  toolResult: zod.ZodUnknown;
237
- }>, zod.ZodTypeAny, "passthrough">>;
309
+ }, zod.ZodTypeAny, "passthrough">>;
238
310
  /**
239
311
  * Namespaced version of readResource
240
312
  */
241
313
  readResource(params: ReadResourceRequest["params"] & {
242
- serverName: string;
243
- }, options: RequestOptions): Promise<zod.objectOutputType<zod.objectUtil.extendShape<{
314
+ serverId: string;
315
+ }, options: RequestOptions): Promise<zod.objectOutputType<{
244
316
  _meta: zod.ZodOptional<zod.ZodObject<{}, "passthrough", zod.ZodTypeAny, zod.objectOutputType<{}, zod.ZodTypeAny, "passthrough">, zod.objectInputType<{}, zod.ZodTypeAny, "passthrough">>>;
245
- }, {
317
+ } & {
246
318
  contents: zod.ZodArray<zod.ZodUnion<[zod.ZodObject<zod.objectUtil.extendShape<{
247
319
  uri: zod.ZodString;
248
320
  mimeType: zod.ZodOptional<zod.ZodString>;
@@ -274,15 +346,15 @@ declare class MCPClientManager {
274
346
  }, {
275
347
  blob: zod.ZodString;
276
348
  }>, zod.ZodTypeAny, "passthrough">>]>, "many">;
277
- }>, zod.ZodTypeAny, "passthrough">>;
349
+ }, zod.ZodTypeAny, "passthrough">>;
278
350
  /**
279
351
  * Namespaced version of getPrompt
280
352
  */
281
353
  getPrompt(params: GetPromptRequest["params"] & {
282
- serverName: string;
283
- }, options: RequestOptions): Promise<zod.objectOutputType<zod.objectUtil.extendShape<{
354
+ serverId: string;
355
+ }, options: RequestOptions): Promise<zod.objectOutputType<{
284
356
  _meta: zod.ZodOptional<zod.ZodObject<{}, "passthrough", zod.ZodTypeAny, zod.objectOutputType<{}, zod.ZodTypeAny, "passthrough">, zod.objectInputType<{}, zod.ZodTypeAny, "passthrough">>>;
285
- }, {
357
+ } & {
286
358
  description: zod.ZodOptional<zod.ZodString>;
287
359
  messages: zod.ZodArray<zod.ZodObject<{
288
360
  role: zod.ZodEnum<["user", "assistant"]>;
@@ -307,6 +379,18 @@ declare class MCPClientManager {
307
379
  type: zod.ZodLiteral<"image">;
308
380
  data: zod.ZodString;
309
381
  mimeType: zod.ZodString;
382
+ }, zod.ZodTypeAny, "passthrough">>, zod.ZodObject<{
383
+ type: zod.ZodLiteral<"audio">;
384
+ data: zod.ZodString;
385
+ mimeType: zod.ZodString;
386
+ }, "passthrough", zod.ZodTypeAny, zod.objectOutputType<{
387
+ type: zod.ZodLiteral<"audio">;
388
+ data: zod.ZodString;
389
+ mimeType: zod.ZodString;
390
+ }, zod.ZodTypeAny, "passthrough">, zod.objectInputType<{
391
+ type: zod.ZodLiteral<"audio">;
392
+ data: zod.ZodString;
393
+ mimeType: zod.ZodString;
310
394
  }, zod.ZodTypeAny, "passthrough">>, zod.ZodObject<{
311
395
  type: zod.ZodLiteral<"resource">;
312
396
  resource: zod.ZodUnion<[zod.ZodObject<zod.objectUtil.extendShape<{
@@ -430,6 +514,18 @@ declare class MCPClientManager {
430
514
  type: zod.ZodLiteral<"image">;
431
515
  data: zod.ZodString;
432
516
  mimeType: zod.ZodString;
517
+ }, zod.ZodTypeAny, "passthrough">>, zod.ZodObject<{
518
+ type: zod.ZodLiteral<"audio">;
519
+ data: zod.ZodString;
520
+ mimeType: zod.ZodString;
521
+ }, "passthrough", zod.ZodTypeAny, zod.objectOutputType<{
522
+ type: zod.ZodLiteral<"audio">;
523
+ data: zod.ZodString;
524
+ mimeType: zod.ZodString;
525
+ }, zod.ZodTypeAny, "passthrough">, zod.objectInputType<{
526
+ type: zod.ZodLiteral<"audio">;
527
+ data: zod.ZodString;
528
+ mimeType: zod.ZodString;
433
529
  }, zod.ZodTypeAny, "passthrough">>, zod.ZodObject<{
434
530
  type: zod.ZodLiteral<"resource">;
435
531
  resource: zod.ZodUnion<[zod.ZodObject<zod.objectUtil.extendShape<{
@@ -553,6 +649,18 @@ declare class MCPClientManager {
553
649
  type: zod.ZodLiteral<"image">;
554
650
  data: zod.ZodString;
555
651
  mimeType: zod.ZodString;
652
+ }, zod.ZodTypeAny, "passthrough">>, zod.ZodObject<{
653
+ type: zod.ZodLiteral<"audio">;
654
+ data: zod.ZodString;
655
+ mimeType: zod.ZodString;
656
+ }, "passthrough", zod.ZodTypeAny, zod.objectOutputType<{
657
+ type: zod.ZodLiteral<"audio">;
658
+ data: zod.ZodString;
659
+ mimeType: zod.ZodString;
660
+ }, zod.ZodTypeAny, "passthrough">, zod.objectInputType<{
661
+ type: zod.ZodLiteral<"audio">;
662
+ data: zod.ZodString;
663
+ mimeType: zod.ZodString;
556
664
  }, zod.ZodTypeAny, "passthrough">>, zod.ZodObject<{
557
665
  type: zod.ZodLiteral<"resource">;
558
666
  resource: zod.ZodUnion<[zod.ZodObject<zod.objectUtil.extendShape<{
@@ -654,20 +762,20 @@ declare class MCPClientManager {
654
762
  }>, zod.ZodTypeAny, "passthrough">>]>;
655
763
  }, zod.ZodTypeAny, "passthrough">>]>;
656
764
  }, zod.ZodTypeAny, "passthrough">>, "many">;
657
- }>, zod.ZodTypeAny, "passthrough">>;
765
+ }, zod.ZodTypeAny, "passthrough">>;
658
766
  }
659
767
  type NamespacedData = {
660
768
  tools: (Tool & {
661
- serverName: string;
769
+ serverId: string;
662
770
  })[];
663
771
  prompts: (Prompt & {
664
- serverName: string;
772
+ serverId: string;
665
773
  })[];
666
774
  resources: (Resource & {
667
- serverName: string;
775
+ serverId: string;
668
776
  })[];
669
777
  resourceTemplates: (ResourceTemplate & {
670
- serverName: string;
778
+ serverId: string;
671
779
  })[];
672
780
  };
673
781
  declare function getNamespacedData<T extends keyof NamespacedData>(mcpClients: Record<string, MCPClientConnection>, type: T): NamespacedData[T];
@@ -0,0 +1,9 @@
1
+ import {
2
+ MCPClientManager,
3
+ getNamespacedData
4
+ } from "../chunk-OYJXQRRH.js";
5
+ export {
6
+ MCPClientManager,
7
+ getNamespacedData
8
+ };
9
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,41 @@
1
+ import { OAuthClientProvider } from '@modelcontextprotocol/sdk/client/auth.js';
2
+ import { OAuthClientMetadata, OAuthClientInformation, OAuthClientInformationFull, OAuthTokens } from '@modelcontextprotocol/sdk/shared/auth.js';
3
+
4
+ interface AgentsOAuthProvider extends OAuthClientProvider {
5
+ authUrl: string | undefined;
6
+ clientId: string | undefined;
7
+ serverId: string | undefined;
8
+ }
9
+ declare class DurableObjectOAuthClientProvider implements AgentsOAuthProvider {
10
+ storage: DurableObjectStorage;
11
+ clientName: string;
12
+ baseRedirectUrl: string;
13
+ private _authUrl_;
14
+ private _serverId_;
15
+ private _clientId_;
16
+ constructor(storage: DurableObjectStorage, clientName: string, baseRedirectUrl: string);
17
+ get clientMetadata(): OAuthClientMetadata;
18
+ get redirectUrl(): string;
19
+ get clientId(): string;
20
+ set clientId(clientId_: string);
21
+ get serverId(): string;
22
+ set serverId(serverId_: string);
23
+ keyPrefix(clientId: string): string;
24
+ clientInfoKey(clientId: string): string;
25
+ clientInformation(): Promise<OAuthClientInformation | undefined>;
26
+ saveClientInformation(clientInformation: OAuthClientInformationFull): Promise<void>;
27
+ tokenKey(clientId: string): string;
28
+ tokens(): Promise<OAuthTokens | undefined>;
29
+ saveTokens(tokens: OAuthTokens): Promise<void>;
30
+ get authUrl(): string | undefined;
31
+ /**
32
+ * Because this operates on the server side (but we need browser auth), we send this url back to the user
33
+ * and require user interact to initiate the redirect flow
34
+ */
35
+ redirectToAuthorization(authUrl: URL): Promise<void>;
36
+ codeVerifierKey(clientId: string): string;
37
+ saveCodeVerifier(verifier: string): Promise<void>;
38
+ codeVerifier(): Promise<string>;
39
+ }
40
+
41
+ export { type AgentsOAuthProvider, DurableObjectOAuthClientProvider };
@@ -0,0 +1,7 @@
1
+ import {
2
+ DurableObjectOAuthClientProvider
3
+ } from "../chunk-BZXOAZUX.js";
4
+ export {
5
+ DurableObjectOAuthClientProvider
6
+ };
7
+ //# sourceMappingURL=do-oauth-client-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,15 +1,37 @@
1
+ import { MCPClientManager } from './client.js';
1
2
  import { DurableObject } from 'cloudflare:workers';
3
+ import { Connection, WSMessage } from 'partyserver';
2
4
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
- import { Connection } from 'partyserver';
5
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
6
+ import 'zod';
7
+ import '@modelcontextprotocol/sdk/types.js';
8
+ import '@modelcontextprotocol/sdk/client/index.js';
9
+ import '@modelcontextprotocol/sdk/client/sse.js';
10
+ import './do-oauth-client-provider.js';
11
+ import '@modelcontextprotocol/sdk/client/auth.js';
12
+ import '@modelcontextprotocol/sdk/shared/auth.js';
13
+ import '@modelcontextprotocol/sdk/shared/protocol.js';
14
+ import 'ai';
4
15
 
5
16
  interface CORSOptions {
6
17
  origin?: string;
7
18
  methods?: string;
8
19
  headers?: string;
9
20
  maxAge?: number;
21
+ exposeHeaders?: string;
10
22
  }
23
+ type MaybePromise<T> = T | Promise<T>;
11
24
  declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Record<string, unknown> = Record<string, unknown>> extends DurableObject<Env> {
12
- #private;
25
+ private _status;
26
+ private _transport?;
27
+ private _transportType;
28
+ private _requestIdToConnectionId;
29
+ /**
30
+ * Since McpAgent's _aren't_ yet real "Agents", let's only expose a couple of the methods
31
+ * to the outer class: initialState/state/setState/onStateUpdate/sql
32
+ */
33
+ private _agent;
34
+ get mcp(): MCPClientManager;
13
35
  protected constructor(ctx: DurableObjectState, env: Env);
14
36
  /**
15
37
  * Agents API allowlist
@@ -19,22 +41,43 @@ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Re
19
41
  sql<T = Record<string, string | number | boolean | null>>(strings: TemplateStringsArray, ...values: (string | number | boolean | null)[]): T[];
20
42
  setState(state: State): void;
21
43
  onStateUpdate(state: State | undefined, source: Connection | "server"): void;
44
+ onStart(): Promise<void>;
22
45
  /**
23
46
  * McpAgent API
24
47
  */
25
- abstract server: McpServer;
26
- private transport;
48
+ abstract server: MaybePromise<McpServer | Server>;
27
49
  props: Props;
28
50
  initRun: boolean;
29
51
  abstract init(): Promise<void>;
30
52
  _init(props: Props): Promise<void>;
31
- onSSE(path: string): Promise<Response>;
32
- onMCPMessage(request: Request): Promise<Response>;
53
+ setInitialized(): Promise<void>;
54
+ isInitialized(): Promise<boolean>;
55
+ private _initialize;
56
+ fetch(request: Request): Promise<Response>;
57
+ getWebSocket(): WebSocket | null;
58
+ getWebSocketForResponseID(id: string): WebSocket | null;
59
+ onMessage(connection: Connection, event: WSMessage): Promise<void>;
60
+ onSSEMcpMessage(sessionId: string, request: Request): Promise<Error | null>;
61
+ webSocketMessage(ws: WebSocket, event: ArrayBuffer | string): Promise<void>;
62
+ webSocketError(ws: WebSocket, error: unknown): Promise<void>;
63
+ webSocketClose(ws: WebSocket, code: number, reason: string, wasClean: boolean): Promise<void>;
33
64
  static mount(path: string, { binding, corsOptions, }?: {
34
65
  binding?: string;
35
66
  corsOptions?: CORSOptions;
36
67
  }): {
37
- fetch: (request: Request, env: Record<string, DurableObjectNamespace<McpAgent>>, ctx: ExecutionContext) => Promise<Response>;
68
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
69
+ };
70
+ static serveSSE(path: string, { binding, corsOptions, }?: {
71
+ binding?: string;
72
+ corsOptions?: CORSOptions;
73
+ }): {
74
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
75
+ };
76
+ static serve(path: string, { binding, corsOptions, }?: {
77
+ binding?: string;
78
+ corsOptions?: CORSOptions;
79
+ }): {
80
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
38
81
  };
39
82
  }
40
83