DotnetMcpServer 2.0.0
dotnet tool install --global DotnetMcpServer --version 2.0.0
dotnet new tool-manifest
dotnet tool install --local DotnetMcpServer --version 2.0.0
#tool dotnet:?package=DotnetMcpServer&version=2.0.0
nuke :add-package DotnetMcpServer --version 2.0.0
π dotnet-mcp-server
A Model Context Protocol (MCP) server built with .NET 8 that exposes enterprise tools to AI assistants like Claude Desktop, VS Code (Copilot/Continue/Cline), Cursor, Windsurf, and more.
MCP is Anthropic's open protocol that lets AI assistants connect to external data sources and tools. This project brings MCP to the .NET ecosystem. It works with any MCP-compatible client β not just Claude Desktop.
π Full Documentation β Getting Started, Tool Reference, Plugin Guide
What is MCP?
The Model Context Protocol allows AI assistants to:
- π Query your databases
- π Read files from your system
- π Call external APIs
- β° Get real-time information
Instead of copying data into prompts, the AI can directly access the tools it needs.
Features
This server provides nine enterprise-ready tools:
| Tool | Description |
|---|---|
| π datetime | Get current time, convert between timezones |
| π filesystem | Read files, list directories (within allowed paths) |
| ποΈ sql_query | Execute read-only SQL queries against configured databases |
| π http_request | Make GET/POST requests to allowed APIs |
| π text | Regex match/replace, word count, text diff, format JSON/XML |
| π data_transform | JSON query, CSV/JSON/XML conversion, base64, hashing |
| π environment | Get/list/check environment variables (sensitive values masked) |
| π» system_info | OS details, running processes, network interfaces |
| π git | Read-only Git: status, log, diff, branches, blame |
Security Features
- β File access restricted to configured directories only
- β SQL queries are read-only (SELECT only, dangerous keywords blocked)
- β HTTP requests limited to allowed hosts
- β Environment variables with sensitive value masking (passwords, tokens, keys)
- β Git operations are read-only with path validation and argument sanitization
- β Regex timeout protection against ReDoS attacks
- β XXE prevention in XML parsing
- β No arbitrary code execution
<details> <summary><h2>π Quick Start</h2></summary>
Prerequisites
- .NET 8 SDK
- Any MCP client (see Supported Clients below)
<details> <summary><h3>Option A β Install as a Global Tool (Recommended)</h3></summary>
dotnet tool install -g DotnetMcpServer
Then run the interactive setup wizard to create your config:
dotnet-mcp-server --init
The wizard writes appsettings.json to your user config directory:
- Windows:
%APPDATA%\dotnet-mcp-server\appsettings.json - Linux/macOS:
~/.config/dotnet-mcp-server/appsettings.json
After configuring, you can verify everything is working:
dotnet-mcp-server --validate
To update to the latest version later:
dotnet tool update -g DotnetMcpServer
</details>
<details> <summary><h3>Option B β Clone and Build</h3></summary>
git clone https://github.com/Argha713/dotnet-mcp-server.git
cd dotnet-mcp-server
dotnet build
Configure (Option B only)
Edit src/McpServer/appsettings.json:
{
"FileSystem": {
"AllowedPaths": [
"C:\\Users\\YourName\\Documents",
"C:\\Projects"
]
},
"Sql": {
"Connections": {
"MyDB": {
"ConnectionString": "Server=localhost;Database=MyDB;Trusted_Connection=True;",
"Description": "My local database"
}
}
},
"Http": {
"AllowedHosts": [
"api.github.com",
"jsonplaceholder.typicode.com"
]
}
}
</details>
<details> <summary><h3>Option C β Docker (No .NET Required)</h3></summary>
Run the server in a container alongside a demo SQL Server β no .NET SDK needed on your machine.
Step 1: Copy the example config and env files:
cp docker/appsettings.example.json docker/appsettings.json
cp .env.example .env
Step 2: Edit docker/appsettings.json to set your allowed paths, SQL connections, and HTTP hosts. Edit .env to set a strong SQL_SA_PASSWORD.
Step 3: Build the image and start both services:
docker-compose up --build
The docker build step runs all tests β if any test fail, the build is aborted.
Claude Desktop integration (docker run pattern):
{
"mcpServers": {
"dotnet-mcp-server": {
"command": "docker",
"args": [
"run", "--rm", "-i",
"-v", "/path/to/docker/appsettings.json:/home/app/.config/dotnet-mcp-server/appsettings.json:ro",
"dotnet-mcp-server"
]
}
}
}
Note: Replace
/path/to/docker/appsettings.jsonwith the absolute path to yourdocker/appsettings.jsonfile. On Windows use forward slashes or escape backslashes.
</details>
<details> <summary><h3>Connect to Your MCP Client</h3></summary>
Pick your client in the Supported Clients section below and follow the setup instructions.
Note: All client config examples use the global tool command
dotnet-mcp-server. If you are using Option B (clone & build), replace"command": "dotnet-mcp-server"with"command": "dotnet", "args": ["run", "--project", "C:\\path\\to\\dotnet-mcp-server\\src\\McpServer"]instead.
</details>
</details>
<details> <summary><h2>π₯οΈ Supported Clients</h2></summary>
<details> <summary><h3>Claude Desktop</h3></summary>
Config file location:
| OS | Path |
|----|------|
| Windows | %APPDATA%\Claude\claude_desktop_config.json |
| macOS | ~/Library/Application Support/Claude/claude_desktop_config.json |
Add this to the config file:
{
"mcpServers": {
"dotnet-mcp-server": {
"command": "dotnet-mcp-server"
}
}
}
Restart Claude Desktop. You should see the tools available in the chat.
</details>
<details> <summary><h3>VS Code β GitHub Copilot (Built-in)</h3></summary>
VS Code has native MCP support via GitHub Copilot (agent mode). No extension needed β just VS Code 1.99+ with Copilot enabled.
Step 1: Open your project in VS Code.
Step 2: Create a .vscode/mcp.json file in your workspace root:
{
"servers": {
"dotnet-mcp-server": {
"command": "dotnet-mcp-server"
}
}
}
Step 3: Open the Copilot Chat panel (Ctrl+Shift+I or Cmd+Shift+I).
Step 4: Switch to Agent mode (click the dropdown at the top of the chat panel and select "Agent").
Step 5: You should see the MCP tools listed. Ask Copilot questions like "What time is it in Tokyo?" or "List files in my Documents folder".
Tip: You can also add the server globally via VS Code settings (
settings.json):{ "mcp": { "servers": { "dotnet-mcp-server": { "command": "dotnet-mcp-server" } } } }
</details>
<details> <summary><h3>VS Code β Continue.dev (Open Source)</h3></summary>
Continue is a free, open-source AI coding assistant for VS Code and JetBrains.
Step 1: Install the Continue extension from VS Code Marketplace.
Step 2: Open Continue config: press Ctrl+Shift+P β type Continue: Open Config β select it.
Step 3: This opens ~/.continue/config.json. Add the MCP server under mcpServers:
{
"mcpServers": [
{
"name": "dotnet-mcp-server",
"command": "dotnet-mcp-server"
}
]
}
Step 4: Reload VS Code (Ctrl+Shift+P β Developer: Reload Window).
Step 5: Open Continue chat panel. The tools will be available in agent mode.
</details>
<details> <summary><h3>VS Code β Cline (Open Source)</h3></summary>
Cline is a free, open-source autonomous AI coding agent for VS Code.
Step 1: Install the Cline extension from VS Code Marketplace.
Step 2: Open Cline settings: click the Cline icon in the sidebar β click the gear icon β go to MCP Servers.
Step 3: Click "Edit MCP Settings" which opens ~/Documents/Cline/cline_mcp_settings.json. Add:
{
"mcpServers": {
"dotnet-mcp-server": {
"command": "dotnet-mcp-server"
}
}
}
Step 4: Restart Cline. The tools should appear in the MCP Servers section.
</details>
<details> <summary><h3>Cursor</h3></summary>
Cursor is an AI-first code editor with built-in MCP support.
Step 1: Open Cursor Settings β go to MCP section (or press Ctrl+Shift+J).
Step 2: Click "Add new MCP Server".
Step 3: Alternatively, create/edit ~/.cursor/mcp.json:
{
"mcpServers": {
"dotnet-mcp-server": {
"command": "dotnet-mcp-server"
}
}
}
Step 4: Restart Cursor. Use the tools in Composer (Agent mode).
</details>
<details> <summary><h3>Windsurf (Codeium)</h3></summary>
Windsurf is an AI-powered editor by Codeium with MCP support.
Step 1: Open Windsurf and go to Settings β MCP.
Step 2: Click "Add Server" and configure:
{
"mcpServers": {
"dotnet-mcp-server": {
"command": "dotnet-mcp-server"
}
}
}
Step 3: Restart Windsurf. Tools are available in Cascade (the AI chat).
</details>
<details> <summary><h3>Claude Code (CLI)</h3></summary>
Claude Code is Anthropic's CLI tool. It supports MCP servers natively.
claude mcp add dotnet-mcp-server dotnet-mcp-server
That's it β Claude Code will auto-start the server when needed.
</details>
<details> <summary><h3>ChatGPT Desktop</h3></summary>
OpenAI's ChatGPT desktop app supports MCP servers (requires Plus plan).
Step 1: Open ChatGPT Desktop β Settings β Beta Features β enable MCP Servers.
Step 2: Go to Settings β MCP Servers β click "Add Server".
Step 3: Configure:
- Name:
dotnet-mcp-server - Command:
dotnet-mcp-server - Arguments: (leave blank)
Step 4: Restart ChatGPT. Tools appear in the chat.
</details>
<details> <summary><h3>Manual Testing (No Client Needed)</h3></summary>
You can test the server directly from any terminal:
dotnet run --project src/McpServer
Then paste JSON-RPC messages line by line:
{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","clientInfo":{"name":"manual-test","version":"1.0"}}}
{"jsonrpc":"2.0","method":"notifications/initialized"}
{"jsonrpc":"2.0","id":2,"method":"tools/list"}
{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"datetime","arguments":{"action":"now"}}}
Note: Replace
C:\path\to\dotnet-mcp-serverwith the actual path where you cloned the repo in all examples above.
</details>
</details>
<details> <summary><h2>π¬ Tool Usage Examples</h2></summary>
<details> <summary><h3>DateTime Tool</h3></summary>
Ask Claude:
- "What time is it in Tokyo?"
- "Convert 3pm EST to IST"
- "What's the current UTC time?"
</details>
<details> <summary><h3>File System Tool</h3></summary>
Ask Claude:
- "List files in my Documents folder"
- "Read the contents of README.md"
- "Search for all .cs files in my projects"
</details>
<details> <summary><h3>SQL Query Tool</h3></summary>
Ask Claude:
- "Show me the tables in MyDB database"
- "Query the top 10 customers by revenue"
- "Describe the structure of the Orders table"
</details>
<details> <summary><h3>HTTP Tool</h3></summary>
Ask Claude:
- "Get my GitHub profile info"
- "Fetch the latest posts from JSONPlaceholder API"
- "What APIs can you access?"
</details>
<details> <summary><h3>Text Tool</h3></summary>
Ask Claude:
- "Find all email addresses in this text"
- "Replace localhost:3000 with api.prod.com in my config"
- "How many words are in this document?"
- "Show me the diff between these two configs"
- "Pretty-print this minified JSON"
</details>
<details> <summary><h3>Data Transform Tool</h3></summary>
Ask Claude:
- "Convert this CSV to JSON"
- "Extract all user emails from this JSON"
- "Base64 encode this string"
- "Generate a SHA256 hash of this text"
- "Convert this XML response to JSON"
</details>
<details> <summary><h3>Environment Tool</h3></summary>
Ask Claude:
- "What is my JAVA_HOME set to?"
- "Show me all Node-related environment variables"
- "Is DOCKER_HOST configured?"
</details>
<details> <summary><h3>System Info Tool</h3></summary>
Ask Claude:
- "How much disk space do I have?"
- "What processes are using the most memory?"
- "What's my OS version and .NET runtime?"
- "Show me my network interfaces"
</details>
<details> <summary><h3>Git Tool</h3></summary>
Ask Claude:
- "What files have I changed in this repo?"
- "Show me the last 10 commits"
- "What's the diff of my current changes?"
- "Who last modified line 42 of Program.cs?"
</details>
</details>
<details> <summary><h2>βοΈ Configuration Reference</h2></summary>
<details> <summary><h3>Example Profiles</h3></summary>
Ready-to-use configuration files are provided in examples/configs/:
| File | Best for |
|---|---|
developer.json |
Software developers β local repos, dev DBs, GitHub/npm/docs APIs |
data-analyst.json |
Data analysts β data directories, analytics DBs, public data APIs |
api-integrator.json |
API integrators β broad external API access, minimal filesystem |
Copy one of these to your config directory and edit to match your environment.
</details>
<details> <summary><h3>File System Settings</h3></summary>
{
"FileSystem": {
"AllowedPaths": [
"/home/user/documents",
"/projects"
]
}
}
</details>
<details> <summary><h3>SQL Settings</h3></summary>
{
"Sql": {
"Connections": {
"Production": {
"ConnectionString": "Server=...;Database=...;",
"Description": "Production database (read-only)"
},
"Analytics": {
"ConnectionString": "Server=...;Database=...;",
"Description": "Analytics warehouse"
}
}
}
}
</details>
<details> <summary><h3>HTTP Settings</h3></summary>
{
"Http": {
"AllowedHosts": [
"api.github.com",
"api.stripe.com",
"your-internal-api.com"
],
"TimeoutSeconds": 30
}
}
</details>
</details>
<details> <summary><h2>ποΈ Architecture</h2></summary>
ββββββββββββββββ ββββββββββββ ββββββββββ ββββββββββββ
βClaude Desktopβ β VS Code β β Cursor β β ChatGPT β
β β β(Copilot/ β β β β Desktop β
β β βContinue/ β β β β β
β β β Cline) β β β β β
ββββββββ¬ββββββββ ββββββ¬ββββββ βββββ¬βββββ ββββββ¬ββββββ
β β β β
ββββββββββββββββ΄ββββββ¬ββββββ΄βββββββββββββ
β JSON-RPC over stdio
βΌ
βββββββββββββββββββββββ
β dotnet-mcp-server β
β (MCP Server) β
βββββββββββββββββββββββ€
β βββββββββββββββββ β
β β DateTime Tool β β
β βββββββββββββββββ€ β
β β FileSystem β β
β βββββββββββββββββ€ β
β β SQL Query β β
β βββββββββββββββββ€ β
β β HTTP Tool β β
β βββββββββββββββββ€ β
β β Text Tool β β
β βββββββββββββββββ€ β
β β Data Transformβ β
β βββββββββββββββββ€ β
β β Environment β β
β βββββββββββββββββ€ β
β β System Info β β
β βββββββββββββββββ€ β
β β Git Tool β β
β βββββββββββββββββ β
βββββββββββββββββββββββ
β
ββββββ¬ββββ¬ββββ΄ββββ¬βββββ
βΌ βΌ βΌ βΌ βΌ
Files SQL APIs Git OS
</details>
<details> <summary><h2>π Project Structure</h2></summary>
dotnet-mcp-server/
βββ src/
β βββ McpServer/
β βββ Protocol/ # MCP/JSON-RPC types
β βββ Tools/ # Tool implementations
β βββ Configuration/ # Settings classes
β βββ McpServerHandler.cs # Main server logic
β βββ Program.cs # Entry point
βββ tests/
β βββ McpServer.Tests/ # Unit tests
βββ docker/
β βββ appsettings.example.json # Docker config template
βββ examples/
β βββ configs/
β β βββ developer.json # Developer profile
β β βββ data-analyst.json # Data analyst profile
β β βββ api-integrator.json # API integrator profile
β βββ SamplePlugin/ # Reference plugin implementation
βββ Dockerfile # Multi-stage Alpine build
βββ docker-compose.yml # mcp-server + SQL Server 2022
βββ .env.example # SQL SA password template
βββ README.md
</details>
<details> <summary><h2>π§ Adding Custom Tools</h2></summary>
Create a new class implementing ITool:
public class MyCustomTool : ITool
{
public string Name => "my_tool";
public string Description => "Does something useful";
public JsonSchema InputSchema => new()
{
Type = "object",
Properties = new Dictionary<string, JsonSchemaProperty>
{
["input"] = new() { Type = "string", Description = "Input value" }
},
Required = new List<string> { "input" }
};
public async Task<ToolCallResult> ExecuteAsync(
Dictionary<string, object>? arguments,
CancellationToken cancellationToken)
{
var input = arguments?["input"]?.ToString();
// Do something...
return new ToolCallResult
{
Content = new List<ContentBlock>
{
new() { Type = "text", Text = $"Result: {input}" }
}
};
}
}
Register in Program.cs:
services.AddSingleton<ITool, MyCustomTool>();
</details>
<details> <summary><h2>π Plugin Development</h2></summary>
You can extend the server with your own tools β no need to fork or modify the core project. Plugins are plain .NET class libraries that implement ITool and get dropped into the plugins/ folder.
<details> <summary><h3>Scaffold a plugin in one command</h3></summary>
Step 1: Install the template package (once):
dotnet new install DotnetMcpServer.Templates
Step 2: Scaffold a new plugin project:
dotnet new mcp-tool -n WeatherTool
cd WeatherTool
Step 3: Implement your tool β open WeatherTool.cs and follow the TODO markers.
Step 4: Build and install:
dotnet build -c Release
Windows:
copy bin\Release\net8.0\WeatherTool.dll "$env:APPDATA\dotnet-mcp-server\plugins\"
Linux / macOS:
cp bin/Release/net8.0/WeatherTool.dll ~/.config/dotnet-mcp-server/plugins/
Restart the server β your tool appears in tools/list automatically.
</details>
<details> <summary><h3>Plugin configuration</h3></summary>
Pass values to your plugin via appsettings.json:
{
"Plugins": {
"Config": {
"my_api_key": "your-value-here"
}
}
}
Use the PluginContext constructor pattern in your tool class to read these values (the scaffolded file includes a commented-out example).
</details>
</details>
<details open> <summary><h2>π Troubleshooting</h2></summary>
| Problem | Solution |
|---|---|
| Client doesn't see the tools | Check the config file path is correct. Restart the client. Make sure the path to dotnet-mcp-server is absolute. |
| "Access denied" errors | Add the path to AllowedPaths in appsettings.json |
| SQL connection fails | Verify connection string. Ensure SQL Server is running. |
| HTTP requests blocked | Add the host to AllowedHosts in appsettings.json |
| "Server not initialized" error | Your client must send initialize before calling tools. Most clients do this automatically. |
| VS Code Copilot doesn't show tools | Make sure you're in Agent mode (not Ask/Edit mode). Check .vscode/mcp.json syntax. |
| Tools not loading in Cursor | Go to Settings β MCP and check the server shows a green status. Restart Cursor if needed. |
View Logs
Logs are written to stderr. To see them:
dotnet run 2> log.txt
</details>
Roadmap
<details> <summary><h3>β Phase 1 β Security & Stability</h3></summary>
- Path traversal prevention for filesystem tool
- SQL injection prevention (SELECT-only enforcement)
- HTTP host allowlist validation with subdomain support
- XXE prevention in XML parsing
- ReDoS protection with regex timeout
- Environment variable sensitive-value masking
</details>
<details> <summary><h3>β Phase 2 β New Tools</h3></summary>
- Text tool (regex match/replace, word count, diff, format JSON/XML)
- Data transform tool (JSON query, CSVβJSONβXML conversion, base64, hashing)
- Environment tool (get/list/check env vars with masking)
- System info tool (OS details, processes, disk, network)
- Git tool (read-only: status, log, diff, branches, blame)
</details>
<details> <summary><h3>β Phase 3 β Production Readiness</h3></summary>
- 3.1 β CI/CD pipeline with self-contained binary publishing
- 3.2 β
--validateflag for configuration health check - 3.3 β
--initinteractive setup wizard - 3.4 β NuGet global tool (
dotnet tool install -g DotnetMcpServer) - 3.5 β Docker multi-stage Alpine build with test gate
</details>
<details> <summary><h3>β Phase 4 β MCP Protocol Completeness</h3></summary>
- 4.1 β Resources protocol (
resources/list,resources/read) - 4.2 β Prompts protocol (
prompts/list,prompts/get) - 4.3 β Logging protocol (
logging/setLevel, log forwarding to client) - 4.4 β Progress notifications (per-tool streaming progress tokens)
</details>
<details> <summary><h3>β Phase 5 β Developer Experience</h3></summary>
- 5.1 β Plugin architecture (drop-in DLL plugins)
- 5.2 β
dotnet new mcp-tooltemplate - 5.3 β Example configuration profiles (developer, data-analyst, api-integrator)
- 5.4 β CONTRIBUTING.md and GitHub issue templates
- 5.5 β GitHub Pages documentation site (MkDocs Material)
</details>
<details> <summary><h3>β Phase 6 β Advanced Features</h3></summary>
- 6.1 β Multi-database support (SQL Server, PostgreSQL, MySQL, SQLite)
- 6.2 β Audit logging (rolling JSONL files with argument sanitization)
- 6.3 β Per-tool sliding window rate limiting
- 6.4 β Per-tool response caching with configurable TTL
</details>
<details> <summary><h3>β Phase 7 β Tool-level Authentication & Permissions</h3></summary>
- 7.1 β API key authentication via
MCP_API_KEYenvironment variable - 7.2 β Per-key tool allowlists (restrict a key to specific tools)
- 7.3 β Per-key action allowlists (restrict a key to specific actions within a tool)
- 7.4 β Audit records include client identity name
</details>
<details> <summary><h3>Phase 8 β β Document Processing Tool</h3></summary>
- 8.1 β PDF reading (text extraction, metadata, search) via PdfPig
- 8.2 β Office documents (Word .docx, Excel .xlsx, PowerPoint .pptx) via OpenXml + ClosedXML
- 8.3 β Table extraction (Word + PDF), Excel sheet listing with row/col counts, progress reporting
</details>
<details> <summary><h3>Phase 9 β Notification & Communication Tool</h3></summary>
- 9.1 β Email notifications via SMTP (MailKit) with recipient allowlist
- 9.2 β Microsoft Teams + Slack webhook notifications
- 9.3 β Generic HTTP webhook + Markdown-to-Adaptive-Card/Block-Kit templating
</details>
Contributing
Bug reports, feature requests, and pull requests are welcome! Please read CONTRIBUTING.md before submitting.
Related Projects
- dotnet-rag-api β RAG system in .NET 8
License
This project is licensed under the MIT License - see the LICENSE file for details.
Author
Argha Sarkar
- LinkedIn: argha-sarkar
- GitHub: @Argha713
β If you found this project helpful, please give it a star!
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
This package has no dependencies.