MCP Server Starter
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 Server Starter
A production-shaped starting point for putting an MCP server in front of an existing app, so AI assistants can act on your product on behalf of a logged-in user.
Clerk handles all the OAuth. That is the headline: your customers sign in through whatever identity provider they already use -- Okta, Entra ID, Google Workspace -- and it flows straight through to the MCP connection with no extra work from you. See docs/AUTH.md.
What you get
A working OAuth 2.1 authorization flow, including the discovery endpoints and dynamic client registration that MCP clients require. This is the part that eats a week if you hand-roll it.
Enterprise SSO for free, via Clerk connections.
Scope-gated tools -- callers only ever see the tools their grant covers.
A tool registry with one uniform handler signature, audit logging, and a sane error contract.
Three example tools showing the shape to copy.
Related MCP server: OAuth 2.1 MCP Server
What you have to write
One file: mcp/tools.ts. Plus services/index.ts, which is where you point at your app's real business logic instead of the shipped stub.
Building this with an AI assistant
This repo ships with AGENTS.md — standing instructions for coding agents. Claude Code picks it up automatically via CLAUDE.md; Cursor, Codex, and most other agents read AGENTS.md directly.
It tells the agent which two files to edit, which files to leave alone, the anti-patterns to refuse (a raw-SQL tool being the big one), and the exact commands to verify its own work rather than declaring success because the code compiled.
So the workflow is just: open the repo with your assistant and tell it what your app does and what your users need to accomplish. It has the rest.
One thing worth doing yourself: skim docs/TOOL-DESIGN.md first. Which tools you expose is a product decision, and it is the decision that determines whether the finished server is good. The agent can write them well; it cannot tell you what your users are trying to do.
Quickstart
npm install
cp .env.example .env.local # add your Clerk keys
npm run devThen in the Clerk Dashboard, enable dynamic client registration under OAuth applications (details and the security trade-off are in docs/AUTH.md).
Point an MCP client at http://localhost:3000/mcp. For local testing the MCP Inspector is the fastest path:
npx @modelcontextprotocol/inspectorYou should get bounced through a Clerk sign-in, land back in the client, and see three tools listed.
Layout
Path | What it is |
| Standing instructions for AI coding agents. |
| The file you edit. Your tool definitions. |
| The other file you edit. Adapter onto your app's business logic. Ships as a stub. |
| Tool type, scope filtering, error and result helpers. |
| Per-request context handed to every tool (user, org, scopes, services). |
| Scope definitions and the fail-closed check. |
| Metadata-only audit logging. |
| Auth-to-tools wiring. Serves |
| OAuth discovery documents. Must stay public. |
Read these before you build
docs/TOOL-DESIGN.md -- the one that actually determines whether your server is any good. Covers why exposing a generic query tool over your database is the wrong move, and what to do instead.
docs/AUTH.md -- how the Clerk flow works, the SSO story, and the dynamic-client-registration security setting you need to make a deliberate call on.
docs/ADAPTING.md -- step-by-step from clone to your own server.
Stack
Next.js 15 App Router · @modelcontextprotocol/sdk · mcp-handler · @clerk/nextjs + @clerk/mcp-tools · Zod. Deploys to Vercel as-is; nothing here is Vercel-specific except the convenience of it.
Built and verified against: next@15.5.23, @clerk/nextjs@6.39.6, @clerk/mcp-tools@0.2.2, mcp-handler@1.1.0, @modelcontextprotocol/sdk@1.26.0, zod@3.25.76. If something in the auth wiring stops working after an upgrade, that combination is a known-good baseline to fall back to.
What was actually tested
Not just "it compiles":
tsc --noEmitclean across all files, including the.well-knownroutes (which tsc's default globs skip, because the directory starts with a dot — they were checked separately).next buildsucceeds and registers all three routes, confirming Next.js does serve dot-directory paths.Unauthenticated
POST /mcpreturns401with a correctWWW-Authenticate: Bearer ... resource_metadata="..."header pointing at the metadata route.GET /.well-known/oauth-protected-resource/mcpreturns200with CORS headers and a well-formed document naming the Clerk authorization server.
The tools themselves have not been exercised against a live Clerk instance — that needs real keys. Step 1 of docs/ADAPTING.md walks through it.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Related MCP Connectors
MCP server connecting AI agents to 100+ apps (Gmail, Slack, Notion, GitHub) via one-click OAuth.
MCP server for Argo RPG Platform — connects AI assistants to campaign data via OAuth2
Zero-setup MCP gateway securely connecting AI to your tools with authentication and workflows
Official Fibery MCP server: query and update your workspace from any AI client via OAuth.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA production-ready template for building Model Context Protocol servers with Clerk authentication on Cloudflare Workers, allowing AI assistants to securely access user data and business logic in Clerk-authenticated applications.2MIT
- AlicenseNot gradedqualityDmaintenanceA Next.js-based MCP server template that implements OAuth 2.1 authentication with support for both SSE and Streamable HTTP transports. Provides a reference implementation for building authenticated MCP servers that work with Claude, Cursor, VSCode, and other MCP clients.32 npm6MIT
- FlicenseNot gradedqualityDmaintenanceA remote Model Context Protocol server template for Cloudflare Workers with built-in Clerk OAuth authentication and role-based access control. Enables secure deployment of MCP servers with user authentication and customizable tool access based on user roles.-
- AlicenseNot gradedqualityDmaintenanceA production-ready MCP server template that connects LLMs and AI agents to external data, tools, and services with built-in OAuth 2.1 authentication, Redis-backed session management, and a modular tools engine.1MIT