GUIDE.md
The Model Context Protocol (MCP) is a specification that enables AI models like Claude to interact with external tools and services. It creates a standardized way for LLMs to discover, understand, and use tools provided by separate processes.
GUIDE.md
The Model Context Protocol (MCP) is a specification that enables AI models like Claude to interact with external tools and services. It creates a standardized way for LLMs to discover, understand, and use tools provided by separate processes.
This Todo List MCP Server is designed to be a clear, educational example of how to build an MCP server. It implements a complete todo list management system that can be used by Claude or other MCP-compatible systems.
By studying this codebase, you can learn:
The project follows several key design principles:
The codebase is organized into distinct layers:
src/models/): Data structures and validation schemassrc/services/): Business logic and data accesssrc/utils/): Helper functions and formatterssrc/index.ts): MCP server definition and tool implementationsThis separation makes the code easier to understand, maintain, and extend.
The project uses TypeScript and Zod for comprehensive type safety:
A consistent error handling approach is used throughout:
safeExecute function standardizes error handlingThe project uses SQLite for simple but effective data storage:
Every MCP tool follows the same pattern:
server.tool( "tool-name", // Name: How the tool is identified "Tool description", // Description: What the tool does { /* parameter schema */ }, // Schema: Expected inputs with validation async (params) => { // Handler: The implementation function // 1. Validate inputs // 2. Execute business logic // 3. Format and return response } );
The error handling pattern ensures consistent behavior:
const result = await safeExecute(() => { // Operation that might fail }, "Descriptive error message"); if (result instanceof Error) { return createErrorResponse(result.message); } return createSuccessResponse(formattedResult);
Responses are consistently formatted for easy consumption by LLMs:
// Success responses return createSuccessResponse(`✅ Success message with ${formattedData}`); // Error responses return createErrorResponse(`Error: ${errorMessage}`);
Todo model in src/models/Todo.tssrc/index.tssrc/services/TodoService.tssrc/utils/formatters.tsUse the provided test client to see the server in action:
npm run build node dist/client.js
This will run through a complete lifecycle of creating, updating, completing, and deleting a todo.
To use this server with Claude for Desktop, add it to your claude_desktop_config.json:
{ "mcpServers": { "todo": { "command": "node", "args": ["/absolute/path/to/todo-list-mcp/dist/index.js"] } } }
This Todo List MCP Server demonstrates a clean, well-structured approach to building an MCP server. By studying the code and comments, you can gain a deep understanding of how MCP works and how to implement your own MCP servers for various use cases.
The project emphasizes not just what code to write, but why specific approaches are taken, making it an excellent learning resource for understanding both MCP and general best practices in TypeScript application development.
This Todo List MCP Server is designed to be a clear, educational example of how to build an MCP server. It implements a complete todo list management system that can be used by Claude or other MCP-compatible systems.
By studying this codebase, you can learn:
The project follows several key design principles:
The codebase is organized into distinct layers:
src/models/): Data structures and validation schemassrc/services/): Business logic and data accesssrc/utils/): Helper functions and formatterssrc/index.ts): MCP server definition and tool implementationsThis separation makes the code easier to understand, maintain, and extend.
The project uses TypeScript and Zod for comprehensive type safety:
A consistent error handling approach is used throughout:
safeExecute function standardizes error handlingThe project uses SQLite for simple but effective data storage:
Every MCP tool follows the same pattern:
server.tool( "tool-name", // Name: How the tool is identified "Tool description", // Description: What the tool does { /* parameter schema */ }, // Schema: Expected inputs with validation async (params) => { // Handler: The implementation function // 1. Validate inputs // 2. Execute business logic // 3. Format and return response } );
The error handling pattern ensures consistent behavior:
const result = await safeExecute(() => { // Operation that might fail }, "Descriptive error message"); if (result instanceof Error) { return createErrorResponse(result.message); } return createSuccessResponse(formattedResult);
Responses are consistently formatted for easy consumption by LLMs:
// Success responses return createSuccessResponse(`✅ Success message with ${formattedData}`); // Error responses return createErrorResponse(`Error: ${errorMessage}`);
Todo model in src/models/Todo.tssrc/index.tssrc/services/TodoService.tssrc/utils/formatters.tsUse the provided test client to see the server in action:
npm run build node dist/client.js
This will run through a complete lifecycle of creating, updating, completing, and deleting a todo.
To use this server with Claude for Desktop, add it to your claude_desktop_config.json:
{ "mcpServers": { "todo": { "command": "node", "args": ["/absolute/path/to/todo-list-mcp/dist/index.js"] } } }
This Todo List MCP Server demonstrates a clean, well-structured approach to building an MCP server. By studying the code and comments, you can gain a deep understanding of how MCP works and how to implement your own MCP servers for various use cases.
The project emphasizes not just what code to write, but why specific approaches are taken, making it an excellent learning resource for understanding both MCP and general best practices in TypeScript application development.