Documentation menu
Documentation

Model Context Protocol

Connect agents to MCP servers or expose an agent as one without losing the co-located UI.

Start from a fresh project

This guide is self-contained. Create an empty Ayjnt project, then replace the starter agent with the files shown below. Run commands from the new project directory unless a step says otherwise.

terminal
bunx ayjnt new try-mcp --empty
cd try-mcp
bun install

# remove agents/alive once you are ready to add the guide's files

MCP clients

Cloudflare Agent includes a durable MCP client manager for registering servers, OAuth callbacks, discovery, and namespaced tools. Use native addMcpServer(), removeMcpServer(), and the manager on this.mcp.

Treat tool descriptions and remote content as untrusted. Gate sensitive tools and keep authorization tied to the person and agent instance.

MCP agents

An MCP agent can live in the same file-routed project and still have app.tsx. Ayjnt detects the agent type and generates the correct handler while preserving the browser interface.

Run it and verify the result

Connect an MCP inspector to the generated route and invoke the example tool with its documented input.

terminal
bun run build
bun run dev

# the local app is now available at http://localhost:8787