Skip to main content
Glama
amir1824

mcp-trellis

mcp-trellis

CI License: MIT

Host-agnostic MCP + OAuth ports — you bring the runtime and IdP; the library owns the connector protocol.

Web-standard RequestResponse. Same handler on Cloudflare Workers, Next.js App Router, Deno, Bun, and Node HTTP via mcp-trellis/node. Zero runtime dependencies.

Why mcp-trellis

The whole connector stack in one package — MCP handler and OAuth 2.1 authorization server — with no database and no vendor signup. You own login, token minting, and storage; the library owns the protocol.

mcp-trellis

Official MCP SDK

workers-oauth-provider

@mcpauth/auth

Auth0 / Clerk / Authlete

MCP handler

OAuth 2.1 authorization server

❌ bring your own

Runtime

any Web-standard

any Web-standard

Workers only

Node

Database

none

KV (optional)

required

Runtime dependencies

zero

several

several

several

Self-hosted

❌ SaaS

Named connector profiles (Claude / Gemini / Codex), enforced

Prefer the official SDK when you already have a separate AS. Prefer workers-oauth-provider when you want Cloudflare's Workers-only implementation. Prefer a managed IdP when you'd rather pay than operate one.

Named alternatives in the same problem space:

  • @mcpauth/auth / getmcpauth / mcp-auth — OAuth for MCP, typically with a DB or a different runtime/stack assumption. mcp-trellis is the zero-dependency option that ships the MCP handler and the OAuth 2.1 AS in one package.

  • fastmcp-oauth — OAuth helpers around FastMCP. mcp-trellis is host-agnostic (Request/Response) and not tied to a particular MCP framework.

Related MCP server: Remote MCP Server on Cloudflare

Requirements

  • Node ≥ 20 for Node hosts (global WebCrypto in ESM)

  • Or any runtime with WebCrypto + fetch (Workers, Deno, Bun)

Install

npm install mcp-trellis

Quick start

One call mounts the MCP endpoint, the OAuth authorization server, and both discovery documents:

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) };

You return the token's audience; the library rejects tokens minted for a different resource before any tool runs. Details: docs/security.md.

A real /authorize walk includes an approval step: a resolved session doesn't redirect straight back with a code, it renders a consent screen first (built in, or your own via consent). First-time integrators clicking through by hand should expect an HTML page there, not an immediate redirect — see Consent.

Smoke-test with initialize (public — no Bearer needed):

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

Clients

Client

Registration

Token endpoint auth

Notes

claude

Dynamic (DCR), public + PKCE

none

Claude Custom Connectors callback allowlisted

gemini

Pre-registered, confidential

client_secret_basic, client_secret_post

Supply auth.clientStore

codex

OAuth 2.1 per MCP auth spec, public + PKCE

none

ChatGPT / Codex share one contract

Pre-registered clients, DCR enforcement, and clientStore wiring: docs/guide.md#clients.

Architecture

createMcpApp wires MCP and OAuth and routes between them:

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

Sequence: OAuth authorize and token, then MCP tool call

Host recipes, ports, tools, and multi-tenant: docs/guide.md.

Docs

Doc

Contents

docs/guide.md

Architecture, clients, recipes, ports, tools, multi-tenant

docs/reference.md

Routes, methods, status codes, options, exports

docs/security.md

Protocol promises, threat model, not in scope

docs/ROADMAP.md

What's next

Examples: examples/ — HTTP server, Worker, multi-tenant, stores, audit.

Contributing

PRs welcome — see CONTRIBUTING.md.

npm test
npm run build
npm run typecheck

License

MIT

A
license - permissive license
Not graded
quality - not tested
A
maintenance

Maintenance

Maintainers
Response time
2dRelease cycle
4Releases (12mo)
Commit activity

Related MCP Servers

  • F
    license
    Not graded
    quality
    C
    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
    C
    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
    D
    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.
    16
    138
    ISC
  • 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.
    13
    26
    MIT

View all related MCP servers

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.

View all MCP Connectors

Latest Blog Posts

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