This document explains how to use the Model Context Protocol (MCP) server that has been integrated into the fullstack_demo application. This allows AI agents like Claude Desktop to securely interact with your todos through a standardized protocol.
Model Context Protocol (MCP) is a standardized way for AI assistants to securely connect to external tools and services. This implementation allows Claude Desktop and other MCP-compatible AI agents to:
All operations are authenticated using Clerk OAuth tokens, ensuring secure access to your data.
The MCP server is built using:
src/app/[transport]/route.ts)
/mcp (HTTP) and /sse (Server-Sent Events) transports/.well-known/oauth-protected-resource/mcp - Resource metadata/.well-known/oauth-authorization-server - Authorization server metadata (backward compatibility)src/middleware.ts)
.well-known endpointsIMPORTANT: Before the MCP server can work, you must enable dynamic client registration in your Clerk Dashboard.
This allows MCP-compatible clients to automatically register themselves during the OAuth flow.
cd /Users/anthonymays/source/forks/code-society-25-2/lib/javascript/fullstack_demo
npm run dev
The server will start on http://localhost:3000 (or your configured port).
The easiest way to connect AI agents to your MCP server is using the mcp-remote utility:
npx -y mcp-remote http://localhost:3000/mcp
This command:
If you prefer to manually configure your AI agent:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.json{
"mcpServers": {
"fullstack_demo_todos": {
"url": "http://localhost:3000/mcp",
"transport": "streamable-http",
"auth": {
"type": "oauth2",
"authorizationUrl": "http://localhost:3000/.well-known/oauth-authorization-server"
}
}
}
}
Note: The tokenUrl is automatically discovered from the authorization server metadata.
Restart your AI agent
When the agent tries to use the MCP server, you’ll be prompted to authenticate via Clerk OAuth.
When deploying to production:
mcp-remote:
npx -y mcp-remote https://your-production-domain.com/mcp
Or update your AI agent’s configuration manually:
{
"mcpServers": {
"fullstack_demo_todos": {
"url": "https://your-production-domain.com/mcp",
"transport": "streamable-http",
"auth": {
"type": "oauth2",
"authorizationUrl": "https://your-production-domain.com/.well-known/oauth-authorization-server"
}
}
}
}
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEYCLERK_SECRET_KEYget-todosGets all todos for the authenticated user.
Parameters: None
Example Response:
[
{
"id": 1,
"text": "Buy groceries",
"completed": false
},
{
"id": 2,
"text": "Finish homework",
"completed": true
}
]
create-todoCreates a new todo for the authenticated user.
Parameters:
text (string, required): The text content of the todocompleted (boolean, optional): Whether the todo is completed (defaults to false)Example Response:
{
"id": 1234567890,
"text": "New todo item",
"completed": false
}
update-todoUpdates an existing todo for the authenticated user.
Parameters:
id (number, required): The ID of the todo to updatetext (string, optional): The new text content of the todocompleted (boolean, optional): Whether the todo is completedExample Response:
{
"id": 1234567890,
"text": "Updated todo text",
"completed": true
}
delete-todoDeletes a todo for the authenticated user.
Parameters:
id (number, required): The ID of the todo to deleteExample Response:
{
"success": true,
"deletedId": 1234567890
}
get-clerk-user-dataGets data about the Clerk user that authorized the request.
Parameters: None
Example Response:
{
"id": "user_xxxxxxxxxxxxx",
"firstName": "John",
"lastName": "Doe",
"emailAddresses": [...],
...
}
Once configured, you can interact with your todos naturally through Claude:
Example Prompts:
Claude will use the appropriate MCP tools to interact with your todo list securely.
.well-known endpoints are publicly accessible for OAuth discovery.envsrc/app/[transport]/route.ts - Main MCP server handlersrc/app/.well-known/oauth-protected-resource/mcp/route.ts - OAuth resource metadatasrc/app/.well-known/oauth-authorization-server/route.ts - OAuth server metadatasrc/middleware.ts - Updated to allow public access to .well-known endpointspackage.json - Added MCP dependencies@vercel/mcp-adapter - MCP protocol handler@clerk/mcp-tools - Clerk OAuth integration for MCP