Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion examples/x402-mcp/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ export class PayAgent extends Agent<Env> {
);
console.log("Agent will pay from this address:", account.address);

const { id } = await this.mcp.connect("http://localhost:8787/mcp");
const { id } = await this.addMcpServer(
"x402",
"http://localhost:8787/mcp",
"http://localhost:3000"
);

// Build the x402 MCP client
this.x402Client = withX402Client(this.mcp.mcpConnections[id].client, {
Expand Down
4 changes: 3 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion packages/agents/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"url": "https://github.com/cloudflare/agents/issues"
},
"dependencies": {
"@ai-sdk/openai": "2.0.64",
"@cfworker/json-schema": "^4.1.1",
"@modelcontextprotocol/sdk": "^1.21.0",
"ai": "5.0.89",
Expand Down
2 changes: 2 additions & 0 deletions packages/agents/src/ai-chat-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,12 @@ export class AIChatAgent<Env = unknown, State = unknown> extends Agent<
override async onRequest(request: Request): Promise<Response> {
return this._tryCatchChat(() => {
const url = new URL(request.url);

if (url.pathname.endsWith("/get-messages")) {
const messages = this._loadMessagesFromDb();
return Response.json(messages);
}

return super.onRequest(request);
});
}
Expand Down
Loading
Loading