Todo MCP Server
A Model Context Protocol server with a built-in OAuth 2.1 authorization server and a Next.js todo app, enabling authenticated task management (create, read, update, delete tasks) via natural language through an MCP client.
README
Todo MCP Server
A Model Context Protocol server with a from-scratch OAuth 2.1 authorization server, built inside a Next.js todo app. Connect Claude (or any MCP client) to it and the full flow works end to end: dynamic client registration → PKCE authorization → token exchange → authenticated tool calls scoped to the signed-in user.
I built this to understand what actually happens when an LLM client connects to a remote MCP server — not just the tool definitions, but the entire auth handshake underneath. No auth library for the OAuth server; every endpoint is hand-rolled against the RFCs.
What's implemented
MCP server (src/mcp/, served at /api/mcp via Streamable HTTP):
- 6 task tools:
list_tasks,get_task,create_task,update_task,complete_task,delete_task - Zod input validation and tool annotations (
readOnlyHint,destructiveHint,idempotentHint) userIdcomes only from the validated Bearer token, never from tool arguments — an LLM cannot ask for another user's tasks- Stateless per-request handling, serverless-friendly
OAuth 2.1 authorization server (hand-rolled):
- Dynamic Client Registration — RFC 7591 (
/register) - Authorization Code + PKCE S256 (
/authorizewith a real consent page) - Server metadata discovery — RFC 8414
(
/.well-known/oauth-authorization-server) plus protected-resource metadata for MCP clients - Token endpoint with
authorization_codeandrefresh_tokengrants - Access tokens: stateless JWTs, 1h TTL, audience-bound to
/api/mcp(a token minted for this resource is rejected everywhere else) - Single-use authorization codes with 5-minute expiry; persisted refresh tokens with 30-day TTL
The app itself: Next.js 16 + React 19 + Prisma 7 + PostgreSQL, task CRUD behind a service layer that both the web UI and the MCP tools share.
Quick start
Requires Node 20+ and PostgreSQL.
npm install
cp .env.example .env # set DATABASE_URL and JWT_SECRET
npx prisma migrate deploy
node scripts/seed-mock-users.mjs
npm run dev
Then either use the web UI at http://localhost:3000, or run the proof
scripts:
# Bearer-token MCP session: lists tools, calls them, proves per-user scoping
node scripts/mcp-test.mjs
# Full OAuth 2.1 handshake: DCR → PKCE authorize → token exchange →
# authenticated MCP call → refresh grant. Exactly what Claude does internally.
node scripts/oauth-e2e.mjs
# Against a public tunnel instead of localhost:
BASE=https://your-tunnel.example.com node scripts/oauth-e2e.mjs
Connecting Claude
Add the server URL (https://<host>/api/mcp) as a custom connector — the
client discovers the authorization server via .well-known, registers
itself, and walks the PKCE flow against the consent page.
Security notes
- Auth codes are consumed atomically before validation — replay gets a 400
- PKCE S256 verified on every code exchange
- JWT
audclaim pins tokens to the MCP resource (no token passthrough) - Every service-layer query is scoped
where: { userId }— ownership is enforced below the tool layer, so a buggy tool can't leak across users - Sign-in is passwordless-by-email for local development only; wiring a real identity provider is the obvious next step for production use
Design
The phased plan and decisions (why audience binding, why stateless access tokens + persisted refresh tokens, why the service layer owns scoping) are in docs/specs/2026-07-03-todo-mcp-server-design.md.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。