Get the FREE Ultimate OpenClaw Setup Guide →

McpServerDemo

Building and Debugging Your First MCP Server in .NET

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio jamiemaguiredotnet-mcpserverdemo dotnet run \
  --env ASPNETCORE_URLS="http://localhost:5125"

How to use

This MCP server (McpServerDemo) is a lightweight .NET 10 implementation that exposes tools via the Model Context Protocol (MCP) so AI assistants can query and leverage local documents. The server hosts a simple document search tool and demonstrates how to register tools with the MCP framework. You can connect clients like Claude Desktop, Cursor, or VS Code Continue to the server's SSE endpoint to discover available tools and send requests. The server exposes its tools at the SSE endpoint http://localhost:5125/sse once it’s running, and clients can point to that endpoint to start interacting with the tools.

To test locally, you can run the server and then use the MCP Inspector in a browser or a dedicated MCP Explorer client. The README also shows example client configurations for Claude Desktop, Cursor, and VS Code Continue, illustrating how to wire up a local MCP server to those tools via URL and transport settings. Once connected, you can invoke the provided tool (SearchDocs) to perform document-related queries against the local data sources configured in the project.

How to install

Prerequisites:

  • .NET 10 SDK
  • Node.js (for MCP Inspector testing)
  1. Install the .NET 10 SDK if you haven’t already:

    • Windows/macOS/Linux: follow the official .NET 10 SDK installation guide for your platform.
  2. Obtain the MCP Server Demo source (clone or download the repository):

    • git clone <your-repo-url>
    • cd McpServerDemo/WebApi or navigate to src/McpServerDemo.WebApi as described in the README
  3. Build and run the server:

  4. Optional: Test with MCP Inspector (Browser):

  5. Optional: Test with MCP Explorer (Windows):

  6. Stop the server when done (Ctrl+C in the terminal).

Note: The project structure includes the Web API project at src/McpServerDemo.WebApi and a tool named SearchDocs.cs that implements MCP tool behavior. You can extend Tools with new MCP tools by following the pattern shown in the Extending section of the README.

Additional notes

Tips and notes:

  • The server hosts an SSE endpoint at /sse. Point MCP clients to this URL to fetch tool metadata and capabilities.
  • If you change ports or want to run behind a reverse proxy, you may need to adjust the ASPNETCORE_URLS environment variable or configure Kestrel accordingly.
  • To extend functionality, add new tool classes under the Tools folder and annotate them with [McpServerToolType] and [McpServerTool] attributes as demonstrated in the README.
  • The included client configuration examples (Claude Desktop, Cursor, VS Code Continue) illustrate how to wire this server into popular AI assistants; adapt the JSON/yaml snippets to your environment if you rename the server or change endpoints.
  • Ensure the .NET 10 SDK is installed and that your environment PATH includes dotnet.
  • For local testing, you can run the server in one terminal and then run MCP Inspector in another to interactively explore available tools.

Related MCP Servers

Sponsor this space

Reach thousands of developers