TodoMCPServer

cpateldev/TodoMCPServer

3.2

If you are the rightful owner of TodoMCPServer and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

The Model Context Protocol (MCP) server is a versatile tool that extends traditional REST APIs with AI agent tooling capabilities, allowing seamless interaction with AI assistants.

Tools
11
Resources
0
Prompts
0

Todo MCP Server (.NET Minimal API with MCP server support)

Table of contents

Overview

TodoMCPServer is a modern .NET 10 application that combines a traditional REST API with Model Context Protocol (MCP) server capabilities for todo list management. The project serves as both a standard web API and an MCP-enabled service that can be integrated with AI assistants like Claude Desktop, Gemini Code Assist, and other MCP-compatible tools.

TodoMCPServer is a comprehensive implementation that combines a Todo web API with Model Context Protocol (MCP) server support. This project demonstrates how traditional REST APIs can be extended with AI agent tooling capabilities through MCP, allowing AI assistants to interact with your application directly.

Architecture Diagram

requires mermaid extension in VS Code

flowchart TD
    A[Client Applications] --> B{Interaction Layer}
    B --> C[REST API<br/>11 Endpoints]
    B --> D[MCP Server<br/>11 Tools]
    C --> E[Business Logic Layer]
    D --> E
    E --> F[Data Access Layer]
    F --> G[In-Memory EF Context]

    H[Swagger UI] --> C
    I[Claude Desktop] --> D
    J[VSCode Gemini Code Assist] --> D
    K[VSCode GitHub Copilot] --> D
    L[Visual Studio GitHub Copilot] --> D

Features

  • Dual Interface: Both REST API (11 endpoints) and MCP server (11 tools)
  • Modern Stack: .NET 10 with Minimal API architecture
  • Database: Entity Framework Core with In-Memory DB provider
  • API Documentation: OpenAPI/Swagger UI integration
  • MCP Server Support: MCP Server support using both HTTP and STDIO transport types
  • MCP Integration: Pre-configured with Claude Desktop, Gemini Code Assist, Visual Studio Github Copilot, and VSCode MCP Client for major AI development tools
  • ** MCP Inspector Support**: Easily test MCP tools using MCP Inspector using HTTP or STDIO transport types
  • Cross-Platform: Runs on any platform supporting .NET 10

Tools and MCP Clients

.NET 10 Entity Framework Core ASP.NET Core OpenAPI Swagger UI MCP Protocol

Claude Desktop Visual Studio GitHub Copilot VSCode GitHub Copilot Gemini Code Assist

Prerequisites

  • .NET 10 SDK or later
  • Visual Studio 2025+ or VS Code with C# Dev Kit
  • Git for version control
  • For MCP testing: GitHub Copilot in VS Code, Claude Desktop, Gemini Code Assist, or any MCP-compatible client

Create a New Project named TodoMCPServer

dotnet new webapi -n TodoMCPServer
cd TodoMCPServer

Add Required NuGet Packages

dotnet add package Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore --version 10.0.0
dotnet add package Microsoft.AspNetCore.OpenApi --version 10.0.0
dotnet add package Microsoft.EntityFrameworkCore.InMemory --version 10.0.0
dotnet add package ModelContextProtocol --version 0.4.1-preview.1
dotnet add package ModelContextProtocol.AspNetCore --version 0.4.1-preview.1
dotnet add package Swashbuckle.AspNetCore.SwaggerUI --version 10.0.1

Update Program.cs to Configure MCP Server

builder.Services
    .AddMcpServer()
    .WithStdioServerTransport()   // Use stdio transport for local AI clients
    .WithHttpTransport()          // Use HTTP transport for web-based clients
    .WithToolsFromAssembly();     // Automatically register all MCP tools in the assembly

[!WARNING] NOTE: .WithStdioServerTransport() is commented out to allow deployment to Azure App Service as stdio transport is not supported there.

Map REST Endpoints and add MCP Tools

Create a new class Tools\TodoService.cs and implement the MCP tools for todo operations. Each tool corresponds to a REST API endpoint.

using ModelContextProtocol.AspNetCore.Tools;
using TodoMCPServer.Models;

public static class TodoService
{
    public static void MapEndPoints(this IEndpointRouteBuilder app)
    {
        app.MapGroup("/todoitems");

        app.MapGet("/", TodoTools.GetAllTodos)
            .WithSummary("Get All Todo Items")
            .WithDescription("Retrieve all todo items, optionally filtered by status query parameter (e.g., ?status=completed).");

        app.MapPost("/complete", TodoTools.CompleteTodoItem)
            .WithSummary("Complete Todo Item")
            .WithDescription("Mark a todo item as complete by its ID.");
            
        // Rest of the code
    }
}

[McpServerToolType]
public static class TodoTools
{
    // Get all todo items
    [McpServerTool(Name = "get_all_todos"), Description("Retrieve all todo items optionally filtered by status.")]
    public static async Task<List<Todo>> GetAllTodos(string? status, TodoDb db)
    {
        if (string.Equals(status, "completed", StringComparison.OrdinalIgnoreCase))
        {
            return await db.Todos.Where(t => t.IsComplete).ToListAsync();
        }
        else
        {
            return await db.Todos.ToListAsync();
        }
    }
    // Other MCP tool implementations go here...
}

How to Run the Application

1. Clone and Navigate if you want to just try it out existing project

git clone https://github.com/cpateldev/TodoMCPServer.git
cd TodoMCPServer

2. Restore Dependencies

dotnet restore

3. Run the Application

dotnet run
# or for development with hot reload
dotnet watch run

4. Access Interfaces

5. Alternative Launch Methods

  • Visual Studio: Open TodoMCPServer.sln and press F5
  • VS Code: Open folder and use .NET Core Launch configuration

Package Dependencies

Here are the NuGet packages used in this project:

PackageVersionDescription
Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore10.0.0ASP.NET Core middleware for Entity Framework Core error pages.
Microsoft.AspNetCore.OpenApi10.0.0Provides APIs for generating and serving OpenAPI documents for web APIs built with ASP.NET Core.
Microsoft.EntityFrameworkCore.InMemory10.0.0Entity Framework Core in-memory database provider.
ModelContextProtocol0.4.1-preview.1A protocol for synchronizing models between a client and a server. (not needed in this project)
ModelContextProtocol.AspNetCore0.4.1-preview.1ASP.NET Core middleware for ModelContextProtocol.
Swashbuckle.AspNetCore.SwaggerUI10.0.1Middleware to expose an embedded version of the Swagger UI to visualize and interact with your web APIs.

See comparison between ModelContextProtocol vs ModelContextProtocol.AspNetCore

Web API REST Endpoints

The API follows RESTful conventions with 11 endpoints for comprehensive Todo management.

Endpoint Details Table

#HTTP MethodEndpointDescriptionParametersRequest BodyResponse Type
1GET/todoitemsGet all todo itemsstatus (query, optional) - Filter by statusNoneArray of Todo
2POST/todoitemsCreate a new todo itemNoneTodo objectSingle Todo
3GET/todoitems/completeMark a todo as completeid (query, required) - Todo IDNoneboolean
4GET/todoitems/completedGet all completed todosNoneNoneArray of Todo
5GET/todoitems/{id}Get a specific todo by IDid (path, required) - Todo IDNoneSingle Todo
6PATCH/todoitems/{id}Update a specific todoid (path, required) - Todo IDTodo object (partial update)boolean
7DELETE/todoitems/{id}Delete a specific todoid (path, required) - Todo IDNoneSingle Todo (deleted item)
8POST/todoitems/idsGet multiple todos by IDsNoneArray of integers (IDs)Array of Todo
9GET/todoitems/search/{name}Search todos by namename (path, required) - Search termNoneArray of Todo
10POST/todoitems/batchCreate multiple todos in batchNoneArray of Todo objectsArray of Todo
11GET/todoitems/exists/{id}Check if a todo existsid (path, required) - Todo IDNoneboolean

Swagger UI Usage

  1. Navigate to http://localhost:5000/swagger
  2. Click on any endpoint to expand
  3. Use "Try it out" button for interactive testing
  4. View request/response schemas and examples

MCP Tools Details

The MCP server provides 11 tools that mirror the REST API functionality, enabling AI assistants to interact with the Todo system.

MCP Tools Table

#Tool NameDescriptionInput ParametersReturn TypeHTTP Equivalent
1get_all_todosRetrieve all todo items optionally filtered by status.status (string, optional) - "completed" or nullList<Todo>GET /todoitems
2get_todo_by_idRetrieve a todo item by its ID.id (int) - Todo IDTodo? (nullable)GET /todoitems/{id}
3get_todos_by_idsRetrieve multiple todo items by their IDs.ids (int[]) - Array of Todo IDsList<Todo>POST /todoitems/ids
4search_todos_by_nameSearch todo items by name.name (string) - Search termList<Todo>GET /todoitems/search/{name}
5add_todo_itemAdd a new todo item.todo (Todo) - Todo object to createTodoPOST /todoitems
6update_todo_itemUpdate an existing todo item by id.id (int) - Todo ID
inputTodo (Todo) - Updated todo data
bool (success)PATCH /todoitems/{id}
7batch_update_todo_itemsBatch update todo items.todos (Todo[]) - Array of todos to updateList<Todo> (updated items)Multiple PATCH calls
8delete_todo_itemDelete a todo item by its ID.id (int) - Todo IDTodo? (deleted item or null)DELETE /todoitems/{id}
9get_completed_todosRetrieve all completed todo items.NoneList<Todo>GET /todoitems/completed
10complete_todo_itemMark a todo item as complete by its ID.id (int) - Todo IDbool (success)POST /todoitems/complete?id={id}
11todo_existsCheck if a todo item exists by its ID.id (int) - Todo IDbool (exists)GET /todoitems/exists/{id}

Prompt to Request Flow

sequenceDiagram
    participant Client as MCP Client Prompt (Github Copilot / Claude / Gemini)
    participant MCPServer as Todo MCP Server
    participant API as REST API Layer
    participant DB as (EF Core) In-Memory DB

    Client->>MCPServer: Prompt to Tool Request (e.g., get_all_todo)
    MCPServer->>API: Process MCP Request
    API->>DB: Execute Database Operation
    DB-->>API: Return Data
    API-->>MCPServer: Format Response
    MCPServer-->>Client: Return Tool Result

MCP JSON Config Files and Usage

Visual Studio Github Copilot Configuration

Visual Studio supports MCP integration using both HTTP and stdio transport types. Create a new file: <SOLUTIONDIR>\.mcp.json or %USERPROFILE%\.mcp.json. We recommend that you use Visual Studio to edit this file so that its JSON schema is automatically applied.

Transport type: http

{
  "servers": {
    "TodoMcpServer": {
      "type": "http",
      "url": "http://localhost:5000/api/mcp"
    }
  }
}
Visual Studio MCP support

Visual Studio MCP json

Visual Studio Github Copilot MCP Tools

Usage with Visual Studio GitHub Copilot: http:

  1. Only works in Visual Studio 2026.
  2. Place config in .mcp.json file in solution directory or user profile directory.
  3. Run project using VS 2026 or using dotnet run or dotnet watch commands
  4. Click Start link above json block in .mcp.json
  5. Access todo tools via GitHub Copilot AI assistant panel shown in above image

Visual Studio MCP Json

VS Code GitHub Copilot Configuration

VS Code supports MCP integration using both HTTP and stdio transport types.

.vscode\mcp.json

Transport type: http

{
  "servers": {
    "TodoMcpServer": {
      "type": "http",
      "url": "http://localhost:5000/api/mcp"
    }
  }
}

GitHub Copilot HTTP MCP Start

Usage with VS Code GitHub Copilot: http:

  1. Make sure chat.mcp.enabled is true in VS Code settings.
  2. Place config in .vscode\mcp.json. See VSCode MCP docs for more details.
  3. Run project using dotnet run or dotnet watch command
  4. Click Start link above json block in .vscode\mcp.json
  5. Access todo tools via AI assistant panel

Transport type: stdio

{
  "servers": {
    "TodoMcpHttpServer": {
      "type": "stdio",
      "command": "dotnet",
      "args": ["run", "--project", "ToDoMCPServer.csproj"]
    }
  }
}

Usage with VS Code GitHub Copilot: stdio

  1. Make sure chat.mcp.enabled is true in VS Code settings.
  2. Place config in .vscode\mcp.json. See VSCode MCP docs for more details.
  3. Click Start link above json block in .vscode\mcp.json
  • DONT NEED TO run project using dotnet run or dotnet watch command as stdio transport will start the project
  1. Wait for "MCP server started" message in output console
  2. Access todo tools via GitHub Copilot AI assistant panel

GitHub Copilot responses to Todo MCP

VSCode: Github Copilot

Claude Desktop Configuration

Transport type: stdio only

claude-desktop-config.json

{
  "mcpServers": {
    "TodoMcpHttpServer": {
      "type": "stdio",
      "command": "dotnet",
      "args": [
        "run",
        "--project",
        "<path to project directory>\\TodoMCPServer.csproj"
      ]
    }
  }
}

Usage with Claude Desktop:

  1. Locate Claude config: ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows)
  2. Update configuration with existing settings shown above. Make sure to provide full path to TodoMCPServer.csproj
  3. Restart Claude Desktop
  4. Use natural language like "Show me all my todos" or "Create a new todo for meeting tomorrow"

Claude Desktop response to Todo MCP

Claude Desktop MCP Response

Gemini Code Assist Configuration

** Transport type: stdio only **

.gemini\settings.json

{
  "mcpServers": {
    "TodoMcpHttpServer": {
      "type": "stdio",
      "command": "dotnet",
      "args": ["run", "--project", "ToDoMCPServer.csproj"]
    }
  }
}

Usage with Gemini Code Assist:

  1. Open VS Code > Gemini Code Assist chat window
  2. Enter /mcp
  3. Open command palette (Ctrl + Shift + P) and select Developer: Reload Windows option.
  4. Gemini Code Assist will show MCP servers from settings.json. 11 tools will be shown in this case

Gemini Code Assists responses to Todo MCP

Gemini Code Assists

Configuration Comparison

AI MCP ToolConfig LocationKey PropertiesNotes
VS Code:GitHub CopilotProject > .vscode\mcp.jsontype,command, argsor http, urlsupports both stdio or http transport
Claude DesktopClaude Desktop Configtype,command, argssupports stdio transport only
VS Code: Gemini Code AssistProject > .gemini\settings.jsontype,command, argssupports stdio transport only

Testing MCP Tools

  1. Start the server: dotnet run or dotnet watch
  2. Connect a client using one of the configs above
  3. Test with natural language:
    • "get all todos"
    • "Create a todo for fixing the bug report"
    • "Mark todo #3 as complete"

Testing using MCP Inspector

  1. Testing with MCP Inspector
    • Use MCP Inspector to test MCP tools directly by sending requests and viewing responses.
    • Configure MCP Inspector to connect to the TodoMCPServer using HTTP or stdio transport as per your setup.
  2. Run MCP Inspector and connect to the Todo MCP server
    • Open PowerShell or terminal and run npx -y @modelcontextprotocol/inspector command, see below examples for http and stdio transport
    • This should open MCP Inspector UI in browser
    • Configure connection to Todo MCP server using HTTP or stdio transport shown in images below

Testing using MCP Inspector - HTTP

MCP Inspector Command for HTTP transport:

For http transport use: http://localhost:5000/api/mcp, you must start the server first using dotnet run command.

npx -y @modelcontextprotocol/inspector http http://localhost:5000/api/mcp

Testing using MCP Inspector - http

Testing using MCP Inspector - STDIO

MCP Inspector Command for STDIO transport:

For stdio transport: click Connect button from MCP Inspector UI, no need to start the server first as stdio transport will start the server process.

npx -y @modelcontextprotocol/inspector stdio "dotnet run --project ToDoMCPServer.csproj"

Testing MCP Inspector - STDIO


Deploy to Azure App Service

Option A: Using Azure CLI

  1. Login:
    az login
    
  2. Create resource group:
    az group create --name TodoMcpRG --location eastus
    
  3. Deploy App Service:
    az webapp up --runtime "DOTNET|10.0" --sku B1 \
      --name TodoMcpServerApp --resource-group TodoMcpRG
    

This command builds, publishes, and deploys your app.


Option B: Using Visual Studio

  • Configure Publish Profile in Visual Studio.
  • Right‑click project → PublishAzure App Service (Windows/Linux).
  • Select subscription, resource group, and App Service plan.
  • Publish.

Test Todo REST API in Azure

  • REST:
    curl https://TodoMcpServerApp.azurewebsites.net/todos
    
  • MCP tools:
    • get_todos → returns items
    • add_todo → adds new item

Secure Your Endpoint (Optional)

Add JWT/OAuth authentication:

builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
    .AddJwtBearer(options =>
    {
        options.Authority = "https://login.microsoftonline.com/<tenant-id>/v2.0";
        options.Audience = "<app-client-id>";
    });

builder.Services.AddAuthorization();

app.MapMcp("api/mcp").RequireAuthorization();

Then configure Azure AD App Registration for your server.


Monitor & Scale

  • Enable Application Insights for logging MCP requests.
  • Configure autoscaling in App Service Plan for load handling.

End to end flow diagram

flowchart TD
    subgraph "MCP Clients Ecosystem"
        A[Claude Desktop]
        B[VS Code with MCP]
        C[Cursor IDE]
        D[Gemini Code Assist]
        E[Custom MCP Client]
    end

    subgraph "Azure App Service Deployment"
        F[Azure App Service<br/>TodoMCPServer]
        G[Web API Layer<br/>ASP.NET Core 10]
        H[MCP Server Layer<br/>Stdio Protocol]
        I[Business Logic<br/>TodoTools.cs]
        J[Data Access<br/>Entity Framework]
        
        subgraph "Database Options"
            K1[Azure SQL Database]
            K2[Cosmos DB]
            K3[In-Memory<br/>Dev/Test]
        end
        
        L[Azure Key Vault<br/>Secrets Management]
        M[Application Insights<br/>Monitoring]
        N[Azure Monitor<br/>Logging & Alerts]
    end

    subgraph "Development & CI/CD"
        O[GitHub Repository]
        P[GitHub Actions<br/>CI/CD Pipeline]
        Q[Azure Container Registry]
        R[Docker Container]
    end

    %% Client Connections
    A -->|STDIO Protocol<br/>over SSH/WebSocket| F
    B -->|STDIO Protocol<br/>VS Code Extension| F
    C -->|STDIO Protocol<br/>Integrated Client| F
    D -->|STDIO Protocol<br/>Google Extension| F
    E -->|Custom MCP Protocol| F

    %% Internal Azure Flow
    F --> G
    F --> H
    G --> I
    H --> I
    I --> J
    J --> K1
    J --> K2
    J --> K3
    
    %% Security & Monitoring
    F --> L
    F --> M
    M --> N
    
    %% Deployment Flow
    O --> P
    P --> Q
    Q --> R
    R --> F

    %% External Services
    S[Azure Active Directory<br/>Authentication]
    T[Azure API Management<br/>Optional Gateway]
    U[Azure Front Door<br/>CDN & WAF]
    
    S --> F
    T --> F
    U --> F

Client communication flow

sequenceDiagram
    participant C as MCP Client (Claude/VS Code)
    participant APIM as Azure API Management (Optional)
    participant AS as App Service
    participant MCP as MCP Server
    participant API as Web API
    participant DB as Azure SQL

    Note over C,DB: Initial Connection
    C->>APIM: MCP Handshake Request
    APIM->>AS: Forward Request
    AS->>MCP: Initialize MCP Server
    MCP-->>AS: Server Ready
    AS-->>APIM: Handshake Response
    APIM-->>C: Connection Established
    
    Note over C,DB: Tool Execution Flow
    C->>APIM: Tool Request (e.g., get_all_todos)
    APIM->>AS: Forward with Auth
    AS->>MCP: Parse & Validate Request
    MCP->>API: Call Internal API
    API->>DB: Database Query
    DB-->>API: Results
    API-->>MCP: Formatted Data
    MCP-->>AS: MCP-formatted Response
    AS-->>APIM: Response
    APIM-->>C: Final Result

Project Structure

TodoMCPServer/
├── .gemini/                        # gemini Code Assist configuration folder
│   └── settings.json               # config for Gemini Code Assist (MCP)
├── .vscode/                        # VS Code configuration (MCP + editor settings)
│   └── mcp.json                    # MCP configuration for Visual Studio GitHub Copilot
├── ClaudeDesktopConfig/            # Cache folder of Claude Desktop config (MCP)
│   └── claude_desktop_config.json  # MCP configuration for Claude Desktop
├── Properties/                     # project properties (auto-generated by .NET)
│   └── …                           # (typically AssemblyInfo, launchSettings, etc.)
├── images/                         # static image assets (if any)
│   └── …                           # (files here)
├── Program.cs                      # main entry point (ASP.NET minimal API + MCP setup)
├── Readme.md                       # project README / documentation
├── ToDo.cs                         # model/entity class (Todo item)
├── ToDoDb.cs                       # EF Core in-memory DB context
├── TodoItemDTO.cs                  # Data Transfer Object for Todo (for API / MCP)
├── TodoMCPServer.csproj            # .NET project file
├── TodoMCPServer.sln               # Solution file
├── TodoMCPServer.http              # HTTP request collection (e.g. for testing via REST)
├── TodoService.cs                  # REST minimal api endpoints + MCP Tools for Todo operations logic
├── appsettings.json                # general configuration file
├── appsettings.Development.json    # development-specific configuration
└── .mcp.json                       # MCP configuration for Visual Studio 2026 GitHub Copilot (placed at solution root or user profile root)

Troubleshooting MCP Connections

  1. Server not starting: Ensure .NET 10 SDK is installed
  2. Connection refused: Check if port 5000 is available
  3. Tools not appearing: Verify config file syntax and paths
  4. Permission issues: Ensure execute permissions on the project
  5. Database empty: The in-memory DB resets on restart; seed data may be needed

Security Notes

  • Development Only: In-memory database resets on application restart
  • No Authentication: Configure authentication for production use
  • Local Network: By default runs on localhost; update for network access
  • Input Validation: Ensure all inputs are validated in production

References

Go to Top