agents 0.19.0 → 0.20.0
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 +24 -19
- package/dist/{agent-tool-types-BNUGGBzQ.d.ts → agent-tool-types-Btk9ETS-.d.ts} +997 -356
- package/dist/agent-tool-types.d.ts +1 -1
- package/dist/{agent-tools-BFbzVLFc.d.ts → agent-tools-UuScsJg3.d.ts} +2 -2
- package/dist/agent-tools.d.ts +1 -1
- package/dist/browser/ai.js +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/chat/index.d.ts +2 -2
- package/dist/chat-sdk/index.d.ts +1 -1
- package/dist/client-invoker-BNSZxAkv.d.ts +20 -0
- package/dist/client-invoker-VNZ7X0nn.js +57 -0
- package/dist/client-invoker-VNZ7X0nn.js.map +1 -0
- package/dist/{client-CcjiFpTf.js → client-zqKcsyFa.js} +434 -168
- package/dist/client-zqKcsyFa.js.map +1 -0
- package/dist/client.d.ts +1 -1
- package/dist/{connector-CdldGF3h.js → connector-KEJnl6e5.js} +2 -2
- package/dist/connector-KEJnl6e5.js.map +1 -0
- package/dist/{do-oauth-client-provider-D4ZwyBDu.d.ts → do-oauth-client-provider-VTZj2VtM.d.ts} +23 -11
- package/dist/experimental/webmcp.js +1 -1
- package/dist/handler-stateless-8hQN_kC3.js +367 -0
- package/dist/handler-stateless-8hQN_kC3.js.map +1 -0
- package/dist/handler-stateless-C_bo-Ytq.d.ts +107 -0
- package/dist/index.d.ts +12 -12
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/mcp/client.d.ts +22 -18
- package/dist/mcp/client.js +1 -1
- package/dist/mcp/do-oauth-client-provider.d.ts +1 -1
- package/dist/mcp/do-oauth-client-provider.js +25 -12
- package/dist/mcp/do-oauth-client-provider.js.map +1 -1
- package/dist/mcp/index.d.ts +48 -34
- package/dist/mcp/index.js +84 -79
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/server.d.ts +17 -0
- package/dist/mcp/server.js +2 -0
- package/dist/mcp/x402.d.ts +21 -9
- package/dist/mcp/x402.js +8 -7
- package/dist/mcp/x402.js.map +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/serializable.d.ts +1 -1
- package/dist/sub-routing.d.ts +6 -6
- package/dist/workflows.d.ts +1 -1
- package/docs/human-in-the-loop.md +63 -82
- package/docs/mcp-client.md +31 -7
- package/docs/mcp-servers.md +125 -88
- package/docs/securing-mcp-servers.md +9 -6
- package/package.json +28 -7
- package/dist/client-CcjiFpTf.js.map +0 -1
- package/dist/connector-CdldGF3h.js.map +0 -1
package/README.md
CHANGED
|
@@ -427,30 +427,35 @@ Features:
|
|
|
427
427
|
|
|
428
428
|
Agents integrate with MCP to act as servers (providing tools to AI assistants) or clients (using tools from other services).
|
|
429
429
|
|
|
430
|
-
### Creating
|
|
430
|
+
### Creating a Stateless MCP server
|
|
431
431
|
|
|
432
432
|
```typescript
|
|
433
|
-
import { McpServer } from "@modelcontextprotocol/
|
|
434
|
-
import {
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
);
|
|
448
|
-
}
|
|
433
|
+
import { McpServer } from "@modelcontextprotocol/server";
|
|
434
|
+
import { createMcpHandler } from "agents/mcp/server";
|
|
435
|
+
import { z } from "zod";
|
|
436
|
+
|
|
437
|
+
function createServer() {
|
|
438
|
+
const server = new McpServer({ name: "my-tools", version: "1.0.0" });
|
|
439
|
+
server.registerTool(
|
|
440
|
+
"lookup",
|
|
441
|
+
{ description: "Look up data", inputSchema: { query: z.string() } },
|
|
442
|
+
async ({ query }) => ({
|
|
443
|
+
content: [{ type: "text", text: await lookup(query) }]
|
|
444
|
+
})
|
|
445
|
+
);
|
|
446
|
+
return server;
|
|
449
447
|
}
|
|
450
448
|
|
|
451
|
-
export default
|
|
449
|
+
export default {
|
|
450
|
+
fetch(request, env, ctx) {
|
|
451
|
+
return createMcpHandler(createServer)(request, env, ctx);
|
|
452
|
+
}
|
|
453
|
+
} satisfies ExportedHandler;
|
|
452
454
|
```
|
|
453
455
|
|
|
456
|
+
Use `McpAgent`, `createLegacyMcpHandler`, and `WorkerTransport` from
|
|
457
|
+
`agents/mcp` only when retaining Legacy session behavior.
|
|
458
|
+
|
|
454
459
|
### Using MCP Tools
|
|
455
460
|
|
|
456
461
|
```typescript
|
|
@@ -466,7 +471,7 @@ await this.addMcpServer(
|
|
|
466
471
|
// Use with AI SDK
|
|
467
472
|
const result = await generateText({
|
|
468
473
|
model: openai("gpt-4o"),
|
|
469
|
-
tools: this.mcp.
|
|
474
|
+
tools: this.mcp.getAITools(),
|
|
470
475
|
prompt: "What's the weather in Tokyo?"
|
|
471
476
|
});
|
|
472
477
|
```
|