feat(unstable): Deno.McpServer API for writing MCP servers#35178
Draft
bartlomieju wants to merge 1 commit into
Draft
feat(unstable): Deno.McpServer API for writing MCP servers#35178bartlomieju wants to merge 1 commit into
Deno.McpServer API for writing MCP servers#35178bartlomieju wants to merge 1 commit into
Conversation
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.
Contributor
|
Seems like this is going the bun way of adding everything under the main scope , maybe another global variable called Extra that have all this and S3 and what not should be considered and if something is truly used frequently with time it will be upgraded to deno scooe |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Experiment: a built-in API for writing Model Context Protocol servers in
Deno with zero dependencies, behind
--unstable-mcp.It is implemented as a JS-only lazy-loaded extension (
ext/mcp, no ops)that handles the MCP JSON-RPC lifecycle (initialize handshake with
protocol version negotiation, ping, tools, resources, prompts), reports
tool execution errors in-band per spec, and supports the stdio transport
(newline-delimited JSON-RPC) plus a stateless streamable HTTP transport.
Handlers can return plain values, which are auto-wrapped into MCP result
shapes, or full spec-shaped result objects. Verified against the official
MCP Inspector client over stdio and with raw JSON-RPC on both transports.
Not implemented yet (follow-ups if this is pursued): server-initiated
notifications (
listChanged), SSE streaming and sessions for the HTTPtransport, resource templates, argument completion, schema validation of
tool arguments, and spec tests.