namanbarkiya/MCP-todo-client-server
If you are the rightful owner of MCP-todo-client-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
This document provides a comprehensive overview of a Model Context Protocol (MCP) server implementation using FastAPI and Next.js, designed to demonstrate an API-first approach for managing todos.
MCP AI Todo
An end-to-end demo showing an API-first MCP approach: a FastAPI backend exposes both a REST API and an MCP endpoint; a Next.js client consumes the REST API for UI and can orchestrate via MCP for tool-driven actions.
Why API-first MCP?
- The backend (FastAPI) owns the source of truth and exposes capabilities as REST endpoints and MCP tools.
- The frontend (Next.js) stays thin and calls the API, while MCP can automate workflows via the same backend.
- Assistants in MCP-compatible clients can invoke the same server-side tools used by the UI.
Architecture
βββββββββββββββββββββββββββββββββ
β Next.js Frontend β
β (Tabs: Todos | MCP | Chat) β
βββββββββββββββββ¬ββββββββββββββββ
β
fetch /app/api/mcp β fetch /app/api/chat
β β
βΌ βΌ
ββββββββββββββββββββββββββββββ ββββββββββββββββββββββββ
β MCP API Routes β β Chat API Route β
β /api/mcp/tools β β (LLM + tool-calling) β
β /api/mcp/tool (invoke) β βββββββββββββββ¬βββββββββ
β /api/mcp/resources/prompts β β
ββββββββββββββββ¬ββββββββββββββ β server-side
β βΌ
β ββββββββββββββββββββββββββ
β β MCP Client SDK (JS) β
β β @modelcontextprotocol β
β βββββββββββββββ¬βββββββββββ
β β HTTP
βΌ β
ββββββββββββββββββββββββββββββ βΌ
β MCP Server (FastAPI) β βββββββββββββββββ
β Endpoint: POST /mcp β β LLM (Gemini)β
β Exposes MCP Tools: β βββββββββββββββββ
β - list_todos β function calls
β - get_todo β
β - create_todo β
β - update_todo β
β - delete_todo β
βββββββββββ¬βββββββββββββββββββ
β
REST β
ββββββββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββββββ
β FastAPI REST β
β GET/POST /todos/ | PUT/DELETE /todos/{id} β
βββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββ writes/reads βββββββββββββ
β CSV Service (CRUD) ββββββββββββββββββββββββββΊβ todos.csv β
β load/save/next id βββββββββββββββββββββββββββ β
ββββββββββββββββββββββββ data returned βββββββββββββ
Project Structure
mcp-ai-todo/
βββ .cursor/ # Cursor config for MCP tools
βββ backend/ # FastAPI REST API + MCP endpoint; CSV storage for todos
βββ frontend/ # Next.js client (shadcn/ui, Tailwind) with multi-tab UI
βββ README.md # This file
Backend (FastAPI + MCP)
Start the API server:
cd backend
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
uvicorn app.main:app --reload --port 8080
Key endpoints:
- REST: GET/POST
/todos/
, PUT/DELETE/todos/{id}/
- MCP: POST
/mcp
(Model Context Protocol endpoint)
Data store: backend/data/todos.csv
via a simple CSV service.
Frontend (Next.js)
Start the web client:
cd frontend
npm install
npm run dev
Environment variables:
NEXT_PUBLIC_API_BASE
(optional): defaults tohttp://localhost:8080
. Set if your backend runs elsewhere.
UI highlights (single-page, multi-tab):
- Todos: CRUD against FastAPI endpoints; inline edit, toggle, delete
- MCP Tools: lists available server tools exposed via MCP
- Chat: improved chat window; each response shows collapsible tool-call details
Tech:
- Next.js App Router, Tailwind CSS (v3), shadcn/ui components
- MCP client (
@modelcontextprotocol/sdk
) configured infrontend/lib/mcpClient.ts
Using MCP with this project
MCP is exposed at http://localhost:8080/mcp
. Any MCP-compatible client can connect and discover available tools. Typical flows:
- Ask the assistant to list/create/update/delete todos; the assistant calls MCP tools that use the same backend logic as the REST API.
- In the UI Chat tab, tool calls and results appear under each assistant response.
Example assistant prompts:
- βList all todos.β
- βCreate a todo βBuy groceriesβ.β
- βMark todo 3 as completed.β
Development Tips
- Keep server logic in the backend; expose as both REST and MCP tools.
- The UI should remain a thin client; avoid duplicating server logic in the frontend.
- To change styles, use shadcn/ui primitives and Tailwind utilities (no custom component boilerplate).
URLs
- Frontend:
http://localhost:3000
- API:
http://localhost:8080
- MCP:
http://localhost:8080/mcp