experiment: native MCP server API (Deno.McpServer)
Adds an unstable Deno.McpServer API behind --unstable-mcp that makes it
easy to write Model Context Protocol servers in Deno without any
dependencies:
const server = new Deno.McpServer({ name: "demo", version: "1.0.0" });
server.tool("add", { inputSchema }, ({ a, b }) => a + b);
server.resource("file:///greeting.txt", () => "hello");
server.prompt("review", ({ code }) => "Review this: " + code);
await server.serve(); // stdio transport
// or: Deno.serve(server.fetch) // streamable HTTP transport
Implemented as a new lazy loaded JS-only extension (ext/mcp) that
handles the MCP JSON-RPC lifecycle (initialize, ping, tools, resources,
prompts), reports tool errors in-band per spec, and supports both the
stdio transport (newline delimited JSON-RPC) and a stateless streamable
HTTP transport.
Verified against the official MCP Inspector client (initialize
handshake, tools/list, tools/call) and with raw JSON-RPC over both
transports.