agents 0.0.0-e03246e → 0.0.0-e1af284
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 +255 -27
- package/dist/ai-chat-agent.d.ts +59 -11
- package/dist/ai-chat-agent.js +532 -160
- package/dist/ai-chat-agent.js.map +1 -1
- package/dist/ai-chat-v5-migration-DBHGW4Hv.js +155 -0
- package/dist/ai-chat-v5-migration-DBHGW4Hv.js.map +1 -0
- package/dist/ai-chat-v5-migration.d.ts +155 -0
- package/dist/ai-chat-v5-migration.js +3 -0
- package/dist/ai-react.d.ts +73 -72
- package/dist/ai-react.js +261 -192
- package/dist/ai-react.js.map +1 -1
- package/dist/ai-types-B3aQaFv3.js +20 -0
- package/dist/ai-types-B3aQaFv3.js.map +1 -0
- package/dist/ai-types-D5YoPrBZ.d.ts +95 -0
- package/dist/ai-types.d.ts +6 -69
- package/dist/ai-types.js +3 -1
- package/dist/cli.d.ts +8 -0
- package/dist/cli.js +27 -0
- package/dist/cli.js.map +1 -0
- package/dist/client-9Ld2_lnt.js +786 -0
- package/dist/client-9Ld2_lnt.js.map +1 -0
- package/dist/client-BIwY43Ed.d.ts +5315 -0
- package/dist/client-BfiZ3HQd.js +117 -0
- package/dist/client-BfiZ3HQd.js.map +1 -0
- package/dist/client-CbWe9FBd.d.ts +104 -0
- package/dist/client.d.ts +12 -79
- package/dist/client.js +3 -130
- package/dist/codemode/ai.d.ts +27 -0
- package/dist/codemode/ai.js +151 -0
- package/dist/codemode/ai.js.map +1 -0
- package/dist/do-oauth-client-provider-CswoD5Lu.js +93 -0
- package/dist/do-oauth-client-provider-CswoD5Lu.js.map +1 -0
- package/dist/do-oauth-client-provider-DGc5pP0l.d.ts +55 -0
- package/dist/index-Bp6UrXKf.d.ts +560 -0
- package/dist/index-DhJCaDWd.d.ts +58 -0
- package/dist/index.d.ts +63 -301
- package/dist/index.js +7 -22
- package/dist/mcp/client.d.ts +4 -675
- package/dist/mcp/client.js +2 -267
- package/dist/mcp/do-oauth-client-provider.d.ts +2 -0
- package/dist/mcp/do-oauth-client-provider.js +3 -0
- package/dist/mcp/index.d.ts +151 -42
- package/dist/mcp/index.js +1362 -335
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/x402.d.ts +34 -0
- package/dist/mcp/x402.js +194 -0
- package/dist/mcp/x402.js.map +1 -0
- package/dist/mcp-Dw5vDrY8.d.ts +61 -0
- package/dist/observability/index.d.ts +3 -0
- package/dist/observability/index.js +7 -0
- package/dist/react-BRVSan-t.d.ts +115 -0
- package/dist/react.d.ts +10 -39
- package/dist/react.js +183 -98
- package/dist/react.js.map +1 -1
- package/dist/schedule.d.ts +89 -12
- package/dist/schedule.js +46 -23
- package/dist/schedule.js.map +1 -1
- package/dist/serializable-CymX8ovI.d.ts +39 -0
- package/dist/serializable.d.ts +7 -0
- package/dist/serializable.js +1 -0
- package/dist/src-Dz0H9hSU.js +1200 -0
- package/dist/src-Dz0H9hSU.js.map +1 -0
- package/package.json +121 -50
- package/dist/ai-types.js.map +0 -1
- package/dist/chunk-HMLY7DHA.js +0 -16
- package/dist/chunk-HMLY7DHA.js.map +0 -1
- package/dist/chunk-YMUU7QHV.js +0 -595
- package/dist/chunk-YMUU7QHV.js.map +0 -1
- package/dist/client.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/mcp/client.js.map +0 -1
- package/src/index.ts +0 -919
package/dist/mcp/client.js
CHANGED
|
@@ -1,268 +1,3 @@
|
|
|
1
|
-
import "../
|
|
1
|
+
import { n as getNamespacedData, t as MCPClientManager } from "../client-9Ld2_lnt.js";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
SSEClientTransport
|
|
6
|
-
} from "@modelcontextprotocol/sdk/client/sse.js";
|
|
7
|
-
var SSEEdgeClientTransport = class extends SSEClientTransport {
|
|
8
|
-
/**
|
|
9
|
-
* Creates a new EdgeSSEClientTransport, which overrides fetch to be compatible with the CF workers environment
|
|
10
|
-
*/
|
|
11
|
-
constructor(url, options) {
|
|
12
|
-
const fetchOverride = (url2, options2 = {}) => {
|
|
13
|
-
const workerOptions = {
|
|
14
|
-
...options2
|
|
15
|
-
};
|
|
16
|
-
delete workerOptions.mode;
|
|
17
|
-
return global.fetch(url2, workerOptions);
|
|
18
|
-
};
|
|
19
|
-
super(url, {
|
|
20
|
-
...options,
|
|
21
|
-
eventSourceInit: {
|
|
22
|
-
fetch: fetchOverride
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
this.url = url;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
// src/mcp/client-connection.ts
|
|
30
|
-
import {
|
|
31
|
-
ToolListChangedNotificationSchema,
|
|
32
|
-
ResourceListChangedNotificationSchema,
|
|
33
|
-
PromptListChangedNotificationSchema
|
|
34
|
-
} from "@modelcontextprotocol/sdk/types.js";
|
|
35
|
-
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
36
|
-
var MCPClientConnection = class {
|
|
37
|
-
constructor(url, info, opts = { transport: {}, client: {}, capabilities: {} }) {
|
|
38
|
-
this.info = info;
|
|
39
|
-
this.transport = new SSEEdgeClientTransport(url, opts.transport);
|
|
40
|
-
this.client = new Client(info, opts.client);
|
|
41
|
-
this.client.registerCapabilities(opts.capabilities);
|
|
42
|
-
this.connected = false;
|
|
43
|
-
this.tools = [];
|
|
44
|
-
this.prompts = [];
|
|
45
|
-
this.resources = [];
|
|
46
|
-
this.resourceTemplates = [];
|
|
47
|
-
}
|
|
48
|
-
async init() {
|
|
49
|
-
await this.client.connect(this.transport);
|
|
50
|
-
this.serverCapabilities = await this.client.getServerCapabilities();
|
|
51
|
-
if (!this.serverCapabilities) {
|
|
52
|
-
throw new Error(
|
|
53
|
-
`The MCP Server ${this.info.name} failed to return server capabilities`
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
const [instructions, tools, resources, prompts, resourceTemplates] = await Promise.all([
|
|
57
|
-
this.client.getInstructions(),
|
|
58
|
-
this.registerTools(),
|
|
59
|
-
this.registerResources(),
|
|
60
|
-
this.registerPrompts(),
|
|
61
|
-
this.registerResourceTemplates()
|
|
62
|
-
]);
|
|
63
|
-
this.instructions = instructions;
|
|
64
|
-
this.tools = tools;
|
|
65
|
-
this.resources = resources;
|
|
66
|
-
this.prompts = prompts;
|
|
67
|
-
this.resourceTemplates = resourceTemplates;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Notification handler registration
|
|
71
|
-
*/
|
|
72
|
-
async registerTools() {
|
|
73
|
-
if (!this.serverCapabilities || !this.serverCapabilities.tools) {
|
|
74
|
-
return [];
|
|
75
|
-
}
|
|
76
|
-
if (this.serverCapabilities.tools.listChanged) {
|
|
77
|
-
this.client.setNotificationHandler(
|
|
78
|
-
ToolListChangedNotificationSchema,
|
|
79
|
-
async (_notification) => {
|
|
80
|
-
this.tools = await this.fetchTools();
|
|
81
|
-
}
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
return this.fetchTools();
|
|
85
|
-
}
|
|
86
|
-
async registerResources() {
|
|
87
|
-
if (!this.serverCapabilities || !this.serverCapabilities.resources) {
|
|
88
|
-
return [];
|
|
89
|
-
}
|
|
90
|
-
if (this.serverCapabilities.resources.listChanged) {
|
|
91
|
-
this.client.setNotificationHandler(
|
|
92
|
-
ResourceListChangedNotificationSchema,
|
|
93
|
-
async (_notification) => {
|
|
94
|
-
this.resources = await this.fetchResources();
|
|
95
|
-
}
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
return this.fetchResources();
|
|
99
|
-
}
|
|
100
|
-
async registerPrompts() {
|
|
101
|
-
if (!this.serverCapabilities || !this.serverCapabilities.prompts) {
|
|
102
|
-
return [];
|
|
103
|
-
}
|
|
104
|
-
if (this.serverCapabilities.prompts.listChanged) {
|
|
105
|
-
this.client.setNotificationHandler(
|
|
106
|
-
PromptListChangedNotificationSchema,
|
|
107
|
-
async (_notification) => {
|
|
108
|
-
this.prompts = await this.fetchPrompts();
|
|
109
|
-
}
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
return this.fetchPrompts();
|
|
113
|
-
}
|
|
114
|
-
async registerResourceTemplates() {
|
|
115
|
-
if (!this.serverCapabilities || !this.serverCapabilities.resources) {
|
|
116
|
-
return [];
|
|
117
|
-
}
|
|
118
|
-
return this.fetchResourceTemplates();
|
|
119
|
-
}
|
|
120
|
-
async fetchTools() {
|
|
121
|
-
let toolsAgg = [];
|
|
122
|
-
let toolsResult = { tools: [] };
|
|
123
|
-
do {
|
|
124
|
-
toolsResult = await this.client.listTools({
|
|
125
|
-
cursor: toolsResult.nextCursor
|
|
126
|
-
});
|
|
127
|
-
toolsAgg = toolsAgg.concat(toolsResult.tools);
|
|
128
|
-
} while (toolsResult.nextCursor);
|
|
129
|
-
return toolsAgg;
|
|
130
|
-
}
|
|
131
|
-
async fetchResources() {
|
|
132
|
-
let resourcesAgg = [];
|
|
133
|
-
let resourcesResult = { resources: [] };
|
|
134
|
-
do {
|
|
135
|
-
resourcesResult = await this.client.listResources({
|
|
136
|
-
cursor: resourcesResult.nextCursor
|
|
137
|
-
});
|
|
138
|
-
resourcesAgg = resourcesAgg.concat(resourcesResult.resources);
|
|
139
|
-
} while (resourcesResult.nextCursor);
|
|
140
|
-
return resourcesAgg;
|
|
141
|
-
}
|
|
142
|
-
async fetchPrompts() {
|
|
143
|
-
let promptsAgg = [];
|
|
144
|
-
let promptsResult = { prompts: [] };
|
|
145
|
-
do {
|
|
146
|
-
promptsResult = await this.client.listPrompts({
|
|
147
|
-
cursor: promptsResult.nextCursor
|
|
148
|
-
});
|
|
149
|
-
promptsAgg = promptsAgg.concat(promptsResult.prompts);
|
|
150
|
-
} while (promptsResult.nextCursor);
|
|
151
|
-
return promptsAgg;
|
|
152
|
-
}
|
|
153
|
-
async fetchResourceTemplates() {
|
|
154
|
-
let templatesAgg = [];
|
|
155
|
-
let templatesResult = {
|
|
156
|
-
resourceTemplates: []
|
|
157
|
-
};
|
|
158
|
-
do {
|
|
159
|
-
templatesResult = await this.client.listResourceTemplates({
|
|
160
|
-
cursor: templatesResult.nextCursor
|
|
161
|
-
});
|
|
162
|
-
templatesAgg = templatesAgg.concat(templatesResult.resourceTemplates);
|
|
163
|
-
} while (templatesResult.nextCursor);
|
|
164
|
-
return templatesAgg;
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
// src/mcp/client.ts
|
|
169
|
-
var MCPClientManager = class {
|
|
170
|
-
constructor() {
|
|
171
|
-
this.mcpConnections = {};
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Connect to and register an MCP server
|
|
175
|
-
*
|
|
176
|
-
* @param transportConfig Transport config
|
|
177
|
-
* @param clientConfig Client config
|
|
178
|
-
* @param capabilities Client capabilities (i.e. if the client supports roots/sampling)
|
|
179
|
-
*/
|
|
180
|
-
async connectToServer(url, info, opts = { transport: {}, client: {}, capabilities: {} }) {
|
|
181
|
-
if (info.name in this.mcpConnections) {
|
|
182
|
-
throw new Error(
|
|
183
|
-
`An existing MCP client has already been registered under the name "${info.name}". The MCP client name must be unique.`
|
|
184
|
-
);
|
|
185
|
-
}
|
|
186
|
-
this.mcpConnections[info.name] = new MCPClientConnection(url, info, opts);
|
|
187
|
-
await this.mcpConnections[info.name].init();
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* @returns namespaced list of tools
|
|
191
|
-
*/
|
|
192
|
-
listTools() {
|
|
193
|
-
return getNamespacedData(this.mcpConnections, "tools");
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* @returns namespaced list of prompts
|
|
197
|
-
*/
|
|
198
|
-
listPrompts() {
|
|
199
|
-
return getNamespacedData(this.mcpConnections, "prompts");
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* @returns namespaced list of tools
|
|
203
|
-
*/
|
|
204
|
-
listResources() {
|
|
205
|
-
return getNamespacedData(this.mcpConnections, "resources");
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* @returns namespaced list of resource templates
|
|
209
|
-
*/
|
|
210
|
-
listResourceTemplates() {
|
|
211
|
-
return getNamespacedData(this.mcpConnections, "resourceTemplates");
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Namespaced version of callTool
|
|
215
|
-
*/
|
|
216
|
-
callTool(params, resultSchema, options) {
|
|
217
|
-
const unqualifiedName = params.name.replace(`${params.serverName}.`, "");
|
|
218
|
-
return this.mcpConnections[params.serverName].client.callTool(
|
|
219
|
-
{
|
|
220
|
-
...params,
|
|
221
|
-
name: unqualifiedName
|
|
222
|
-
},
|
|
223
|
-
resultSchema,
|
|
224
|
-
options
|
|
225
|
-
);
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Namespaced version of readResource
|
|
229
|
-
*/
|
|
230
|
-
readResource(params, options) {
|
|
231
|
-
return this.mcpConnections[params.serverName].client.readResource(
|
|
232
|
-
params,
|
|
233
|
-
options
|
|
234
|
-
);
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* Namespaced version of getPrompt
|
|
238
|
-
*/
|
|
239
|
-
getPrompt(params, options) {
|
|
240
|
-
return this.mcpConnections[params.serverName].client.getPrompt(
|
|
241
|
-
params,
|
|
242
|
-
options
|
|
243
|
-
);
|
|
244
|
-
}
|
|
245
|
-
};
|
|
246
|
-
function getNamespacedData(mcpClients, type) {
|
|
247
|
-
const sets = Object.entries(mcpClients).map(([name, conn]) => {
|
|
248
|
-
return { name, data: conn[type] };
|
|
249
|
-
});
|
|
250
|
-
const namespacedData = sets.flatMap(({ name: serverName, data }) => {
|
|
251
|
-
return data.map((item) => {
|
|
252
|
-
return {
|
|
253
|
-
...item,
|
|
254
|
-
// we add a servername so we can easily pull it out and convert between qualified<->unqualified name
|
|
255
|
-
// just in case the server name or item name includes a "."
|
|
256
|
-
serverName: `${serverName}`,
|
|
257
|
-
// qualified name
|
|
258
|
-
name: `${serverName}.${item.name}`
|
|
259
|
-
};
|
|
260
|
-
});
|
|
261
|
-
});
|
|
262
|
-
return namespacedData;
|
|
263
|
-
}
|
|
264
|
-
export {
|
|
265
|
-
MCPClientManager,
|
|
266
|
-
getNamespacedData
|
|
267
|
-
};
|
|
268
|
-
//# sourceMappingURL=client.js.map
|
|
3
|
+
export { MCPClientManager, getNamespacedData };
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -1,45 +1,154 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { c as MaybePromise, d as StreamableHTTPEdgeClientTransport, f as SSEEdgeClientTransport, l as ServeOptions, n as MCPClientOAuthCallbackConfig, o as BaseTransportType, r as MCPClientOAuthResult, s as CORSOptions } from "../client-BIwY43Ed.js";
|
|
2
|
+
import "../mcp-Dw5vDrY8.js";
|
|
3
|
+
import "../do-oauth-client-provider-DGc5pP0l.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-Bp6UrXKf.js";
|
|
7
|
+
import { ElicitRequest, ElicitRequestSchema, ElicitResult, ElicitResult as ElicitResult$1, JSONRPCMessage, MessageExtraInfo } from "@modelcontextprotocol/sdk/types.js";
|
|
8
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
9
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
10
|
+
import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
|
|
4
11
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
12
|
+
//#region src/mcp/worker-transport.d.ts
|
|
13
|
+
interface WorkerTransportOptions {
|
|
14
|
+
sessionIdGenerator?: () => string;
|
|
15
|
+
enableJsonResponse?: boolean;
|
|
16
|
+
onsessioninitialized?: (sessionId: string) => void;
|
|
17
|
+
corsOptions?: CORSOptions;
|
|
10
18
|
}
|
|
11
|
-
declare
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}): {
|
|
41
|
-
fetch: (request: Request, env: Record<string, DurableObjectNamespace<McpAgent>>, ctx: ExecutionContext) => Promise<Response | undefined>;
|
|
42
|
-
};
|
|
19
|
+
declare class WorkerTransport implements Transport {
|
|
20
|
+
private started;
|
|
21
|
+
private initialized;
|
|
22
|
+
private sessionIdGenerator?;
|
|
23
|
+
private enableJsonResponse;
|
|
24
|
+
private onsessioninitialized?;
|
|
25
|
+
private standaloneSseStreamId;
|
|
26
|
+
private streamMapping;
|
|
27
|
+
private requestToStreamMapping;
|
|
28
|
+
private requestResponseMap;
|
|
29
|
+
private corsOptions?;
|
|
30
|
+
private protocolVersion?;
|
|
31
|
+
sessionId?: string;
|
|
32
|
+
onclose?: () => void;
|
|
33
|
+
onerror?: (error: Error) => void;
|
|
34
|
+
onmessage?: (message: JSONRPCMessage, extra?: MessageExtraInfo) => void;
|
|
35
|
+
constructor(options?: WorkerTransportOptions);
|
|
36
|
+
start(): Promise<void>;
|
|
37
|
+
private validateProtocolVersion;
|
|
38
|
+
private getHeaders;
|
|
39
|
+
handleRequest(request: Request, parsedBody?: unknown): Promise<Response>;
|
|
40
|
+
private handleGetRequest;
|
|
41
|
+
private handlePostRequest;
|
|
42
|
+
private handleDeleteRequest;
|
|
43
|
+
private handleOptionsRequest;
|
|
44
|
+
private handleUnsupportedRequest;
|
|
45
|
+
private validateSession;
|
|
46
|
+
close(): Promise<void>;
|
|
47
|
+
send(message: JSONRPCMessage): Promise<void>;
|
|
43
48
|
}
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region src/mcp/handler.d.ts
|
|
51
|
+
interface CreateMcpHandlerOptions extends WorkerTransportOptions {
|
|
52
|
+
/**
|
|
53
|
+
* The route path that this MCP handler should respond to.
|
|
54
|
+
* If specified, the handler will only process requests that match this route.
|
|
55
|
+
* @default "/mcp"
|
|
56
|
+
*/
|
|
57
|
+
route?: string;
|
|
58
|
+
/**
|
|
59
|
+
* CORS configuration options for handling cross-origin requests.
|
|
60
|
+
* These options are passed to the WorkerTransport which handles adding
|
|
61
|
+
* CORS headers to all responses.
|
|
62
|
+
*
|
|
63
|
+
* Default values are:
|
|
64
|
+
* - origin: "*"
|
|
65
|
+
* - headers: "Content-Type, Accept, Authorization, mcp-session-id, MCP-Protocol-Version"
|
|
66
|
+
* - methods: "GET, POST, DELETE, OPTIONS"
|
|
67
|
+
* - exposeHeaders: "mcp-session-id"
|
|
68
|
+
* - maxAge: 86400
|
|
69
|
+
*
|
|
70
|
+
* Provided options will overwrite the defaults.
|
|
71
|
+
*/
|
|
72
|
+
corsOptions?: CORSOptions;
|
|
73
|
+
}
|
|
74
|
+
type OAuthExecutionContext = ExecutionContext & {
|
|
75
|
+
props?: Record<string, unknown>;
|
|
76
|
+
};
|
|
77
|
+
declare function createMcpHandler(server: McpServer | Server, options?: CreateMcpHandlerOptions): (request: Request, env: unknown, ctx: ExecutionContext) => Promise<Response>;
|
|
78
|
+
/**
|
|
79
|
+
* @deprecated This has been renamed to createMcpHandler, and experimental_createMcpHandler will be removed in the next major version
|
|
80
|
+
*/
|
|
81
|
+
declare function experimental_createMcpHandler(server: McpServer | Server, options?: CreateMcpHandlerOptions): (request: Request, env: unknown, ctx: ExecutionContext) => Promise<Response>;
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/mcp/auth-context.d.ts
|
|
84
|
+
interface McpAuthContext {
|
|
85
|
+
props: Record<string, unknown>;
|
|
86
|
+
}
|
|
87
|
+
declare function getMcpAuthContext(): McpAuthContext | undefined;
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/mcp/index.d.ts
|
|
90
|
+
declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Record<string, unknown> = Record<string, unknown>> extends Agent<Env, State, Props> {
|
|
91
|
+
private _transport?;
|
|
92
|
+
props?: Props;
|
|
93
|
+
abstract server: MaybePromise<McpServer | Server>;
|
|
94
|
+
abstract init(): Promise<void>;
|
|
95
|
+
setInitializeRequest(initializeRequest: JSONRPCMessage): Promise<void>;
|
|
96
|
+
getInitializeRequest(): Promise<JSONRPCMessage | undefined>;
|
|
97
|
+
/** Read the transport type for this agent.
|
|
98
|
+
* This relies on the naming scheme being `sse:${sessionId}`
|
|
99
|
+
* or `streamable-http:${sessionId}`.
|
|
100
|
+
*/
|
|
101
|
+
getTransportType(): BaseTransportType;
|
|
102
|
+
/** Read the sessionId for this agent.
|
|
103
|
+
* This relies on the naming scheme being `sse:${sessionId}`
|
|
104
|
+
* or `streamable-http:${sessionId}`.
|
|
105
|
+
*/
|
|
106
|
+
getSessionId(): string;
|
|
107
|
+
/** Get the unique WebSocket. SSE transport only. */
|
|
108
|
+
private getWebSocket;
|
|
109
|
+
/** Returns a new transport matching the type of the Agent. */
|
|
110
|
+
private initTransport;
|
|
111
|
+
/** Update and store the props */
|
|
112
|
+
updateProps(props?: Props): Promise<void>;
|
|
113
|
+
reinitializeServer(): Promise<void>;
|
|
114
|
+
/** Sets up the MCP transport and server every time the Agent is started.*/
|
|
115
|
+
onStart(props?: Props): Promise<void>;
|
|
116
|
+
/** Validates new WebSocket connections. */
|
|
117
|
+
onConnect(conn: Connection, {
|
|
118
|
+
request: req
|
|
119
|
+
}: ConnectionContext): Promise<void>;
|
|
120
|
+
/** Handles MCP Messages for the legacy SSE transport. */
|
|
121
|
+
onSSEMcpMessage(_sessionId: string, messageBody: unknown): Promise<Error | null>;
|
|
122
|
+
/** Elicit user input with a message and schema */
|
|
123
|
+
elicitInput(params: {
|
|
124
|
+
message: string;
|
|
125
|
+
requestedSchema: unknown;
|
|
126
|
+
}): Promise<ElicitResult$1>;
|
|
127
|
+
/** Wait for elicitation response through storage polling */
|
|
128
|
+
private _waitForElicitationResponse;
|
|
129
|
+
/** Handle elicitation responses */
|
|
130
|
+
private _handleElicitationResponse;
|
|
131
|
+
/** Return a handler for the given path for this MCP.
|
|
132
|
+
* Defaults to Streamable HTTP transport.
|
|
133
|
+
*/
|
|
134
|
+
static serve(path: string, {
|
|
135
|
+
binding,
|
|
136
|
+
corsOptions,
|
|
137
|
+
transport,
|
|
138
|
+
jurisdiction
|
|
139
|
+
}?: ServeOptions): {
|
|
140
|
+
fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* Legacy api
|
|
144
|
+
**/
|
|
145
|
+
static mount(path: string, opts?: Omit<ServeOptions, "transport">): {
|
|
146
|
+
fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
|
|
147
|
+
};
|
|
148
|
+
static serveSSE(path: string, opts?: Omit<ServeOptions, "transport">): {
|
|
149
|
+
fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
//#endregion
|
|
153
|
+
export { type CreateMcpHandlerOptions, type ElicitRequest, ElicitRequestSchema, type ElicitResult, type MCPClientOAuthCallbackConfig, type MCPClientOAuthResult, McpAgent, type McpAuthContext, type OAuthExecutionContext, SSEEdgeClientTransport, StreamableHTTPEdgeClientTransport, WorkerTransport, type WorkerTransportOptions, createMcpHandler, experimental_createMcpHandler, getMcpAuthContext };
|
|
154
|
+
//# sourceMappingURL=index.d.ts.map
|