What is the Model Context Protocol (MCP)? A Developer Guide to Building an MCP Server
Developer guide to the Model Context Protocol: what MCP is, why it makes AI agents reliable, and how to build and register an MCP server on CAPPZ.
1. What is Model Context Protocol?
The Model Context Protocol (MCP) is an open specification that standardizes how AI models and agents discover and call external tools, data sources, and prompts. Think of it as the USB-C port for AI: instead of writing a bespoke integration for every LLM × tool pair, you implement MCP once and any compliant client (Claude, ChatGPT, agent frameworks, CAPPZ resident agents) can use it.
An MCP server exposes capabilities to AI clients in three primitives:
- Tools — callable functions the model can invoke.
- Resources — read-only context the model can pull (files, rows, docs).
- Prompts — reusable, parameterized prompt templates.
Transport happens over stdio for local servers or Streamable HTTP (JSON-RPC 2.0 with SSE) for remote servers.
2. Why MCP matters for AI agent reliability
Tool-calling reliability is the bottleneck for production agents. MCP improves it in four ways:
- Typed schemas. Every tool ships a JSON Schema input/output contract, which dramatically reduces malformed tool calls.
- Capability discovery. Agents introspect what a server offers at runtime instead of relying on hardcoded prompts.
- Permission boundaries. Servers declare scopes; clients enforce user consent before invocation.
- Portability. The same MCP server works across Claude Desktop, Cursor, agent SDKs, and CAPPZ resident agents — no rewrites.
On CAPPZ specifically, MCP servers are first-class citizens of the MCP Registry, which notarizes every server, version, and tool invocation on-chain — so agent behaviour stays auditable and royalty-bearing.
3. MCP architecture in 60 seconds
MCP is a client/server protocol over JSON-RPC 2.0. The lifecycle is:
- initialize — handshake, advertise protocol version & capabilities.
- tools/list, resources/list, prompts/list — discovery.
- tools/call, resources/read, prompts/get — execution.
- notifications/* — async server-pushed events.
Remote MCP servers usually run as a single HTTP endpoint that accepts POST requests with Accept: application/json, text/event-stream. Without that header the official SDK responds 406 Not Acceptable — a top-3 footgun for newcomers.
4. Build an MCP server (step-by-step)
We'll build a minimal HTTP MCP server using mcp-lite and Hono — deployable to any edge runtime (Cloudflare Workers, Vercel Edge, Supabase Edge Functions).
Step 1 — Install
npm install mcp-lite hono
Step 2 — Define a server and a tool
import { Hono } from "hono"; import { McpServer, StreamableHttpTransport } from "mcp-lite"; const mcp = new McpServer({ name: "weather-mcp", version: "1.0.0", }); mcp.tool({ name: "get_weather", description: "Returns current weather for a city.", inputSchema: { type: "object", properties: { city: { type: "string" } }, required: ["city"], }, handler: async ({ city }) => { const data = await fetch(`https://wttr.in/${city}?format=j1`).then(r => r.json()); return { content: [{ type: "text", text: JSON.stringify(data.current_condition[0]) }] }; }, });
Step 3 — Wire up HTTP transport
const app = new Hono(); const transport = new StreamableHttpTransport(); app.all("/*", (c) => transport.handleRequest(c.req.raw, mcp)); export default app;
Step 4 — Test locally
npx @modelcontextprotocol/inspector http://localhost:8787
The Inspector lets you click through tools/list and tools/call without writing a client. If your tool responds, you have a working MCP server.
5. Register your MCP server on CAPPZ
Once your server is reachable over HTTPS, register it in the CAPPZ MCP Registry so every resident agent on the substrate can discover and invoke it — with on-chain notarization and royalty events:
- Visit the MCP Registrypage.
- Click Register MCP Server and paste your HTTPS endpoint, name, version, and a one-line description.
- CAPPZ probes the server (initialize + tools/list), persists the tool catalog as event transactions on the substrate, and emits a McpServerRegistered TX at your HD address.
- Configure the royalty split (default 70/20/10 via the Royalty Flywheel) so every tools/call notarized against your server pays out automatically.
Your server is now discoverable to every CAPPZ agent and visible in the public registry — no central gatekeeper required.
6. Best practices & common pitfalls
- Always send Accept: application/json, text/event-stream on POSTs — otherwise SDK servers return HTTP 406.
- Keep schemas tight. Use required, enums, and pattern constraints. LLMs follow narrow schemas more reliably.
- Idempotent tools win. Agents retry. Design tools/call handlers to be safely retryable.
- Version your server. Bump version on breaking tool changes — CAPPZ tracks versions as HD-addressed artifacts.
- Don't leak secrets. Read API keys from environment variables; never echo them in tool responses.
7. Frequently asked questions
Is MCP only for Claude?
No. MCP is an open spec maintained by Anthropic but adopted by OpenAI, agent frameworks (LangGraph, AI SDK, Mastra), IDEs (Cursor, Zed), and the CAPPZ substrate. Any client that speaks JSON-RPC 2.0 over stdio or Streamable HTTP can use any MCP server.
What's the difference between an MCP server and a REST API?
A REST API exposes resources for human or app consumption. An MCP server exposes capabilities for LLM consumption — with typed schemas, capability discovery, and a standardized invocation envelope. You can wrap an existing REST API in an MCP server in minutes.
Does my MCP server need to be public?
No. Local stdio servers stay on the user's machine. Remote HTTP servers can be private (auth required) or public. CAPPZ supports both, and notarizes only the catalog and invocation metadata — not response payloads — unless you opt in.
How does CAPPZ make MCP servers more reliable?
Every registered server, version, tool, and invocation is anchored to an HD address on the XRPL. Agents verify catalogs against the on-chain registry before calling, and every call emits a royalty event TX — so usage, attribution, and revenue are all auditable.