Skip to main content
Glama
mcp-trellis

mcp-trellis

mcp-trellis

CI License: MIT

ホスト非依存の 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

workers-oauth-provider

@mcpauth/auth

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":""}}

クライアント

クライアント

登録

トークンエンドポイント認証

備考

claude

動的登録(DCR)、パブリック + PKCE

none

Claude Custom Connectors のコールバックは許可リストに登録されます

gemini

事前登録済み、機密クライアント

client_secret_basic、client_secret_post

auth.clientStore を指定してください

codex

MCP 認証仕様による OAuth 2.1、パブリック + PKCE

none

ChatGPT / Codex は 1 つのコントラクトを共有します

事前登録済みクライアント、DCR の強制、clientStore の導線概要については docs/guide.md#clients を参照してください。

アーキテクチャ

createMcpApp は MCP と OAuth を配線し、それらの間をルーティングします:

Architecture: connector → edge → OAuth or MCP → your ports

Sequence: OAuth authorize and token, then MCP tool call

ホストのレシピ、ポート、ツール、およびマルチテナントについては docs/guide.md を参照してください。

ドキュメント

ドキュメント

内容

docs/guide.md

アーキテクチャ、クライアント、レシピ、ポート、ツール、マルチテナント

docs/reference.md

ルート、メソッド、ステータスコード、オプション、エクスポート

docs/security.md

プロトコルの約束、脅威モデル、スコープ外

docs/ROADMAP.md

今後の予定

例: examples/ — HTTP サーバー、Worker、マルチテナント、ストア、監査。

コントリビューション

PR 歓迎 — CONTRIBUTING.md を参照してください。

npm test
npm run build
npm run typecheck

ライセンス

MIT

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      Not graded
      maintenance
      Enables 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.
      -
    • F
      license
      Not graded
      quality
      Not graded
      maintenance
      Enables 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.
      -
    • A
      license
      Not graded
      quality
      B
      maintenance
      A 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.
      160
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables developers to build OAuth-protected MCP servers on Cloudflare Workers with pluggable authentication adapters, allowing user-specific access control and secure token exchange.
      15 npm
      26
      MIT