mcp-trellis
mcp-trellis
ホスト非依存の MCP + OAuth ポート — あなたがランタイムと IdP を持ち込み、ライブラリがコネクタプロトコルを所有します。
Web 標準の Request → Response。同じハンドラーを Cloudflare Workers、Next.js App Router、Deno、Bun、そして mcp-trellis/node 経由の Node HTTP で利用できます。ランタイム依存はゼロです。
なぜ mcp-trellis なのか
コネクタスタック全体を 1 つのパッケージに — MCP ハンドラー と OAuth 2.1 認可サーバー — データベースも、ベンダーへの登録も不要です。ログイン、トークン発行、ストレージはあなたが管理し、プロトコルはライブラリが管理します。
人工 | mcp-trellis | 公式 MCP SDK |
|
| Auth0 / Clerk / Authlete |
MCP ハンドラー | ✅ | ✅ | ❌ | ❌ | ❌ |
OAuth 2.1 認可サーバー | ✅ | ❌ self 前で用意 | ✅ | ✅ | ✅ |
ランタイム | 任意の Web 標準 | 任意の Web 標準 | Workers のみ | Node | — |
データベース | なし | — | KV(任意) | 必須 | — |
ランタイム依存関係 | ゼロ | 複数 | 複数 | 複数 | — |
セルフホスト | ✅ | ✅ | ✅ | ✅ | ❌ SaaS |
名前付きコネクタプロファイル(Claude / Gemini / Codex)の強制 | ✅ | ❌ | ❌ | ❌ | ❌ |
既に別の認可サーバー(AS)がある場合は、公式 SDK を優先してください。Cloudflare の Workers 専用実装が必要なら、workers-oauth-provider を優先してください。運用するよりも支払う方を選ぶなら、マネージド IdP を優先してください。
同問題の領域にある名前付きの代替実装:
@mcpauth/auth/getmcpauth/mcp-auth— MCP 向けの OAuth で、通常は DB や異なるランタイム/スタックを前提とします。mcp-trellis は、MCP ハンドラー と OAuth 2.1 認可サーバーを 1 つのパッケージに同梱するゼロ依存の選択肢です。fastmcp-oauth— FastMCP の OAuth ヘルパーです。mcp-trellis はホスト非依存(Request/Response)であり、特定の MCP フレームワークに縛られません。
Related MCP server: Remote MCP Server on Cloudflare
必要条件
Node ホストでは Node ≥ 20(ESM でグローバル WebCrypto を利用)
または WebCrypto +
fetchを持つ任意のランタイム(Workers、Deno、Bun)
インストール
npm install mcp-trellisクイックスタート
1 回の呼び出しで、MCP エンドポイント、OAuth 認可サーバー、そして両方のディスカバリドキュメントをマウントします:
import { createMcpApp } from "mcp-trellis";
const app = createMcpApp({
serverInfo: { name: "demo", version: "1.0.0" },
clients: ["claude"],
tools: [
{
name: "echo",
description: "Echo text back",
inputSchema: {
type: "object",
properties: { text: { type: "string" } },
required: ["text"],
},
scope: "mcp",
handler: (_ctx, args) => String(args.text ?? ""),
},
],
auth: {
codeSecret: process.env.OAUTH_CODE_SECRET!,
resolveUser: async (req) => getSession(req),
loginUrl: (_req, next) => `/login?next=${encodeURIComponent(next)}`,
mintAccessToken: async ({ userId, scope, resource }) => ({
// Embed `resource` as the token audience (RFC 8707).
accessToken: await issueUserToken(userId, { aud: resource, scope }),
expiresIn: 3600,
}),
verifyToken: async (token) => {
const claims = await readUserToken(token);
if (!claims) return null;
return {
userId: claims.sub,
scopes: claims.scope.split(" "),
audience: claims.aud,
};
},
},
});
export default { fetch: (req: Request) => app.fetch(req) };トークンの audience を返してください。別のリソース用に発行されたトークンは、どのツールが実行されるよりも前にライブラリが拒否します。詳細は docs/security.md を参照してください。
実際の /authorize フローには承認ステップが含まれます:解決済みのセッションは、コードを付けたまま直接リダイレクトするのではなく、まず同意画面(組み込み、または consent による独自実装)を表示します。手動でクリックして試す初めての統合者は、即時リダイレクトではなく HTML ページが表示されることを期待してください — 詳細は Consent を参照してください。
initialize でスモークテスト(公開 — Bearer 不要):
curl -s http://127.0.0.1:8787/mcp \
-H 'content-type: application/json' \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18"}}'{"jsonrpc":"2.0","id":1,"result":{"protocolVersion":"2025-06-18","capabilities":{"tools":{}},"serverInfo":{"name":"demo","version":"1.0.0"},"instructions":""}}クライアント
クライアント | 登録 | トークンエンドポイント認証 | 備考 |
| 動的登録(DCR)、パブリック + PKCE |
| Claude Custom Connectors のコールバックは許可リストに登録されます |
| 事前登録済み、機密クライアント |
|
|
| MCP 認証仕様による OAuth 2.1、パブリック + PKCE |
| ChatGPT / Codex は 1 つのコントラクトを共有します |
事前登録済みクライアント、DCR の強制、clientStore の導線概要については docs/guide.md#clients を参照してください。
アーキテクチャ
createMcpApp は MCP と OAuth を配線し、それらの間をルーティングします:
ホストのレシピ、ポート、ツール、およびマルチテナントについては docs/guide.md を参照してください。
ドキュメント
ドキュメント | 内容 |
アーキテクチャ、クライアント、レシピ、ポート、ツール、マルチテナント | |
ルート、メソッド、ステータスコード、オプション、エクスポート | |
プロトコルの約束、脅威モデル、スコープ外 | |
今後の予定 |
例: examples/ — HTTP サーバー、Worker、マルチテナント、ストア、監査。
コントリビューション
PR 歓迎 — CONTRIBUTING.md を参照してください。
npm test
npm run build
npm run typecheckライセンス
MIT
This server cannot be installed
Maintenance
Related MCP Servers
- FlicenseNot gradedqualityCmaintenanceEnables deploying a Model Context Protocol (MCP) server on Cloudflare Workers with built-in OAuth authentication. It allows local clients like Claude Desktop to securely connect to and use remote tools through an HTTP/SSE transport.
- FlicenseNot gradedqualityCmaintenanceEnables deploying and running a Model Context Protocol (MCP) server on Cloudflare Workers with built-in OAuth authentication. It allows users to host and access tools remotely via Server-Sent Events (SSE) transport from clients like Claude Desktop.
- AlicenseNot gradedqualityDmaintenanceA dual-runtime template for building Model Context Protocol servers compatible with Node.js and Cloudflare Workers. It features integrated OAuth, encrypted token storage, and multi-tenant session management to simplify the creation of secure tool, resource, and prompt interfaces.16138ISC
- AlicenseNot gradedqualityDmaintenanceEnables developers to build OAuth-protected MCP servers on Cloudflare Workers with pluggable authentication adapters, allowing user-specific access control and secure token exchange.1326MIT
Related MCP Connectors
Self-hosted federated MCP gateway: one OAuth 2.1 MCP server in front of N apps, user-level scopes.
Artifact store for AI agents. Hosted OAuth at mcp.artifacta.io/mcp; local stdio via npm/PyPI.
Self-hosted MCP gateway: turn any API, database or MCP server into AI connectors — no code.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/amir1824/mcp-trellis'
If you have feedback or need assistance with the MCP directory API, please join our Discord server