Add an MCP server

Add an external MCP server to an agent, and each of the server's tools becomes one the agent can call.

Before you start

You need an agent. See Create an agent.

Add a server to an agent

  1. Add the server to the agent's mcpServers. id names it and transport.url is its address:
    agents/assistant.ts
    import { agent } from "veryfront/agent"; export default agent({  id: "assistant",  system: "Answer questions about open source projects. Use the DeepWiki tools.",  mcpServers: [    {      id: "deepwiki",      transport: { type: "http", url: "https://mcp.deepwiki.com/mcp" },    },  ],});
  2. Start the project with npm run dev.
  3. Open Chat in Studio.
  4. Pick the agent.
  5. Ask "Which sections does the DeepWiki wiki for honojs/hono have? List the first three." You should now see the agent call a DeepWiki tool and name the sections.

Choose its tools

A server's toolPolicy limits what the agent can call, by the server's own tool names as its tools/list gives them. allow lists the tools it may use; deny lists the ones it may not, and wins over allow:

agents/assistant.ts
{  id: "deepwiki",  transport: { type: "http", url: "https://mcp.deepwiki.com/mcp" },  toolPolicy: { allow: ["ask_wiki_question"] },}

A server that needs a key takes auth: { type: "bearer", token }, or auth: { type: "headers", headers }.

Next steps