@roostjs/mcp

What the Model Context Protocol is, why Roost supports it as a server, and how MCP tools differ from AI agent tools.

What MCP Is

The Model Context Protocol (MCP) is an open standard for connecting AI models to external tools and data sources. Instead of every AI application implementing its own bespoke tool integration, MCP defines a standard wire format that any AI client can use to discover and call tools on any MCP server. It is, in effect, a standardized API contract for AI tool use.

An MCP server exposes three kinds of things: tools (functions the AI can call), resources (data sources the AI can read), and prompts (pre-defined prompt templates). An AI client — Claude Desktop, a custom chat interface, or another AI application — connects to the server, discovers what is available, and uses it. The server does not need to know anything about the specific AI model or client; the client does not need to know anything about the server's implementation language or framework.

Server-Side Tool Exposure

Roost's McpServer makes a Cloudflare Worker into an MCP server. A class extending McpServer declares its tools, resources, and prompts as arrays of class constructors. The server instantiates them on demand and handles the MCP protocol mechanics: listing capabilities, routing tool calls to the right tool, reading resources, running prompts. The application code only implements the what — what this tool does, what this resource contains — and the server handles the how of speaking MCP.

Because MCP servers run as HTTP endpoints, a Cloudflare Worker is an ideal host. The server receives HTTP requests containing MCP messages and returns HTTP responses with MCP results. The edge deployment means the MCP server is globally distributed alongside the application it belongs to.

How MCP Tools Relate to AI Agent Tools

At first glance, @roostjs/mcp tools and @roostjs/ai tools look similar: both define a description, a parameter schema, and a handle method. The distinction is the audience. AI agent tools are consumed by Roost agents running inside your application — they are called by the agentic loop inside agent.prompt(). MCP tools are consumed by external AI clients connecting to your application over HTTP.

Both use @roostjs/schema for parameter definitions, which is the intentional overlap. A tool that makes sense as an AI agent tool will often also make sense as an MCP tool. The schema package provides the shared vocabulary, but the two packages serve different integration points: one is internal to your application, the other is an outward-facing API contract for AI clients you do not control.

Further Reading