Elysia MCP Adapterelysia-mcp-adapter

Overview

A thin, secure bridge from Elysia HTTP routes to Model Context Protocol.

@mwillbanks/elysia-mcp-adapter adds a Model Context Protocol HTTP endpoint to an Elysia application. Existing routes can become MCP tools, while explicit registration methods cover MCP-only tools, resources, resource templates, and prompts.

One Elysia application serves HTTP clients and MCP clients through the same route lifecycle.

Preserve the Elysia lifecycle

Route-backed calls are converted into an internal Request and sent through app.handle(). This keeps the behavior that already protects and shapes your HTTP API:

  • request parsing and TypeBox validation
  • local hooks, guards, and authentication plugins
  • error handlers and response mapping
  • route-specific status codes and headers

The adapter never calls an Elysia route handler directly.

A focused MCP surface

PrimitiveRoute-backedStandaloneDefault exposure
ToolsYes.mcpTool()Eligible HTTP routes become tools
ResourcesYes.mcpResource()Explicit opt-in
Resource templatesYes.mcpResource()Explicit opt-in
PromptsYes.mcpPrompt()Explicit opt-in

The transport lives at POST /mcp by default and implements initialization, discovery, tool calls, resource reads, and prompt retrieval over JSON-RPC.

Design principles

  1. Elysia remains the application framework. The adapter translates protocols instead of introducing a parallel runtime.
  2. JSON Schema stays JSON Schema. Route schemas are sanitized for transport without a TypeBox-to-Zod translation layer.
  3. Exposure is deliberate. Tools are convenient by default; resources, prompts, headers, browser origins, and binary output require explicit configuration.
  4. Existing integrations keep working. OpenAPI metadata, auth plugins, hooks, guards, error handling, and OpenTelemetry remain in the Elysia lifecycle.

Next steps

On this page