Use this file to discover all available pages before exploring further.
The Todo TypeScript server showcases a complete CRUD (Create, Read, Update, Delete) application built with MCP. It demonstrates service-oriented architecture and state management patterns.
server.tool( "TODO-Create", "Create a new todo item", { task: z.string().describe("The task to add to the todo list"), }, async ({task}) => { const todo = createTodo(task); return { content: [{ type: "text", text: `Todo created: ${todo.task}`, }], }; });
server.tool( "TODO-Complete", "Complete a todo item", { id: z.string().describe("The id of the todo item to complete"), }, async ({id}) => { const todo = completeTodo(id); return { content: [{type: "text", text: `Todo completed: ${todo?.task}`}], }; });
{ "id": "abc123", "task": "Master the MCP protocol"}
Response:
Todo updated: Master the MCP protocol
Implementation:
server.tool( "TODO-Update", "Update a todo item", { id: z.string().describe("The id of the todo item to update"), task: z.string().describe("The new task for the todo item"), }, async ({id, task}) => { const todo = updateTodoTask(id, task); return { content: [{type: "text", text: `Todo updated: ${todo?.task}`}], }; });
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";import { z } from "zod";import { createTodo, getAllTodos, clearCompletedTodos, completeTodo, deleteTodo, updateTodoTask} from "./todo/todo.service.js";// Create server instanceconst server = new McpServer({ name: "TODO List MCP Server", version: "1.0.0", capabilities: { tools: {}, },});// ... tool definitions ...async function main() { const transport = new StdioServerTransport(); await server.connect(transport); console.error("[INFO] TODO MCP Server running on stdio");}main().catch((error) => { console.error("[ERROR] Fatal error in main():", error); process.exit(1);});
User: Add a todo to learn about MCP resourcesAssistant: [Uses TODO-Create]Todo created: Learn about MCP resourcesUser: What are my current todos?Assistant: [Uses TODO-List]You have 3 todos:1. Learn about MCP resources (pending)2. Build a calculator server (completed)3. Study TypeScript patterns (pending)User: Mark the first one as doneAssistant: [Uses TODO-Complete]Todo completed: Learn about MCP resources
The build script sets execute permissions. If you see permission errors:
chmod 755 build/index.js
Module resolution errors
Ensure your imports use .js extensions:
import { createTodo } from "./todo/todo.service.js";
This is required for ES modules even with TypeScript.
State persistence
This server uses in-memory storage. Todos are lost when the server restarts. For persistence, implement file-based or database storage in the service layer.