agents 0.0.0-2cc0f02 → 0.0.0-2e73791
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 +126 -3
- package/dist/ai-chat-agent.d.ts +231 -22
- package/dist/ai-chat-agent.js +691 -121
- package/dist/ai-chat-agent.js.map +1 -1
- package/dist/{ai-chat-v5-migration-gdyLiTd8.js → ai-chat-v5-migration-DguhuLKF.js} +2 -2
- package/dist/{ai-chat-v5-migration-gdyLiTd8.js.map → ai-chat-v5-migration-DguhuLKF.js.map} +1 -1
- package/dist/ai-chat-v5-migration.js +1 -1
- package/dist/ai-react.d.ts +145 -16
- package/dist/ai-react.js +389 -75
- package/dist/ai-react.js.map +1 -1
- package/dist/{ai-types-B0GBFDwi.js → ai-types-DEtF_8Km.js} +10 -2
- package/dist/ai-types-DEtF_8Km.js.map +1 -0
- package/dist/{ai-types-BWW4umHY.d.ts → ai-types-U8lYA0o8.d.ts} +41 -9
- package/dist/ai-types.d.ts +4 -4
- package/dist/ai-types.js +1 -1
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +28 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/client-Cfw92Wb_.d.ts +834 -0
- package/dist/{client-CmMi85Sj.d.ts → client-ClORm6f0.d.ts} +10 -10
- package/dist/{client-zS-OCVJA.js → client-DjTPRM8-.js} +3 -3
- package/dist/{client-zS-OCVJA.js.map → client-DjTPRM8-.js.map} +1 -1
- package/dist/client-QZa2Rq0l.js +1105 -0
- package/dist/client-QZa2Rq0l.js.map +1 -0
- package/dist/client.d.ts +8 -8
- package/dist/client.js +2 -2
- package/dist/codemode/ai.js +7 -6
- package/dist/codemode/ai.js.map +1 -1
- package/dist/context-BkKbAa1R.js +8 -0
- package/dist/context-BkKbAa1R.js.map +1 -0
- package/dist/context-_sPQqJWv.d.ts +24 -0
- package/dist/context.d.ts +6 -0
- package/dist/context.js +3 -0
- package/dist/{do-oauth-client-provider-CCwGwnrA.d.ts → do-oauth-client-provider-B-ryFIPr.d.ts} +21 -6
- package/dist/{do-oauth-client-provider-B2jr6UNq.js → do-oauth-client-provider-B1fVIshX.js} +71 -9
- package/dist/do-oauth-client-provider-B1fVIshX.js.map +1 -0
- package/dist/{index-W4JUkafc.d.ts → index-CyDpAVHZ.d.ts} +7 -3
- package/dist/{index-DWcUTPtX.d.ts → index-xIS9I1YX.d.ts} +83 -65
- package/dist/index.d.ts +36 -36
- package/dist/index.js +6 -5
- package/dist/mcp/client.d.ts +4 -4
- package/dist/mcp/client.js +2 -1
- package/dist/mcp/do-oauth-client-provider.d.ts +1 -1
- package/dist/mcp/do-oauth-client-provider.js +1 -1
- package/dist/mcp/index.d.ts +140 -12
- package/dist/mcp/index.js +636 -41
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/x402.js +10 -6
- package/dist/mcp/x402.js.map +1 -1
- package/dist/{mcp-BEwaCsxO.d.ts → mcp-CzbSsLfc.d.ts} +2 -2
- package/dist/observability/index.d.ts +2 -2
- package/dist/observability/index.js +6 -5
- package/dist/{react-B8BT6PYZ.d.ts → react-ElpIreHg.d.ts} +35 -17
- package/dist/react.d.ts +15 -10
- package/dist/react.js +57 -57
- package/dist/react.js.map +1 -1
- package/dist/{serializable-gtr9YMhp.d.ts → serializable-C4GLimgv.d.ts} +8 -3
- package/dist/serializable.d.ts +5 -5
- package/dist/{src-C9xZ0CrH.js → src-BZDh910Z.js} +130 -128
- package/dist/src-BZDh910Z.js.map +1 -0
- package/package.json +61 -44
- package/dist/ai-types-B0GBFDwi.js.map +0 -1
- package/dist/client-C-u-lCFT.d.ts +0 -5311
- package/dist/client-WbaRgKYN.js +0 -788
- package/dist/client-WbaRgKYN.js.map +0 -1
- package/dist/do-oauth-client-provider-B2jr6UNq.js.map +0 -1
- package/dist/src-C9xZ0CrH.js.map +0 -1
- package/src/index.ts +0 -2031
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { n as AgentEmail } from "./context-_sPQqJWv.js";
|
|
1
2
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from "./client-
|
|
6
|
-
import { Observability } from "./index-
|
|
7
|
-
import { MessageType } from "./ai-types-
|
|
3
|
+
h as TransportType,
|
|
4
|
+
t as MCPClientManager,
|
|
5
|
+
u as MCPConnectionState
|
|
6
|
+
} from "./client-Cfw92Wb_.js";
|
|
7
|
+
import { t as Observability } from "./index-CyDpAVHZ.js";
|
|
8
|
+
import { n as MessageType } from "./ai-types-U8lYA0o8.js";
|
|
8
9
|
import {
|
|
9
10
|
Connection,
|
|
10
11
|
Connection as Connection$1,
|
|
@@ -20,7 +21,6 @@ import {
|
|
|
20
21
|
ServerCapabilities,
|
|
21
22
|
Tool
|
|
22
23
|
} from "@modelcontextprotocol/sdk/types.js";
|
|
23
|
-
import { env } from "cloudflare:workers";
|
|
24
24
|
|
|
25
25
|
//#region src/index.d.ts
|
|
26
26
|
|
|
@@ -90,7 +90,7 @@ declare const unstable_callable: (metadata?: CallableMetadata) => void;
|
|
|
90
90
|
type QueueItem<T = string> = {
|
|
91
91
|
id: string;
|
|
92
92
|
payload: T;
|
|
93
|
-
callback: keyof Agent<
|
|
93
|
+
callback: keyof Agent<Cloudflare.Env>;
|
|
94
94
|
created_at: number;
|
|
95
95
|
};
|
|
96
96
|
/**
|
|
@@ -139,9 +139,15 @@ type MCPServersState = {
|
|
|
139
139
|
servers: {
|
|
140
140
|
[id: string]: MCPServer;
|
|
141
141
|
};
|
|
142
|
-
tools: Tool
|
|
143
|
-
|
|
144
|
-
|
|
142
|
+
tools: (Tool & {
|
|
143
|
+
serverId: string;
|
|
144
|
+
})[];
|
|
145
|
+
prompts: (Prompt & {
|
|
146
|
+
serverId: string;
|
|
147
|
+
})[];
|
|
148
|
+
resources: (Resource & {
|
|
149
|
+
serverId: string;
|
|
150
|
+
})[];
|
|
145
151
|
};
|
|
146
152
|
type MCPServer = {
|
|
147
153
|
name: string;
|
|
@@ -152,7 +158,7 @@ type MCPServer = {
|
|
|
152
158
|
capabilities: ServerCapabilities | null;
|
|
153
159
|
};
|
|
154
160
|
declare function getCurrentAgent<
|
|
155
|
-
T extends Agent<
|
|
161
|
+
T extends Agent<Cloudflare.Env> = Agent<Cloudflare.Env>
|
|
156
162
|
>(): {
|
|
157
163
|
agent: T | undefined;
|
|
158
164
|
connection: Connection | undefined;
|
|
@@ -165,12 +171,13 @@ declare function getCurrentAgent<
|
|
|
165
171
|
* @template State State type to store within the Agent
|
|
166
172
|
*/
|
|
167
173
|
declare class Agent<
|
|
168
|
-
Env =
|
|
174
|
+
Env extends Cloudflare.Env = Cloudflare.Env,
|
|
169
175
|
State = unknown,
|
|
170
176
|
Props extends Record<string, unknown> = Record<string, unknown>
|
|
171
177
|
> extends Server<Env, Props> {
|
|
172
178
|
private _state;
|
|
173
179
|
private _disposables;
|
|
180
|
+
private _destroyed;
|
|
174
181
|
private _ParentClass;
|
|
175
182
|
readonly mcp: MCPClientManager;
|
|
176
183
|
/**
|
|
@@ -324,7 +331,7 @@ declare class Agent<
|
|
|
324
331
|
/**
|
|
325
332
|
* Cancel a scheduled task
|
|
326
333
|
* @param id ID of the task to cancel
|
|
327
|
-
* @returns true if the task was cancelled, false
|
|
334
|
+
* @returns true if the task was cancelled, false if the task was not found
|
|
328
335
|
*/
|
|
329
336
|
cancelSchedule(id: string): Promise<boolean>;
|
|
330
337
|
private _scheduleNextAlarm;
|
|
@@ -354,7 +361,8 @@ declare class Agent<
|
|
|
354
361
|
* @param callbackHost Base host for the agent, used for the redirect URI. If not provided, will be derived from the current request.
|
|
355
362
|
* @param agentsPrefix agents routing prefix if not using `agents`
|
|
356
363
|
* @param options MCP client and transport options
|
|
357
|
-
* @returns authUrl
|
|
364
|
+
* @returns Server id and state - either "authenticating" with authUrl, or "ready"
|
|
365
|
+
* @throws If connection or discovery fails
|
|
358
366
|
*/
|
|
359
367
|
addMcpServer(
|
|
360
368
|
serverName: string,
|
|
@@ -368,14 +376,35 @@ declare class Agent<
|
|
|
368
376
|
type?: TransportType;
|
|
369
377
|
};
|
|
370
378
|
}
|
|
371
|
-
): Promise<
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
379
|
+
): Promise<
|
|
380
|
+
| {
|
|
381
|
+
id: string;
|
|
382
|
+
state: typeof MCPConnectionState.AUTHENTICATING;
|
|
383
|
+
authUrl: string;
|
|
384
|
+
}
|
|
385
|
+
| {
|
|
386
|
+
id: string;
|
|
387
|
+
state: typeof MCPConnectionState.READY;
|
|
388
|
+
authUrl?: undefined;
|
|
389
|
+
}
|
|
390
|
+
>;
|
|
376
391
|
removeMcpServer(id: string): Promise<void>;
|
|
377
392
|
getMcpServers(): MCPServersState;
|
|
378
393
|
private broadcastMcpServers;
|
|
394
|
+
/**
|
|
395
|
+
* Handle MCP OAuth callback request if it's an OAuth callback.
|
|
396
|
+
*
|
|
397
|
+
* This method encapsulates the entire OAuth callback flow:
|
|
398
|
+
* 1. Checks if the request is an MCP OAuth callback
|
|
399
|
+
* 2. Processes the OAuth code exchange
|
|
400
|
+
* 3. Establishes the connection if successful
|
|
401
|
+
* 4. Broadcasts MCP server state updates
|
|
402
|
+
* 5. Returns the appropriate HTTP response
|
|
403
|
+
*
|
|
404
|
+
* @param request The incoming HTTP request
|
|
405
|
+
* @returns Response if this was an OAuth callback, null otherwise
|
|
406
|
+
*/
|
|
407
|
+
private handleMcpOAuthCallback;
|
|
379
408
|
/**
|
|
380
409
|
* Handle OAuth callback response using MCPClientManager configuration
|
|
381
410
|
* @param result OAuth callback result
|
|
@@ -388,7 +417,7 @@ declare class Agent<
|
|
|
388
417
|
* Namespace for creating Agent instances
|
|
389
418
|
* @template Agentic Type of the Agent class
|
|
390
419
|
*/
|
|
391
|
-
type AgentNamespace<Agentic extends Agent<
|
|
420
|
+
type AgentNamespace<Agentic extends Agent<Cloudflare.Env>> =
|
|
392
421
|
DurableObjectNamespace<Agentic>;
|
|
393
422
|
/**
|
|
394
423
|
* Agent's durable context
|
|
@@ -455,21 +484,11 @@ type EmailRoutingOptions<Env> = AgentOptions<Env> & {
|
|
|
455
484
|
* @param options The options for routing the email
|
|
456
485
|
* @returns A promise that resolves when the email has been routed
|
|
457
486
|
*/
|
|
458
|
-
declare function routeAgentEmail<Env>(
|
|
487
|
+
declare function routeAgentEmail<Env extends Cloudflare.Env = Cloudflare.Env>(
|
|
459
488
|
email: ForwardableEmailMessage,
|
|
460
489
|
env: Env,
|
|
461
490
|
options: EmailRoutingOptions<Env>
|
|
462
491
|
): Promise<void>;
|
|
463
|
-
type AgentEmail = {
|
|
464
|
-
from: string;
|
|
465
|
-
to: string;
|
|
466
|
-
getRaw: () => Promise<Uint8Array>;
|
|
467
|
-
headers: Headers;
|
|
468
|
-
rawSize: number;
|
|
469
|
-
setReject: (reason: string) => void;
|
|
470
|
-
forward: (rcptTo: string, headers?: Headers) => Promise<void>;
|
|
471
|
-
reply: (options: { from: string; to: string; raw: string }) => Promise<void>;
|
|
472
|
-
};
|
|
473
492
|
type EmailSendOptions = {
|
|
474
493
|
to: string;
|
|
475
494
|
subject: string;
|
|
@@ -491,8 +510,8 @@ type EmailSendOptions = {
|
|
|
491
510
|
* @returns Promise resolving to an Agent instance stub
|
|
492
511
|
*/
|
|
493
512
|
declare function getAgentByName<
|
|
494
|
-
Env,
|
|
495
|
-
T extends Agent<Env>,
|
|
513
|
+
Env extends Cloudflare.Env = Cloudflare.Env,
|
|
514
|
+
T extends Agent<Env> = Agent<Env>,
|
|
496
515
|
Props extends Record<string, unknown> = Record<string, unknown>
|
|
497
516
|
>(
|
|
498
517
|
namespace: AgentNamespace<T>,
|
|
@@ -524,35 +543,34 @@ declare class StreamingResponse {
|
|
|
524
543
|
}
|
|
525
544
|
//#endregion
|
|
526
545
|
export {
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
unstable_callable
|
|
546
|
+
createCatchAllEmailResolver as C,
|
|
547
|
+
routeAgentEmail as D,
|
|
548
|
+
getCurrentAgent as E,
|
|
549
|
+
routeAgentRequest as O,
|
|
550
|
+
createAddressBasedEmailResolver as S,
|
|
551
|
+
getAgentByName as T,
|
|
552
|
+
Schedule as _,
|
|
553
|
+
CallableMetadata as a,
|
|
554
|
+
WSMessage as b,
|
|
555
|
+
EmailResolver as c,
|
|
556
|
+
MCPServer as d,
|
|
557
|
+
MCPServerMessage as f,
|
|
558
|
+
RPCResponse as g,
|
|
559
|
+
RPCRequest as h,
|
|
560
|
+
AgentOptions as i,
|
|
561
|
+
unstable_callable as k,
|
|
562
|
+
EmailRoutingOptions as l,
|
|
563
|
+
QueueItem as m,
|
|
564
|
+
AgentContext as n,
|
|
565
|
+
Connection$1 as o,
|
|
566
|
+
MCPServersState as p,
|
|
567
|
+
AgentNamespace as r,
|
|
568
|
+
ConnectionContext as s,
|
|
569
|
+
Agent as t,
|
|
570
|
+
EmailSendOptions as u,
|
|
571
|
+
StateUpdateMessage as v,
|
|
572
|
+
createHeaderBasedEmailResolver as w,
|
|
573
|
+
callable as x,
|
|
574
|
+
StreamingResponse as y
|
|
557
575
|
};
|
|
558
|
-
//# sourceMappingURL=index-
|
|
576
|
+
//# sourceMappingURL=index-xIS9I1YX.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./
|
|
3
|
-
import "./
|
|
4
|
-
import "./
|
|
5
|
-
import "./
|
|
1
|
+
import { n as AgentEmail } from "./context-_sPQqJWv.js";
|
|
2
|
+
import { h as TransportType } from "./client-Cfw92Wb_.js";
|
|
3
|
+
import "./mcp-CzbSsLfc.js";
|
|
4
|
+
import "./do-oauth-client-provider-B-ryFIPr.js";
|
|
5
|
+
import "./index-CyDpAVHZ.js";
|
|
6
|
+
import "./ai-types-U8lYA0o8.js";
|
|
6
7
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
} from "./index-DWcUTPtX.js";
|
|
8
|
+
C as createCatchAllEmailResolver,
|
|
9
|
+
D as routeAgentEmail,
|
|
10
|
+
E as getCurrentAgent,
|
|
11
|
+
O as routeAgentRequest,
|
|
12
|
+
S as createAddressBasedEmailResolver,
|
|
13
|
+
T as getAgentByName,
|
|
14
|
+
_ as Schedule,
|
|
15
|
+
a as CallableMetadata,
|
|
16
|
+
b as WSMessage,
|
|
17
|
+
c as EmailResolver,
|
|
18
|
+
d as MCPServer,
|
|
19
|
+
f as MCPServerMessage,
|
|
20
|
+
g as RPCResponse,
|
|
21
|
+
h as RPCRequest,
|
|
22
|
+
i as AgentOptions,
|
|
23
|
+
k as unstable_callable,
|
|
24
|
+
l as EmailRoutingOptions,
|
|
25
|
+
m as QueueItem,
|
|
26
|
+
n as AgentContext,
|
|
27
|
+
o as Connection,
|
|
28
|
+
p as MCPServersState,
|
|
29
|
+
r as AgentNamespace,
|
|
30
|
+
s as ConnectionContext,
|
|
31
|
+
t as Agent,
|
|
32
|
+
u as EmailSendOptions,
|
|
33
|
+
v as StateUpdateMessage,
|
|
34
|
+
w as createHeaderBasedEmailResolver,
|
|
35
|
+
x as callable,
|
|
36
|
+
y as StreamingResponse
|
|
37
|
+
} from "./index-xIS9I1YX.js";
|
|
38
38
|
export {
|
|
39
39
|
Agent,
|
|
40
40
|
AgentContext,
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import "./ai-types-
|
|
3
|
-
import "./client-
|
|
4
|
-
import "./
|
|
5
|
-
import
|
|
1
|
+
import "./context-BkKbAa1R.js";
|
|
2
|
+
import "./ai-types-DEtF_8Km.js";
|
|
3
|
+
import "./client-DjTPRM8-.js";
|
|
4
|
+
import "./client-QZa2Rq0l.js";
|
|
5
|
+
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-BZDh910Z.js";
|
|
6
7
|
|
|
7
8
|
export { Agent, StreamingResponse, callable, createAddressBasedEmailResolver, createCatchAllEmailResolver, createHeaderBasedEmailResolver, getAgentByName, getCurrentAgent, routeAgentEmail, routeAgentRequest, unstable_callable };
|
package/dist/mcp/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../mcp-
|
|
3
|
-
import "../do-oauth-client-provider-
|
|
4
|
-
export { MCPClientManager, MCPClientOAuthCallbackConfig, MCPClientOAuthResult, getNamespacedData };
|
|
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-Cfw92Wb_.js";
|
|
2
|
+
import "../mcp-CzbSsLfc.js";
|
|
3
|
+
import "../do-oauth-client-provider-B-ryFIPr.js";
|
|
4
|
+
export { MCPClientManager, MCPClientManagerOptions, MCPClientOAuthCallbackConfig, MCPClientOAuthResult, MCPConnectionResult, MCPDiscoverResult, MCPServerOptions, RegisterServerOptions, getNamespacedData };
|
package/dist/mcp/client.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as DurableObjectOAuthClientProvider, t as AgentsOAuthProvider } from "../do-oauth-client-provider-B-ryFIPr.js";
|
|
2
2
|
export { AgentsOAuthProvider, DurableObjectOAuthClientProvider };
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -1,15 +1,142 @@
|
|
|
1
|
-
import
|
|
2
|
-
import "../
|
|
3
|
-
import "../
|
|
4
|
-
import "../
|
|
5
|
-
import "../
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
1
|
+
import "../context-_sPQqJWv.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-Cfw92Wb_.js";
|
|
3
|
+
import "../mcp-CzbSsLfc.js";
|
|
4
|
+
import "../do-oauth-client-provider-B-ryFIPr.js";
|
|
5
|
+
import "../index-CyDpAVHZ.js";
|
|
6
|
+
import "../ai-types-U8lYA0o8.js";
|
|
7
|
+
import { o as Connection, s as ConnectionContext, t as Agent } from "../index-xIS9I1YX.js";
|
|
8
|
+
import { SSEClientTransport, SSEClientTransportOptions } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
9
|
+
import { StreamableHTTPClientTransport, StreamableHTTPClientTransportOptions } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
10
|
+
import { ElicitRequest, ElicitRequestSchema, ElicitResult, ElicitResult as ElicitResult$1, JSONRPCMessage, MessageExtraInfo } from "@modelcontextprotocol/sdk/types.js";
|
|
8
11
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
9
12
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
13
|
+
import { Transport, TransportSendOptions } from "@modelcontextprotocol/sdk/shared/transport.js";
|
|
10
14
|
|
|
15
|
+
//#region src/mcp/client-transports.d.ts
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Use SSEClientTransport from @modelcontextprotocol/sdk/client/sse.js instead. This alias will be removed in the next major version.
|
|
18
|
+
*/
|
|
19
|
+
declare class SSEEdgeClientTransport extends SSEClientTransport {
|
|
20
|
+
constructor(url: URL, options: SSEClientTransportOptions);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* @deprecated Use StreamableHTTPClientTransport from @modelcontextprotocol/sdk/client/streamableHttp.js instead. This alias will be removed in the next major version.
|
|
24
|
+
*/
|
|
25
|
+
declare class StreamableHTTPEdgeClientTransport extends StreamableHTTPClientTransport {
|
|
26
|
+
constructor(url: URL, options: StreamableHTTPClientTransportOptions);
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/mcp/worker-transport.d.ts
|
|
30
|
+
interface MCPStorageApi {
|
|
31
|
+
get(): Promise<TransportState | undefined> | TransportState | undefined;
|
|
32
|
+
set(state: TransportState): Promise<void> | void;
|
|
33
|
+
}
|
|
34
|
+
interface TransportState {
|
|
35
|
+
sessionId?: string;
|
|
36
|
+
initialized: boolean;
|
|
37
|
+
}
|
|
38
|
+
interface WorkerTransportOptions {
|
|
39
|
+
sessionIdGenerator?: () => string;
|
|
40
|
+
/**
|
|
41
|
+
* Enable traditional Request/Response mode, this will disable streaming.
|
|
42
|
+
*/
|
|
43
|
+
enableJsonResponse?: boolean;
|
|
44
|
+
onsessioninitialized?: (sessionId: string) => void;
|
|
45
|
+
corsOptions?: CORSOptions;
|
|
46
|
+
/**
|
|
47
|
+
* Optional storage api for persisting transport state.
|
|
48
|
+
* Use this to store session state in Durable Object/Agent storage
|
|
49
|
+
* so it survives hibernation/restart.
|
|
50
|
+
*/
|
|
51
|
+
storage?: MCPStorageApi;
|
|
52
|
+
}
|
|
53
|
+
declare class WorkerTransport implements Transport {
|
|
54
|
+
started: boolean;
|
|
55
|
+
private initialized;
|
|
56
|
+
private sessionIdGenerator?;
|
|
57
|
+
private enableJsonResponse;
|
|
58
|
+
private onsessioninitialized?;
|
|
59
|
+
private standaloneSseStreamId;
|
|
60
|
+
private streamMapping;
|
|
61
|
+
private requestToStreamMapping;
|
|
62
|
+
private requestResponseMap;
|
|
63
|
+
private corsOptions?;
|
|
64
|
+
private storage?;
|
|
65
|
+
private stateRestored;
|
|
66
|
+
sessionId?: string;
|
|
67
|
+
onclose?: () => void;
|
|
68
|
+
onerror?: (error: Error) => void;
|
|
69
|
+
onmessage?: (message: JSONRPCMessage, extra?: MessageExtraInfo) => void;
|
|
70
|
+
constructor(options?: WorkerTransportOptions);
|
|
71
|
+
/**
|
|
72
|
+
* Restore transport state from persistent storage.
|
|
73
|
+
* This is automatically called on start.
|
|
74
|
+
*/
|
|
75
|
+
private restoreState;
|
|
76
|
+
/**
|
|
77
|
+
* Persist current transport state to storage.
|
|
78
|
+
*/
|
|
79
|
+
private saveState;
|
|
80
|
+
start(): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Validates the MCP-Protocol-Version header on incoming requests.
|
|
83
|
+
*
|
|
84
|
+
* This performs a simple check: if a version header is present, it must be
|
|
85
|
+
* in the SUPPORTED_PROTOCOL_VERSIONS list. We do not track the negotiated
|
|
86
|
+
* version or enforce version consistency across requests - the SDK handles
|
|
87
|
+
* version negotiation during initialization, and we simply reject any
|
|
88
|
+
* explicitly unsupported versions.
|
|
89
|
+
*
|
|
90
|
+
* - Header present and supported: Accept
|
|
91
|
+
* - Header present and unsupported: 400 Bad Request
|
|
92
|
+
* - Header missing: Accept (version validation is optional)
|
|
93
|
+
*/
|
|
94
|
+
private validateProtocolVersion;
|
|
95
|
+
private getHeaders;
|
|
96
|
+
handleRequest(request: Request, parsedBody?: unknown): Promise<Response>;
|
|
97
|
+
private handleGetRequest;
|
|
98
|
+
private handlePostRequest;
|
|
99
|
+
private handleDeleteRequest;
|
|
100
|
+
private handleOptionsRequest;
|
|
101
|
+
private handleUnsupportedRequest;
|
|
102
|
+
private validateSession;
|
|
103
|
+
close(): Promise<void>;
|
|
104
|
+
send(message: JSONRPCMessage, options?: TransportSendOptions): Promise<void>;
|
|
105
|
+
}
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region src/mcp/auth-context.d.ts
|
|
108
|
+
interface McpAuthContext {
|
|
109
|
+
props: Record<string, unknown>;
|
|
110
|
+
}
|
|
111
|
+
declare function getMcpAuthContext(): McpAuthContext | undefined;
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region src/mcp/handler.d.ts
|
|
114
|
+
interface CreateMcpHandlerOptions extends WorkerTransportOptions {
|
|
115
|
+
/**
|
|
116
|
+
* The route path that this MCP handler should respond to.
|
|
117
|
+
* If specified, the handler will only process requests that match this route.
|
|
118
|
+
* @default "/mcp"
|
|
119
|
+
*/
|
|
120
|
+
route?: string;
|
|
121
|
+
/**
|
|
122
|
+
* An optional auth context to use for handling MCP requests.
|
|
123
|
+
* If not provided, the handler will look for props in the execution context.
|
|
124
|
+
*/
|
|
125
|
+
authContext?: McpAuthContext;
|
|
126
|
+
/**
|
|
127
|
+
* An optional transport to use for handling MCP requests.
|
|
128
|
+
* If not provided, a WorkerTransport will be created with the provided WorkerTransportOptions.
|
|
129
|
+
*/
|
|
130
|
+
transport?: WorkerTransport;
|
|
131
|
+
}
|
|
132
|
+
declare function createMcpHandler(server: McpServer | Server, options?: CreateMcpHandlerOptions): (request: Request, env: unknown, ctx: ExecutionContext) => Promise<Response>;
|
|
133
|
+
/**
|
|
134
|
+
* @deprecated This has been renamed to createMcpHandler, and experimental_createMcpHandler will be removed in the next major version
|
|
135
|
+
*/
|
|
136
|
+
declare function experimental_createMcpHandler(server: McpServer | Server, options?: CreateMcpHandlerOptions): (request: Request, env: unknown, ctx: ExecutionContext) => Promise<Response>;
|
|
137
|
+
//#endregion
|
|
11
138
|
//#region src/mcp/index.d.ts
|
|
12
|
-
declare abstract class McpAgent<Env =
|
|
139
|
+
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> {
|
|
13
140
|
private _transport?;
|
|
14
141
|
props?: Props;
|
|
15
142
|
abstract server: MaybePromise<McpServer | Server>;
|
|
@@ -27,7 +154,7 @@ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Re
|
|
|
27
154
|
*/
|
|
28
155
|
getSessionId(): string;
|
|
29
156
|
/** Get the unique WebSocket. SSE transport only. */
|
|
30
|
-
|
|
157
|
+
getWebSocket(): Connection<unknown> | null;
|
|
31
158
|
/** Returns a new transport matching the type of the Agent. */
|
|
32
159
|
private initTransport;
|
|
33
160
|
/** Update and store the props */
|
|
@@ -40,7 +167,7 @@ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Re
|
|
|
40
167
|
request: req
|
|
41
168
|
}: ConnectionContext): Promise<void>;
|
|
42
169
|
/** Handles MCP Messages for the legacy SSE transport. */
|
|
43
|
-
onSSEMcpMessage(_sessionId: string, messageBody: unknown): Promise<Error | null>;
|
|
170
|
+
onSSEMcpMessage(_sessionId: string, messageBody: unknown, extraInfo?: MessageExtraInfo): Promise<Error | null>;
|
|
44
171
|
/** Elicit user input with a message and schema */
|
|
45
172
|
elicitInput(params: {
|
|
46
173
|
message: string;
|
|
@@ -56,7 +183,8 @@ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Re
|
|
|
56
183
|
static serve(path: string, {
|
|
57
184
|
binding,
|
|
58
185
|
corsOptions,
|
|
59
|
-
transport
|
|
186
|
+
transport,
|
|
187
|
+
jurisdiction
|
|
60
188
|
}?: ServeOptions): {
|
|
61
189
|
fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
|
|
62
190
|
};
|
|
@@ -71,5 +199,5 @@ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Re
|
|
|
71
199
|
};
|
|
72
200
|
}
|
|
73
201
|
//#endregion
|
|
74
|
-
export { type ElicitRequest, ElicitRequestSchema, type ElicitResult, type MCPClientOAuthCallbackConfig, type MCPClientOAuthResult, McpAgent, SSEEdgeClientTransport, StreamableHTTPEdgeClientTransport };
|
|
202
|
+
export { type CreateMcpHandlerOptions, type ElicitRequest, ElicitRequestSchema, type ElicitResult, type MCPClientOAuthCallbackConfig, type MCPClientOAuthResult, type MCPConnectionResult, type MCPDiscoverResult, type MCPServerOptions, McpAgent, type McpAuthContext, SSEEdgeClientTransport, StreamableHTTPEdgeClientTransport, type TransportState, WorkerTransport, type WorkerTransportOptions, createMcpHandler, experimental_createMcpHandler, getMcpAuthContext };
|
|
75
203
|
//# sourceMappingURL=index.d.ts.map
|