Elysia MCP Adapter
Exposes Elysia HTTP routes and MCP-native primitives through a single Model Context Protocol endpoint, preserving Elysia's request lifecycle.
README
<p align="center"> <img src="./logo.svg" alt="Elysia MCP Adapter logo" width="164" /> </p>
<h1 align="center">Elysia MCP Adapter</h1>
<p align="center"> Expose Elysia routes and MCP-native primitives through one secure Model Context Protocol endpoint. </p>
<p align="center"> <a href="https://www.npmjs.com/package/@mwillbanks/elysia-mcp-adapter"><img alt="npm" src="https://img.shields.io/npm/v/@mwillbanks/elysia-mcp-adapter?style=flat-square&color=8b5cf6" /></a> <a href="./LICENSE"><img alt="MIT License" src="https://img.shields.io/badge/license-MIT-ec4899?style=flat-square" /></a> <a href="https://mwillbanks.github.io/elysia-mcp-adapter/"><img alt="Documentation" src="https://img.shields.io/badge/docs-live-06b6d4?style=flat-square" /></a> </p>
@mwillbanks/elysia-mcp-adapter turns eligible Elysia HTTP routes into MCP tools while preserving the request lifecycle you already rely on: parsing, validation, hooks, guards, authentication, error handling, and response mapping. It also provides thin APIs for standalone tools, resources, resource templates, and prompts.
Why this adapter?
- Keep Elysia in charge. Route-backed calls run through
app.handle(new Request(...)); handlers are never invoked out of band. - Reuse schemas. Existing TypeBox and route schemas are normalized to JSON Schema for MCP clients.
- Secure by default. Origin checks are enabled, model-controlled headers are denied, credential-bearing response headers are redacted, and binary responses are disabled.
- Stay protocol-focused. The package is ESM-only and does not introduce a second application framework or translate TypeBox to Zod.
Install
bun add @mwillbanks/elysia-mcp-adapter elysia
Node.js >=20.11, Bun >=1.1, Elysia >=1.4, and TypeScript >=5.8 are supported.
Quick start
import { mcp } from '@mwillbanks/elysia-mcp-adapter'
import { Elysia, t } from 'elysia'
const app = new Elysia()
.use(
mcp({
server: {
name: 'users-api',
version: '1.0.0'
}
})
)
.get(
'/users/:id',
({ params }) => ({ id: params.id }),
{
params: t.Object({ id: t.String() }),
detail: {
operationId: 'users.get',
summary: 'Get a user'
}
}
)
.listen(3000)
The adapter exposes GET /users/:id as the users.get MCP tool at POST /mcp. Tool calls are converted to internal HTTP requests and sent back through Elysia:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "users.get",
"arguments": {
"params": { "id": "user_123" }
}
}
}
Explicit MCP primitives
Install the plugin, then register MCP-only behavior alongside your HTTP routes:
const app = new Elysia()
.use(mcp({ allowedRoutes: [] }))
.mcpTool(
'math.add',
({ a, b }: { a: number; b: number }) => ({ sum: a + b }),
{
inputSchema: {
type: 'object',
properties: {
a: { type: 'number' },
b: { type: 'number' }
},
required: ['a', 'b'],
additionalProperties: false
}
}
)
.mcpResource('config://runtime', () => ({ environment: 'production' }))
.mcpPrompt(
'review-error',
({ message }: { message: string }) => `Review this error: ${message}`
)
Routes become tools by default. Resources and prompts require explicit route metadata or the standalone methods above.
Documentation
The full guides and API reference live at mwillbanks.github.io/elysia-mcp-adapter:
- Installation and quick start
- Route-backed tools
- Resources and prompts
- Configuration reference
- Security model
Development
bun install
bun run lint
bun run typecheck
bun test
bun run fallow
bun run build
Documentation development runs independently from website/ with bun install and bun run dev.
License
MIT © Mike Willbanks
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。