agents 0.0.0-d4257c1 → 0.0.0-d6d6d60
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/dist/ai-chat-agent.d.ts +10 -10
- package/dist/ai-chat-agent.js +6 -6
- package/dist/ai-chat-agent.js.map +1 -1
- package/dist/{ai-chat-v5-migration-gdyLiTd8.js → ai-chat-v5-migration-DBHGW4Hv.js} +2 -2
- package/dist/{ai-chat-v5-migration-gdyLiTd8.js.map → ai-chat-v5-migration-DBHGW4Hv.js.map} +1 -1
- package/dist/ai-chat-v5-migration.js +1 -1
- package/dist/ai-react.d.ts +9 -9
- package/dist/ai-react.js +17 -11
- package/dist/ai-react.js.map +1 -1
- package/dist/{ai-types-UZlfLOYP.js → ai-types-B3aQaFv3.js} +2 -2
- package/dist/{ai-types-UZlfLOYP.js.map → ai-types-B3aQaFv3.js.map} +1 -1
- package/dist/{ai-types-BWW4umHY.d.ts → ai-types-D5YoPrBZ.d.ts} +2 -2
- package/dist/ai-types.d.ts +4 -4
- package/dist/ai-types.js +1 -1
- package/dist/cli.d.ts +8 -0
- package/dist/cli.js +27 -0
- package/dist/cli.js.map +1 -0
- package/dist/{client-DjR-lC16.js → client-BfiZ3HQd.js} +3 -3
- package/dist/{client-DjR-lC16.js.map → client-BfiZ3HQd.js.map} +1 -1
- package/dist/{client-C-nwz-3N.d.ts → client-Bws9q38u.d.ts} +189 -75
- package/dist/{client-CmMi85Sj.d.ts → client-CbWe9FBd.d.ts} +10 -10
- package/dist/{client-CZBVDDoO.js → client-DvK0u9vD.js} +236 -124
- package/dist/client-DvK0u9vD.js.map +1 -0
- package/dist/client.d.ts +8 -8
- package/dist/client.js +2 -2
- package/dist/codemode/ai.js +5 -5
- package/dist/do-oauth-client-provider-CcTno-25.d.ts +142 -0
- package/dist/{do-oauth-client-provider-B2jr6UNq.js → do-oauth-client-provider-D2P1lSft.js} +3 -3
- package/dist/do-oauth-client-provider-D2P1lSft.js.map +1 -0
- package/dist/{index-CkQU40oY.d.ts → index-Bdzb2feZ.d.ts} +53 -39
- package/dist/{index-W4JUkafc.d.ts → index-DhJCaDWd.d.ts} +7 -3
- package/dist/index.d.ts +36 -36
- package/dist/index.js +5 -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 +127 -9
- package/dist/mcp/index.js +619 -26
- package/dist/mcp/index.js.map +1 -1
- package/dist/{mcp-BEwaCsxO.d.ts → mcp-Dw5vDrY8.d.ts} +2 -2
- package/dist/observability/index.d.ts +2 -2
- package/dist/observability/index.js +5 -5
- package/dist/{react-B4e1rDid.d.ts → react-DFNXTQzy.d.ts} +17 -17
- package/dist/react.d.ts +9 -9
- package/dist/react.js +1 -1
- package/dist/{serializable-gtr9YMhp.d.ts → serializable-CymX8ovI.d.ts} +8 -3
- package/dist/serializable.d.ts +5 -5
- package/dist/{src-COfG--3R.js → src-C1WWpbRo.js} +189 -121
- package/dist/src-C1WWpbRo.js.map +1 -0
- package/package.json +54 -39
- package/dist/client-CZBVDDoO.js.map +0 -1
- package/dist/do-oauth-client-provider-B2jr6UNq.js.map +0 -1
- package/dist/do-oauth-client-provider-CCwGwnrA.d.ts +0 -55
- package/dist/src-COfG--3R.js.map +0 -1
- package/src/index.ts +0 -2031
package/dist/client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./ai-types-
|
|
2
|
-
import {
|
|
1
|
+
import "./ai-types-B3aQaFv3.js";
|
|
2
|
+
import { n as agentFetch, r as camelCaseToKebabCase, t as AgentClient } from "./client-BfiZ3HQd.js";
|
|
3
3
|
|
|
4
4
|
export { AgentClient, agentFetch, camelCaseToKebabCase };
|
package/dist/codemode/ai.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import "../ai-types-
|
|
2
|
-
import "../client-
|
|
3
|
-
import "../client-
|
|
4
|
-
import "../do-oauth-client-provider-
|
|
5
|
-
import { getAgentByName } from "../src-
|
|
1
|
+
import "../ai-types-B3aQaFv3.js";
|
|
2
|
+
import "../client-BfiZ3HQd.js";
|
|
3
|
+
import "../client-DvK0u9vD.js";
|
|
4
|
+
import "../do-oauth-client-provider-D2P1lSft.js";
|
|
5
|
+
import { s as getAgentByName } from "../src-C1WWpbRo.js";
|
|
6
6
|
import { generateObject, tool } from "ai";
|
|
7
7
|
import { openai } from "@ai-sdk/openai";
|
|
8
8
|
import { z } from "zod/v3";
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { OAuthClientProvider } from "@modelcontextprotocol/sdk/client/auth.js";
|
|
2
|
+
import {
|
|
3
|
+
OAuthClientInformationFull,
|
|
4
|
+
OAuthClientMetadata,
|
|
5
|
+
OAuthTokens
|
|
6
|
+
} from "@modelcontextprotocol/sdk/shared/auth.js";
|
|
7
|
+
|
|
8
|
+
//#region src/mcp/client-storage.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* Represents a row in the cf_agents_mcp_servers table
|
|
11
|
+
*/
|
|
12
|
+
type MCPServerRow = {
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
server_url: string;
|
|
16
|
+
client_id: string | null;
|
|
17
|
+
auth_url: string | null;
|
|
18
|
+
callback_url: string;
|
|
19
|
+
server_options: string | null;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* KV storage interface for OAuth-related data
|
|
23
|
+
* Used by OAuth providers to store tokens, client info, etc.
|
|
24
|
+
*/
|
|
25
|
+
interface OAuthClientStorage {
|
|
26
|
+
/**
|
|
27
|
+
* Get a value from key-value storage (for OAuth data like tokens, client info, etc.)
|
|
28
|
+
*/
|
|
29
|
+
get<T>(key: string): Promise<T | undefined> | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Put a value into key-value storage (for OAuth data like tokens, client info, etc.)
|
|
32
|
+
*/
|
|
33
|
+
put(key: string, value: unknown): Promise<void> | void;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Storage interface for MCP client manager
|
|
37
|
+
* Abstracts storage operations to decouple from specific storage implementations
|
|
38
|
+
*/
|
|
39
|
+
interface MCPClientStorage extends OAuthClientStorage {
|
|
40
|
+
/**
|
|
41
|
+
* Create the cf_agents_mcp_servers table if it doesn't exist
|
|
42
|
+
*/
|
|
43
|
+
create(): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Drop the cf_agents_mcp_servers table
|
|
46
|
+
*/
|
|
47
|
+
destroy(): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Save or update an MCP server configuration
|
|
50
|
+
*/
|
|
51
|
+
saveServer(server: MCPServerRow): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Remove an MCP server from storage
|
|
54
|
+
*/
|
|
55
|
+
removeServer(serverId: string): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* List all MCP servers from storage
|
|
58
|
+
*/
|
|
59
|
+
listServers(): Promise<MCPServerRow[]>;
|
|
60
|
+
/**
|
|
61
|
+
* Get an MCP server by its callback URL
|
|
62
|
+
* Used during OAuth callback to identify which server is being authenticated
|
|
63
|
+
*/
|
|
64
|
+
getServerByCallbackUrl(callbackUrl: string): Promise<MCPServerRow | null>;
|
|
65
|
+
/**
|
|
66
|
+
* Clear auth_url after successful OAuth authentication
|
|
67
|
+
* This prevents the agent from continuously asking for OAuth on reconnect
|
|
68
|
+
* when stored tokens are still valid.
|
|
69
|
+
*/
|
|
70
|
+
clearAuthUrl(serverId: string): Promise<void>;
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/mcp/do-oauth-client-provider.d.ts
|
|
74
|
+
interface AgentsOAuthProvider extends OAuthClientProvider {
|
|
75
|
+
authUrl: string | undefined;
|
|
76
|
+
clientId: string | undefined;
|
|
77
|
+
serverId: string | undefined;
|
|
78
|
+
}
|
|
79
|
+
declare class DurableObjectOAuthClientProvider implements AgentsOAuthProvider {
|
|
80
|
+
storage: OAuthClientStorage;
|
|
81
|
+
clientName: string;
|
|
82
|
+
baseRedirectUrl: string;
|
|
83
|
+
private _authUrl_;
|
|
84
|
+
private _serverId_;
|
|
85
|
+
private _clientId_;
|
|
86
|
+
constructor(
|
|
87
|
+
storage: OAuthClientStorage,
|
|
88
|
+
clientName: string,
|
|
89
|
+
baseRedirectUrl: string
|
|
90
|
+
);
|
|
91
|
+
get clientMetadata(): OAuthClientMetadata;
|
|
92
|
+
get clientUri(): string;
|
|
93
|
+
get redirectUrl(): string;
|
|
94
|
+
get clientId(): string;
|
|
95
|
+
set clientId(clientId_: string);
|
|
96
|
+
get serverId(): string;
|
|
97
|
+
set serverId(serverId_: string);
|
|
98
|
+
keyPrefix(clientId: string): string;
|
|
99
|
+
clientInfoKey(clientId: string): string;
|
|
100
|
+
clientInformation(): Promise<
|
|
101
|
+
| {
|
|
102
|
+
client_id: string;
|
|
103
|
+
client_secret?: string | undefined;
|
|
104
|
+
client_id_issued_at?: number | undefined;
|
|
105
|
+
client_secret_expires_at?: number | undefined;
|
|
106
|
+
}
|
|
107
|
+
| undefined
|
|
108
|
+
>;
|
|
109
|
+
saveClientInformation(
|
|
110
|
+
clientInformation: OAuthClientInformationFull
|
|
111
|
+
): Promise<void>;
|
|
112
|
+
tokenKey(clientId: string): string;
|
|
113
|
+
tokens(): Promise<
|
|
114
|
+
| {
|
|
115
|
+
access_token: string;
|
|
116
|
+
token_type: string;
|
|
117
|
+
id_token?: string | undefined;
|
|
118
|
+
expires_in?: number | undefined;
|
|
119
|
+
scope?: string | undefined;
|
|
120
|
+
refresh_token?: string | undefined;
|
|
121
|
+
}
|
|
122
|
+
| undefined
|
|
123
|
+
>;
|
|
124
|
+
saveTokens(tokens: OAuthTokens): Promise<void>;
|
|
125
|
+
get authUrl(): string | undefined;
|
|
126
|
+
/**
|
|
127
|
+
* Because this operates on the server side (but we need browser auth), we send this url back to the user
|
|
128
|
+
* and require user interact to initiate the redirect flow
|
|
129
|
+
*/
|
|
130
|
+
redirectToAuthorization(authUrl: URL): void;
|
|
131
|
+
codeVerifierKey(clientId: string): string;
|
|
132
|
+
saveCodeVerifier(verifier: string): Promise<void>;
|
|
133
|
+
codeVerifier(): Promise<string>;
|
|
134
|
+
}
|
|
135
|
+
//#endregion
|
|
136
|
+
export {
|
|
137
|
+
MCPServerRow as i,
|
|
138
|
+
DurableObjectOAuthClientProvider as n,
|
|
139
|
+
MCPClientStorage as r,
|
|
140
|
+
AgentsOAuthProvider as t
|
|
141
|
+
};
|
|
142
|
+
//# sourceMappingURL=do-oauth-client-provider-CcTno-25.d.ts.map
|
|
@@ -68,7 +68,7 @@ var DurableObjectOAuthClientProvider = class {
|
|
|
68
68
|
* Because this operates on the server side (but we need browser auth), we send this url back to the user
|
|
69
69
|
* and require user interact to initiate the redirect flow
|
|
70
70
|
*/
|
|
71
|
-
|
|
71
|
+
redirectToAuthorization(authUrl) {
|
|
72
72
|
const stateToken = nanoid();
|
|
73
73
|
authUrl.searchParams.set("state", stateToken);
|
|
74
74
|
this._authUrl_ = authUrl.toString();
|
|
@@ -89,5 +89,5 @@ var DurableObjectOAuthClientProvider = class {
|
|
|
89
89
|
};
|
|
90
90
|
|
|
91
91
|
//#endregion
|
|
92
|
-
export { DurableObjectOAuthClientProvider };
|
|
93
|
-
//# sourceMappingURL=do-oauth-client-provider-
|
|
92
|
+
export { DurableObjectOAuthClientProvider as t };
|
|
93
|
+
//# sourceMappingURL=do-oauth-client-provider-D2P1lSft.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"do-oauth-client-provider-D2P1lSft.js","names":["storage: OAuthClientStorage","clientName: string","baseRedirectUrl: string"],"sources":["../src/mcp/do-oauth-client-provider.ts"],"sourcesContent":["import type { OAuthClientProvider } from \"@modelcontextprotocol/sdk/client/auth.js\";\nimport type {\n OAuthClientInformation,\n OAuthClientInformationFull,\n OAuthClientMetadata,\n OAuthTokens\n} from \"@modelcontextprotocol/sdk/shared/auth.js\";\nimport { nanoid } from \"nanoid\";\nimport type { OAuthClientStorage } from \"./client-storage\";\n\n// A slight extension to the standard OAuthClientProvider interface because `redirectToAuthorization` doesn't give us the interface we need\n// This allows us to track authentication for a specific server and associated dynamic client registration\nexport interface AgentsOAuthProvider extends OAuthClientProvider {\n authUrl: string | undefined;\n clientId: string | undefined;\n serverId: string | undefined;\n}\n\nexport class DurableObjectOAuthClientProvider implements AgentsOAuthProvider {\n private _authUrl_: string | undefined;\n private _serverId_: string | undefined;\n private _clientId_: string | undefined;\n\n constructor(\n public storage: OAuthClientStorage,\n public clientName: string,\n public baseRedirectUrl: string\n ) {}\n\n get clientMetadata(): OAuthClientMetadata {\n return {\n client_name: this.clientName,\n client_uri: this.clientUri,\n grant_types: [\"authorization_code\", \"refresh_token\"],\n redirect_uris: [this.redirectUrl],\n response_types: [\"code\"],\n token_endpoint_auth_method: \"none\"\n };\n }\n\n get clientUri() {\n return new URL(this.redirectUrl).origin;\n }\n\n get redirectUrl() {\n return `${this.baseRedirectUrl}/${this.serverId}`;\n }\n\n get clientId() {\n if (!this._clientId_) {\n throw new Error(\"Trying to access clientId before it was set\");\n }\n return this._clientId_;\n }\n\n set clientId(clientId_: string) {\n this._clientId_ = clientId_;\n }\n\n get serverId() {\n if (!this._serverId_) {\n throw new Error(\"Trying to access serverId before it was set\");\n }\n return this._serverId_;\n }\n\n set serverId(serverId_: string) {\n this._serverId_ = serverId_;\n }\n\n keyPrefix(clientId: string) {\n return `/${this.clientName}/${this.serverId}/${clientId}`;\n }\n\n clientInfoKey(clientId: string) {\n return `${this.keyPrefix(clientId)}/client_info/`;\n }\n\n async clientInformation() {\n if (!this._clientId_) {\n return undefined;\n }\n return (\n (await this.storage.get<OAuthClientInformation>(\n this.clientInfoKey(this.clientId)\n )) ?? undefined\n );\n }\n\n async saveClientInformation(clientInformation: OAuthClientInformationFull) {\n await this.storage.put(\n this.clientInfoKey(clientInformation.client_id),\n clientInformation\n );\n this.clientId = clientInformation.client_id;\n }\n\n tokenKey(clientId: string) {\n return `${this.keyPrefix(clientId)}/token`;\n }\n\n async tokens() {\n if (!this._clientId_) {\n return undefined;\n }\n return (\n (await this.storage.get<OAuthTokens>(this.tokenKey(this.clientId))) ??\n undefined\n );\n }\n\n async saveTokens(tokens: OAuthTokens) {\n await this.storage.put(this.tokenKey(this.clientId), tokens);\n }\n\n get authUrl() {\n return this._authUrl_;\n }\n\n /**\n * Because this operates on the server side (but we need browser auth), we send this url back to the user\n * and require user interact to initiate the redirect flow\n */\n redirectToAuthorization(authUrl: URL) {\n // Generate secure random token for state parameter\n const stateToken = nanoid();\n authUrl.searchParams.set(\"state\", stateToken);\n this._authUrl_ = authUrl.toString();\n }\n\n codeVerifierKey(clientId: string) {\n return `${this.keyPrefix(clientId)}/code_verifier`;\n }\n\n async saveCodeVerifier(verifier: string) {\n const key = this.codeVerifierKey(this.clientId);\n\n // Don't overwrite existing verifier to preserve first PKCE verifier\n const existing = await this.storage.get<string>(key);\n if (existing) {\n return;\n }\n\n await this.storage.put(key, verifier);\n }\n\n async codeVerifier() {\n const codeVerifier = await this.storage.get<string>(\n this.codeVerifierKey(this.clientId)\n );\n if (!codeVerifier) {\n throw new Error(\"No code verifier found\");\n }\n return codeVerifier;\n }\n}\n"],"mappings":";;;AAkBA,IAAa,mCAAb,MAA6E;CAK3E,YACE,AAAOA,SACP,AAAOC,YACP,AAAOC,iBACP;EAHO;EACA;EACA;;CAGT,IAAI,iBAAsC;AACxC,SAAO;GACL,aAAa,KAAK;GAClB,YAAY,KAAK;GACjB,aAAa,CAAC,sBAAsB,gBAAgB;GACpD,eAAe,CAAC,KAAK,YAAY;GACjC,gBAAgB,CAAC,OAAO;GACxB,4BAA4B;GAC7B;;CAGH,IAAI,YAAY;AACd,SAAO,IAAI,IAAI,KAAK,YAAY,CAAC;;CAGnC,IAAI,cAAc;AAChB,SAAO,GAAG,KAAK,gBAAgB,GAAG,KAAK;;CAGzC,IAAI,WAAW;AACb,MAAI,CAAC,KAAK,WACR,OAAM,IAAI,MAAM,8CAA8C;AAEhE,SAAO,KAAK;;CAGd,IAAI,SAAS,WAAmB;AAC9B,OAAK,aAAa;;CAGpB,IAAI,WAAW;AACb,MAAI,CAAC,KAAK,WACR,OAAM,IAAI,MAAM,8CAA8C;AAEhE,SAAO,KAAK;;CAGd,IAAI,SAAS,WAAmB;AAC9B,OAAK,aAAa;;CAGpB,UAAU,UAAkB;AAC1B,SAAO,IAAI,KAAK,WAAW,GAAG,KAAK,SAAS,GAAG;;CAGjD,cAAc,UAAkB;AAC9B,SAAO,GAAG,KAAK,UAAU,SAAS,CAAC;;CAGrC,MAAM,oBAAoB;AACxB,MAAI,CAAC,KAAK,WACR;AAEF,SACG,MAAM,KAAK,QAAQ,IAClB,KAAK,cAAc,KAAK,SAAS,CAClC,IAAK;;CAIV,MAAM,sBAAsB,mBAA+C;AACzE,QAAM,KAAK,QAAQ,IACjB,KAAK,cAAc,kBAAkB,UAAU,EAC/C,kBACD;AACD,OAAK,WAAW,kBAAkB;;CAGpC,SAAS,UAAkB;AACzB,SAAO,GAAG,KAAK,UAAU,SAAS,CAAC;;CAGrC,MAAM,SAAS;AACb,MAAI,CAAC,KAAK,WACR;AAEF,SACG,MAAM,KAAK,QAAQ,IAAiB,KAAK,SAAS,KAAK,SAAS,CAAC,IAClE;;CAIJ,MAAM,WAAW,QAAqB;AACpC,QAAM,KAAK,QAAQ,IAAI,KAAK,SAAS,KAAK,SAAS,EAAE,OAAO;;CAG9D,IAAI,UAAU;AACZ,SAAO,KAAK;;;;;;CAOd,wBAAwB,SAAc;EAEpC,MAAM,aAAa,QAAQ;AAC3B,UAAQ,aAAa,IAAI,SAAS,WAAW;AAC7C,OAAK,YAAY,QAAQ,UAAU;;CAGrC,gBAAgB,UAAkB;AAChC,SAAO,GAAG,KAAK,UAAU,SAAS,CAAC;;CAGrC,MAAM,iBAAiB,UAAkB;EACvC,MAAM,MAAM,KAAK,gBAAgB,KAAK,SAAS;AAI/C,MADiB,MAAM,KAAK,QAAQ,IAAY,IAAI,CAElD;AAGF,QAAM,KAAK,QAAQ,IAAI,KAAK,SAAS;;CAGvC,MAAM,eAAe;EACnB,MAAM,eAAe,MAAM,KAAK,QAAQ,IACtC,KAAK,gBAAgB,KAAK,SAAS,CACpC;AACD,MAAI,CAAC,aACH,OAAM,IAAI,MAAM,yBAAyB;AAE3C,SAAO"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from "./client-
|
|
6
|
-
import { Observability } from "./index-
|
|
7
|
-
import { MessageType } from "./ai-types-
|
|
2
|
+
l as MCPConnectionState,
|
|
3
|
+
m as TransportType,
|
|
4
|
+
t as MCPClientManager
|
|
5
|
+
} from "./client-Bws9q38u.js";
|
|
6
|
+
import { t as Observability } from "./index-DhJCaDWd.js";
|
|
7
|
+
import { n as MessageType } from "./ai-types-D5YoPrBZ.js";
|
|
8
8
|
import {
|
|
9
9
|
Connection,
|
|
10
10
|
Connection as Connection$1,
|
|
@@ -171,6 +171,7 @@ declare class Agent<
|
|
|
171
171
|
> extends Server<Env, Props> {
|
|
172
172
|
private _state;
|
|
173
173
|
private _disposables;
|
|
174
|
+
private _destroyed;
|
|
174
175
|
private _ParentClass;
|
|
175
176
|
readonly mcp: MCPClientManager;
|
|
176
177
|
/**
|
|
@@ -372,10 +373,23 @@ declare class Agent<
|
|
|
372
373
|
id: string;
|
|
373
374
|
authUrl: string | undefined;
|
|
374
375
|
}>;
|
|
375
|
-
private _connectToMcpServerInternal;
|
|
376
376
|
removeMcpServer(id: string): Promise<void>;
|
|
377
|
-
getMcpServers(): MCPServersState
|
|
377
|
+
getMcpServers(): Promise<MCPServersState>;
|
|
378
378
|
private broadcastMcpServers;
|
|
379
|
+
/**
|
|
380
|
+
* Handle MCP OAuth callback request if it's an OAuth callback.
|
|
381
|
+
*
|
|
382
|
+
* This method encapsulates the entire OAuth callback flow:
|
|
383
|
+
* 1. Checks if the request is an MCP OAuth callback
|
|
384
|
+
* 2. Processes the OAuth code exchange
|
|
385
|
+
* 3. Establishes the connection if successful
|
|
386
|
+
* 4. Broadcasts MCP server state updates
|
|
387
|
+
* 5. Returns the appropriate HTTP response
|
|
388
|
+
*
|
|
389
|
+
* @param request The incoming HTTP request
|
|
390
|
+
* @returns Response if this was an OAuth callback, null otherwise
|
|
391
|
+
*/
|
|
392
|
+
private handleMcpOAuthCallback;
|
|
379
393
|
/**
|
|
380
394
|
* Handle OAuth callback response using MCPClientManager configuration
|
|
381
395
|
* @param result OAuth callback result
|
|
@@ -524,35 +538,35 @@ declare class StreamingResponse {
|
|
|
524
538
|
}
|
|
525
539
|
//#endregion
|
|
526
540
|
export {
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
QueueItem,
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
541
|
+
unstable_callable as A,
|
|
542
|
+
createAddressBasedEmailResolver as C,
|
|
543
|
+
getCurrentAgent as D,
|
|
544
|
+
getAgentByName as E,
|
|
545
|
+
routeAgentEmail as O,
|
|
546
|
+
callable as S,
|
|
547
|
+
createHeaderBasedEmailResolver as T,
|
|
548
|
+
RPCResponse as _,
|
|
549
|
+
AgentOptions as a,
|
|
550
|
+
StreamingResponse as b,
|
|
551
|
+
ConnectionContext as c,
|
|
552
|
+
EmailSendOptions as d,
|
|
553
|
+
MCPServer as f,
|
|
554
|
+
RPCRequest as g,
|
|
555
|
+
QueueItem as h,
|
|
556
|
+
AgentNamespace as i,
|
|
557
|
+
routeAgentRequest as k,
|
|
558
|
+
EmailResolver as l,
|
|
559
|
+
MCPServersState as m,
|
|
560
|
+
AgentContext as n,
|
|
561
|
+
CallableMetadata as o,
|
|
562
|
+
MCPServerMessage as p,
|
|
563
|
+
AgentEmail as r,
|
|
564
|
+
Connection$1 as s,
|
|
565
|
+
Agent as t,
|
|
566
|
+
EmailRoutingOptions as u,
|
|
567
|
+
Schedule as v,
|
|
568
|
+
createCatchAllEmailResolver as w,
|
|
569
|
+
WSMessage as x,
|
|
570
|
+
StateUpdateMessage as y
|
|
557
571
|
};
|
|
558
|
-
//# sourceMappingURL=index-
|
|
572
|
+
//# sourceMappingURL=index-Bdzb2feZ.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseEvent, MCPObservabilityEvent } from "./mcp-
|
|
1
|
+
import { n as BaseEvent, t as MCPObservabilityEvent } from "./mcp-Dw5vDrY8.js";
|
|
2
2
|
|
|
3
3
|
//#region src/observability/agent.d.ts
|
|
4
4
|
|
|
@@ -50,5 +50,9 @@ interface Observability {
|
|
|
50
50
|
*/
|
|
51
51
|
declare const genericObservability: Observability;
|
|
52
52
|
//#endregion
|
|
53
|
-
export {
|
|
54
|
-
|
|
53
|
+
export {
|
|
54
|
+
ObservabilityEvent as n,
|
|
55
|
+
genericObservability as r,
|
|
56
|
+
Observability as t
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=index-DhJCaDWd.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import { TransportType } from "./client-
|
|
2
|
-
import "./mcp-
|
|
3
|
-
import "./do-oauth-client-provider-
|
|
4
|
-
import "./index-
|
|
5
|
-
import "./ai-types-
|
|
1
|
+
import { m as TransportType } from "./client-Bws9q38u.js";
|
|
2
|
+
import "./mcp-Dw5vDrY8.js";
|
|
3
|
+
import "./do-oauth-client-provider-CcTno-25.js";
|
|
4
|
+
import "./index-DhJCaDWd.js";
|
|
5
|
+
import "./ai-types-D5YoPrBZ.js";
|
|
6
6
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
QueueItem,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
} from "./index-
|
|
7
|
+
A as unstable_callable,
|
|
8
|
+
C as createAddressBasedEmailResolver,
|
|
9
|
+
D as getCurrentAgent,
|
|
10
|
+
E as getAgentByName,
|
|
11
|
+
O as routeAgentEmail,
|
|
12
|
+
S as callable,
|
|
13
|
+
T as createHeaderBasedEmailResolver,
|
|
14
|
+
_ as RPCResponse,
|
|
15
|
+
a as AgentOptions,
|
|
16
|
+
b as StreamingResponse,
|
|
17
|
+
c as ConnectionContext,
|
|
18
|
+
d as EmailSendOptions,
|
|
19
|
+
f as MCPServer,
|
|
20
|
+
g as RPCRequest,
|
|
21
|
+
h as QueueItem,
|
|
22
|
+
i as AgentNamespace,
|
|
23
|
+
k as routeAgentRequest,
|
|
24
|
+
l as EmailResolver,
|
|
25
|
+
m as MCPServersState,
|
|
26
|
+
n as AgentContext,
|
|
27
|
+
o as CallableMetadata,
|
|
28
|
+
p as MCPServerMessage,
|
|
29
|
+
r as AgentEmail,
|
|
30
|
+
s as Connection,
|
|
31
|
+
t as Agent,
|
|
32
|
+
u as EmailRoutingOptions,
|
|
33
|
+
v as Schedule,
|
|
34
|
+
w as createCatchAllEmailResolver,
|
|
35
|
+
x as WSMessage,
|
|
36
|
+
y as StateUpdateMessage
|
|
37
|
+
} from "./index-Bdzb2feZ.js";
|
|
38
38
|
export {
|
|
39
39
|
Agent,
|
|
40
40
|
AgentContext,
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "./ai-types-
|
|
2
|
-
import "./client-
|
|
3
|
-
import "./client-
|
|
4
|
-
import "./do-oauth-client-provider-
|
|
5
|
-
import {
|
|
1
|
+
import "./ai-types-B3aQaFv3.js";
|
|
2
|
+
import "./client-BfiZ3HQd.js";
|
|
3
|
+
import "./client-DvK0u9vD.js";
|
|
4
|
+
import "./do-oauth-client-provider-D2P1lSft.js";
|
|
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-C1WWpbRo.js";
|
|
6
6
|
|
|
7
7
|
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 getNamespacedData, i as MCPClientOAuthResult, n as MCPClientManagerOptions, o as MCPServerOptions, r as MCPClientOAuthCallbackConfig, s as RegisterServerOptions, t as MCPClientManager } from "../client-Bws9q38u.js";
|
|
2
|
+
import "../mcp-Dw5vDrY8.js";
|
|
3
|
+
import "../do-oauth-client-provider-CcTno-25.js";
|
|
4
|
+
export { MCPClientManager, MCPClientManagerOptions, MCPClientOAuthCallbackConfig, MCPClientOAuthResult, MCPConnectionResult, 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-CcTno-25.js";
|
|
2
2
|
export { AgentsOAuthProvider, DurableObjectOAuthClientProvider };
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -1,13 +1,130 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../mcp-
|
|
3
|
-
import "../do-oauth-client-provider-
|
|
4
|
-
import "../index-
|
|
5
|
-
import "../ai-types-
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
1
|
+
import { a as MCPConnectionResult, d as CORSOptions, f as MaybePromise, i as MCPClientOAuthResult, o as MCPServerOptions, p as ServeOptions, r as MCPClientOAuthCallbackConfig, u as BaseTransportType } from "../client-Bws9q38u.js";
|
|
2
|
+
import "../mcp-Dw5vDrY8.js";
|
|
3
|
+
import "../do-oauth-client-provider-CcTno-25.js";
|
|
4
|
+
import "../index-DhJCaDWd.js";
|
|
5
|
+
import "../ai-types-D5YoPrBZ.js";
|
|
6
|
+
import { c as ConnectionContext, s as Connection, t as Agent } from "../index-Bdzb2feZ.js";
|
|
7
|
+
import { SSEClientTransport, SSEClientTransportOptions } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
8
|
+
import { StreamableHTTPClientTransport, StreamableHTTPClientTransportOptions } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
9
|
+
import { ElicitRequest, ElicitRequestSchema, ElicitResult, ElicitResult as ElicitResult$1, JSONRPCMessage, MessageExtraInfo } from "@modelcontextprotocol/sdk/types.js";
|
|
8
10
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
9
11
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
12
|
+
import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
|
|
10
13
|
|
|
14
|
+
//#region src/mcp/client-transports.d.ts
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated Use SSEClientTransport from @modelcontextprotocol/sdk/client/sse.js instead. This alias will be removed in the next major version.
|
|
17
|
+
*/
|
|
18
|
+
declare class SSEEdgeClientTransport extends SSEClientTransport {
|
|
19
|
+
constructor(url: URL, options: SSEClientTransportOptions);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated Use StreamableHTTPClientTransport from @modelcontextprotocol/sdk/client/streamableHttp.js instead. This alias will be removed in the next major version.
|
|
23
|
+
*/
|
|
24
|
+
declare class StreamableHTTPEdgeClientTransport extends StreamableHTTPClientTransport {
|
|
25
|
+
constructor(url: URL, options: StreamableHTTPClientTransportOptions);
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/mcp/worker-transport.d.ts
|
|
29
|
+
declare const SUPPORTED_PROTOCOL_VERSIONS: readonly ["2025-03-26", "2025-06-18"];
|
|
30
|
+
type ProtocolVersion = (typeof SUPPORTED_PROTOCOL_VERSIONS)[number];
|
|
31
|
+
interface MCPStorageApi {
|
|
32
|
+
get(): Promise<TransportState | undefined> | TransportState | undefined;
|
|
33
|
+
set(state: TransportState): Promise<void> | void;
|
|
34
|
+
}
|
|
35
|
+
interface TransportState {
|
|
36
|
+
sessionId?: string;
|
|
37
|
+
initialized: boolean;
|
|
38
|
+
protocolVersion?: ProtocolVersion;
|
|
39
|
+
}
|
|
40
|
+
interface WorkerTransportOptions {
|
|
41
|
+
sessionIdGenerator?: () => string;
|
|
42
|
+
/**
|
|
43
|
+
* Enable traditional Request/Response mode, this will disable streaming.
|
|
44
|
+
*/
|
|
45
|
+
enableJsonResponse?: boolean;
|
|
46
|
+
onsessioninitialized?: (sessionId: string) => void;
|
|
47
|
+
corsOptions?: CORSOptions;
|
|
48
|
+
/**
|
|
49
|
+
* Optional storage api for persisting transport state.
|
|
50
|
+
* Use this to store session state in Durable Object/Agent storage
|
|
51
|
+
* so it survives hibernation/restart.
|
|
52
|
+
*/
|
|
53
|
+
storage?: MCPStorageApi;
|
|
54
|
+
}
|
|
55
|
+
declare class WorkerTransport implements Transport {
|
|
56
|
+
started: boolean;
|
|
57
|
+
private initialized;
|
|
58
|
+
private sessionIdGenerator?;
|
|
59
|
+
private enableJsonResponse;
|
|
60
|
+
private onsessioninitialized?;
|
|
61
|
+
private standaloneSseStreamId;
|
|
62
|
+
private streamMapping;
|
|
63
|
+
private requestToStreamMapping;
|
|
64
|
+
private requestResponseMap;
|
|
65
|
+
private corsOptions?;
|
|
66
|
+
private protocolVersion?;
|
|
67
|
+
private storage?;
|
|
68
|
+
private stateRestored;
|
|
69
|
+
sessionId?: string;
|
|
70
|
+
onclose?: () => void;
|
|
71
|
+
onerror?: (error: Error) => void;
|
|
72
|
+
onmessage?: (message: JSONRPCMessage, extra?: MessageExtraInfo) => void;
|
|
73
|
+
constructor(options?: WorkerTransportOptions);
|
|
74
|
+
/**
|
|
75
|
+
* Restore transport state from persistent storage.
|
|
76
|
+
* This is automatically called on start.
|
|
77
|
+
*/
|
|
78
|
+
private restoreState;
|
|
79
|
+
/**
|
|
80
|
+
* Persist current transport state to storage.
|
|
81
|
+
*/
|
|
82
|
+
private saveState;
|
|
83
|
+
start(): Promise<void>;
|
|
84
|
+
private validateProtocolVersion;
|
|
85
|
+
private getHeaders;
|
|
86
|
+
handleRequest(request: Request, parsedBody?: unknown): Promise<Response>;
|
|
87
|
+
private handleGetRequest;
|
|
88
|
+
private handlePostRequest;
|
|
89
|
+
private handleDeleteRequest;
|
|
90
|
+
private handleOptionsRequest;
|
|
91
|
+
private handleUnsupportedRequest;
|
|
92
|
+
private validateSession;
|
|
93
|
+
close(): Promise<void>;
|
|
94
|
+
send(message: JSONRPCMessage): Promise<void>;
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/mcp/auth-context.d.ts
|
|
98
|
+
interface McpAuthContext {
|
|
99
|
+
props: Record<string, unknown>;
|
|
100
|
+
}
|
|
101
|
+
declare function getMcpAuthContext(): McpAuthContext | undefined;
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/mcp/handler.d.ts
|
|
104
|
+
interface CreateMcpHandlerOptions extends WorkerTransportOptions {
|
|
105
|
+
/**
|
|
106
|
+
* The route path that this MCP handler should respond to.
|
|
107
|
+
* If specified, the handler will only process requests that match this route.
|
|
108
|
+
* @default "/mcp"
|
|
109
|
+
*/
|
|
110
|
+
route?: string;
|
|
111
|
+
/**
|
|
112
|
+
* An optional auth context to use for handling MCP requests.
|
|
113
|
+
* If not provided, the handler will look for props in the execution context.
|
|
114
|
+
*/
|
|
115
|
+
authContext?: McpAuthContext;
|
|
116
|
+
/**
|
|
117
|
+
* An optional transport to use for handling MCP requests.
|
|
118
|
+
* If not provided, a WorkerTransport will be created with the provided WorkerTransportOptions.
|
|
119
|
+
*/
|
|
120
|
+
transport?: WorkerTransport;
|
|
121
|
+
}
|
|
122
|
+
declare function createMcpHandler(server: McpServer | Server, options?: CreateMcpHandlerOptions): (request: Request, env: unknown, ctx: ExecutionContext) => Promise<Response>;
|
|
123
|
+
/**
|
|
124
|
+
* @deprecated This has been renamed to createMcpHandler, and experimental_createMcpHandler will be removed in the next major version
|
|
125
|
+
*/
|
|
126
|
+
declare function experimental_createMcpHandler(server: McpServer | Server, options?: CreateMcpHandlerOptions): (request: Request, env: unknown, ctx: ExecutionContext) => Promise<Response>;
|
|
127
|
+
//#endregion
|
|
11
128
|
//#region src/mcp/index.d.ts
|
|
12
129
|
declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Record<string, unknown> = Record<string, unknown>> extends Agent<Env, State, Props> {
|
|
13
130
|
private _transport?;
|
|
@@ -56,7 +173,8 @@ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Re
|
|
|
56
173
|
static serve(path: string, {
|
|
57
174
|
binding,
|
|
58
175
|
corsOptions,
|
|
59
|
-
transport
|
|
176
|
+
transport,
|
|
177
|
+
jurisdiction
|
|
60
178
|
}?: ServeOptions): {
|
|
61
179
|
fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
|
|
62
180
|
};
|
|
@@ -71,5 +189,5 @@ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Re
|
|
|
71
189
|
};
|
|
72
190
|
}
|
|
73
191
|
//#endregion
|
|
74
|
-
export { type ElicitRequest, ElicitRequestSchema, type ElicitResult, type MCPClientOAuthCallbackConfig, type MCPClientOAuthResult, McpAgent, SSEEdgeClientTransport, StreamableHTTPEdgeClientTransport };
|
|
192
|
+
export { type CreateMcpHandlerOptions, type ElicitRequest, ElicitRequestSchema, type ElicitResult, type MCPClientOAuthCallbackConfig, type MCPClientOAuthResult, type MCPConnectionResult, type MCPServerOptions, McpAgent, type McpAuthContext, SSEEdgeClientTransport, StreamableHTTPEdgeClientTransport, type TransportState, WorkerTransport, type WorkerTransportOptions, createMcpHandler, experimental_createMcpHandler, getMcpAuthContext };
|
|
75
193
|
//# sourceMappingURL=index.d.ts.map
|