mcp-trellis
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
mcp-trellis
Add user-scoped MCP to your existing TypeScript SaaS. Keep your login. Own your OAuth.
Claude and ChatGPT act as the signed-in user, not as a shared service account. The OAuth authorization server runs inside your app, reuses your session, and has zero runtime dependencies. Node 20+.

The 30-second example
import { createMcpApp, signedTokenAuth } from "mcp-trellis";
import { session, projectsForUser, codeStore } from "./your-app.js";
export const mcp = createMcpApp<{ userId: string }>({
serverInfo: { name: "my-saas", version: "1.0.0" }, clients: ["claude", "codex"],
auth: signedTokenAuth({
secret: process.env.MCP_SECRET!,
resolveUser: (req) => session(req),
loginUrl: (_r, n) => `/login?next=${encodeURIComponent(n)}`,
codeStore,
}),
context: (_r, p) => ({ userId: p?.id ?? "" }),
tools: [{ name: "list_my_projects", description: "List projects",
inputSchema: { type: "object", properties: {} }, scope: "mcp",
handler: async ({ userId }) => JSON.stringify(await projectsForUser(userId)) }],
});That is the configuration, not the whole server. Mount the returned app (it has a fetch(Request) method) on your HTTP framework: Express, Next.js or a Cloudflare Worker. It serves /mcp, the OAuth routes and .well-known discovery.
You bring two things: your session lookup, and a shared store where a one-time login code can be used once (an atomic set-if-absent: Redis, Postgres, D1 or a Durable Object; Workers KV has no atomic NX).
clientspicks presets for the connector clients you serve (default["claude"]): their callback URIs and token-endpoint auth methods. It is not an allowlist: dynamic registration accepts any client whose redirect URI passes the policy, and loopback redirects are allowed by default. See Locking down who can register.OAuth tells your server who is calling. It does not say which tenant or record that user may touch: check that in your data layer on every operation.
Client ID Metadata Documents (CIMD) are off by default: set
cimd: trueand passcimdCache, or every refresh and revoke fetches the client document again. Dynamic Client Registration works too.
Protocol versions. MCP 2024-11-05, 2025-03-26, 2025-06-18 and 2025-11-25 (default 2025-06-18) are negotiated in initialize; for 2025-11-25 the optional additions (icons, tasks, URL elicitation, sampling with tools, SSE polling) are not implemented. MCP 2026-07-28 is served per request when the client sends MCP-Protocol-Version: 2026-07-28 with the _meta and Mcp-Method fields that revision requires. An unknown MCP-Protocol-Version header gets a 400. Details: reference.
Related MCP server: Remote MCP Server on Cloudflare
Quick start
npm install mcp-trellisWire
resolveUserandloginUrlto your existing session.Wire
codeStoreto a shared single-use store (Redis, Postgres, D1 or a Durable Object). mcp-trellis does not ship one; copy the adapter in examples/stores.ts.allowInMemoryCodeStore: trueis for single-process demos only.Deploy over HTTPS, then add your
/mcpURL as a custom connector in Claude. The client guide lists the client profiles.
To run the local Alice and Bob demo (login, consent, then list_my_projects), set two variables first. It stops with an error without them.
export DEMO_PASSWORD="$(openssl rand -hex 16)"
export OAUTH_CODE_SECRET="$(openssl rand -hex 32)"
npm run demoOpen http://127.0.0.1:8787 and sign in as Alice or Bob with $DEMO_PASSWORD. More in examples/saas-demo.
Tool UIs, resources and skills
MCP Apps. A tool can point at an HTML view that a host with MCP Apps renders next to the result. The view calls back through your
/mcpendpoint, so scopes, validation,contextandauditstill apply. Documents arehtmlorblob, with CSP, permissions,domainandprefersBorder. For 2026-07-28 requests the server sends the UI only to a client that declared the Apps extension.Typed results. A tool can declare an
outputSchema(checked against each result) andannotations;structuredContentmay be any JSON value for 2026-07-28 clients. Schemas are evaluated natively as JSON Schema 2020-12;x-mcp-headermirrors an argument into a request header. See docs/reference.md.Resources.
resourcesserves read-only text to the principals allowed to see it. See docs/resources.md.Skills (experimental).
skillsserves Agent Skills over MCP, opt-in. See docs/skills.md.
import { createMcpApp, defineTool } from "mcp-trellis";
const listProducts = defineTool({
name: "list_products",
description: "Show the signed-in user's products",
inputSchema: { type: "object", properties: {} },
scope: "mcp",
ui: { resourceUri: "ui://shop/products" }, // must match a uiResources entry
handler: async (ctx) => ({
content: [{ type: "text", text: "2 products" }], // fallback for hosts without MCP Apps
structuredContent: { items: await loadProducts(ctx) }, // what the view receives
}),
});
export const mcp = createMcpApp({
// ...serverInfo, auth, context as above
tools: [listProducts],
uiResources: [{ uri: "ui://shop/products", html: productsHtml }],
});No MCP Apps host and no 2026-07-28 client is verified by this project's tests. Setup, CSP and limits: docs/mcp-apps.md.
How it fits together

The blue boxes ship in the package. The purple and green boxes are yours to plug in: your session, a code store, token handling and your data layer. signedTokenAuth gives you a default for the token ports. Editable source: architecture.drawio.
When to use it, and when not
Use it when:
Your TypeScript app already has login and user data, and Claude or ChatGPT should read and act on a signed-in user's own data (projects, tickets, invoices) with no shared service account.
You want the MCP handler and the OAuth endpoints in one package, on Next.js, Express or Cloudflare Workers.
Your tools should follow the permissions and tenant boundaries the app already enforces (multi-tenant).
Skip it when:
You need a managed identity provider, a user database, or a login system built for you.
You need a client that is not in the client table below.
You only need a local stdio tool, or you already run an MCP server and authorization server that meet your needs.
Compared with the alternatives
Option | Who hosts the authorization server | You need | Choose it when |
mcp-trellis | Your app | Your session lookup and a shared single-use store | You want no new vendor, database or hosted service |
Your app | Better Auth, its database schema and the JWT plugin | You already use Better Auth | |
Your Worker | A Workers-only app and a KV namespace | You run only on Workers and want Cloudflare's own library | |
Scalekit | A Scalekit dashboard and SDK | You want a hosted identity provider instead of running the authorization server | |
WorkOS | A Login URI set in WorkOS, and a call to AuthKit's completion API from your login | You want the authorization server hosted for you and still keep your own login | |
Nobody. v2 ships resource-server helpers only; the old authorization server helpers live in a frozen, deprecated | An authorization server from somewhere else | You already have one and only need to verify its tokens |
Checked 2026-11-07. Re-verify before you decide.
Integrate with your app
Choose your token mode:
Start with
signedTokenAuth: one secret. Access tokens are stateless; the only stored state is single-use marks incodeStore. A token cannot be revoked before it expires; passisUserActiveto cut off a user at once.Need revocable tokens, refresh-token families or your own JWT/JWKS? Implement the
mintAccessToken,verifyToken,refreshAccessTokenandrevokeTokenports.Mint tokens for the requested MCP resource and return the verified
audience. The library rejects a mismatch before a tool runs.A token outlives the login session that produced it.
isUserActivestops a removed or disabled user on the next request.refreshTtlSeconds(needscodeStoreandisUserActive) lets a connector renew without a browser trip. See Sessions and expiry and the production auth profile.
Before you ship:
Your data layer must enforce ownership and tenancy. The library does not.
Users always see an OAuth consent screen, even when signed in to your app.
A request with an
Originheader is rejected unless it matchesallowedRequestOrigins. Native connectors send none.CIMD fetches client metadata over HTTPS, for public clients only. By default the connection is not pinned to the looked-up IP, so DNS rebinding is possible; see
cimdFetchin the reference and security.md.There is no built-in rate limiting. Put quotas on
/registerand/tokenat your edge or reverse proxy, and on/authorizetoo whencimd: true. With anauditsink that stores entries, limit/mcptoo.No third-party security audit has been done. The threat model is in security.md.
Clients and compatibility
Profile | Implemented server flow | Live client evidence |
Claude ( | Dynamic registration, public client, PKCE; CIMD with | Verified manually by the maintainer (connects and works), 2026-11; no recorded transcript |
ChatGPT / Codex ( | Public client, PKCE; ChatGPT's stable and per-connector callbacks allowed | ChatGPT connector verified manually by the maintainer (connects and works), 2026-11; no recorded transcript. Codex CLI not tested |
Gemini Enterprise ( | Pre-registered client; secret basic/post; requires | Pending; does not imply every Gemini product |
The OAuth flows above run in automated tests and in the local demo. The Claude and ChatGPT results are manual checks, not CI runs. See client configuration and troubleshooting.
Docs
Doc | Contents |
Clients, ports, consent, tools, multi-tenant | |
Attach a UI to a tool: setup, document fields, CSP, negotiation, limits | |
Serve read-only data as resources | |
Experimental: Agent Skills over MCP | |
Routes, methods, status codes, options, exports | |
Protocol promises, threat model, sessions, not in scope | |
Connection, token, schema and header errors |
Examples: project-desk (reference remote server), saas-demo, nextjs-saas. All in examples/.
Contributing
Open an issue for a bug or gap. Pull requests are welcome: see CONTRIBUTING.md and the Code of Conduct.
License
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Self-hosted federated MCP gateway: one OAuth 2.1 MCP server in front of N apps, user-level scopes.
Hosted MCP server with managed OAuth for 15+ toolkits: Google Workspace, Fitbit, Oura, Kalshi, etc.
Artifact store for AI agents. Hosted OAuth at mcp.artifacta.io/mcp; local stdio via npm/PyPI.
One OAuth connector for your team's remote MCP servers, with Tool Packs, guardrails and logs.
Related MCP Servers
- FlicenseNot gradedqualityNot gradedmaintenanceEnables 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 gradedqualityNot gradedmaintenanceEnables 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 gradedqualityBmaintenanceA 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.160MIT
- 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.15 npm26MIT