Argha.dev.McpServer
1.0.0
dotnet tool install --global Argha.dev.McpServer --version 1.0.0
dotnet new tool-manifest
dotnet tool install --local Argha.dev.McpServer --version 1.0.0
#tool dotnet:?package=Argha.dev.McpServer&version=1.0.0
nuke :add-package Argha.dev.McpServer --version 1.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.
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
Quick Start
Prerequisites
- .NET 8 SDK
- Any MCP client (see Supported Clients below)
Option A β Install as a Global Tool (Recommended)
dotnet tool install -g Argha.dev.McpServer
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 Argha.dev.McpServer
Option B β Clone and Build
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"
]
}
}
3. Connect to Your MCP Client
Pick your client below and follow the setup instructions.
Note: All client config examples below 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.
Supported Clients
Claude Desktop
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.
VS Code β GitHub Copilot (Built-in)
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" } } } }
VS Code β Continue.dev (Open Source)
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.
VS Code β Cline (Open Source)
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.
Cursor
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).
Windsurf (Codeium)
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).
Claude Code (CLI)
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.
ChatGPT Desktop
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.
Manual Testing (No Client Needed)
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.
Tool Usage Examples
DateTime Tool
Ask Claude:
- "What time is it in Tokyo?"
- "Convert 3pm EST to IST"
- "What's the current UTC time?"
File System Tool
Ask Claude:
- "List files in my Documents folder"
- "Read the contents of README.md"
- "Search for all .cs files in my projects"
SQL Query Tool
Ask Claude:
- "Show me the tables in MyDB database"
- "Query the top 10 customers by revenue"
- "Describe the structure of the Orders table"
HTTP Tool
Ask Claude:
- "Get my GitHub profile info"
- "Fetch the latest posts from JSONPlaceholder API"
- "What APIs can you access?"
Text Tool
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"
Data Transform Tool
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"
Environment Tool
Ask Claude:
- "What is my JAVA_HOME set to?"
- "Show me all Node-related environment variables"
- "Is DOCKER_HOST configured?"
System Info Tool
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"
Git Tool
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?"
Configuration Reference
File System Settings
{
"FileSystem": {
"AllowedPaths": [
"/home/user/documents",
"/projects"
]
}
}
SQL Settings
{
"Sql": {
"Connections": {
"Production": {
"ConnectionString": "Server=...;Database=...;",
"Description": "Production database (read-only)"
},
"Analytics": {
"ConnectionString": "Server=...;Database=...;",
"Description": "Analytics warehouse"
}
}
}
}
HTTP Settings
{
"Http": {
"AllowedHosts": [
"api.github.com",
"api.stripe.com",
"your-internal-api.com"
],
"TimeoutSeconds": 30
}
}
Architecture
ββββββββββββββββ ββββββββββββ ββββββββββ ββββββββββββ
β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
Project Structure
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
βββ README.md
Adding Custom Tools
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>();
Troubleshooting
| 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
Roadmap
Phase 1 β Security & Stability β Complete
- Fix SQL injection via subqueries (block
;,--,/* */, compound statements, 17 dangerous keywords) - Fix path traversal edge case (trailing separator check prevents
C:\AllowedPathEvilmatchingC:\AllowedPath) - Add initialization gate (reject
tools/listandtools/callbeforeinitializehandshake) - Config validation on startup (warn about missing paths, empty connection strings, malformed hosts)
- Expand test coverage β 8 β 63 tests (SqlQueryValidation, FileSystemTool, HttpTool, McpServerHandler)
Phase 2 β New Tools β Complete
- Text Tool β
regex_match,regex_replace,word_count,diff_text,format_json/xml - Data Transform Tool β
json_query,csv_to_json,json_to_csv,xml_to_json,base64_encode/decode,hash - Environment Tool β
get,list,has(with hardcoded blocklist for sensitive vars) - System Info Tool β
system_info(OS/CPU/RAM/disk),processes,network - Git Tool β
status,log,diff,branch_list,blame(read-only with path validation) - Added 5 new tools (4 β 9 total), 63 β 150 tests, zero new NuGet dependencies
Phase 3 β Production Readiness β Complete
- Dockerfile + docker-compose (one-command setup)
- GitHub Actions CI/CD (build, test on push/PR via
ci.yml; release pipeline viarelease.yml) - Self-contained single-file executables (win-x64, linux-x64, osx-arm64 β published on
v*tags) -
dotnet tool install -g dotnet-mcp-serverdistribution -
--initconfig wizard for first-run setup -
--validatehealth check for all configured connections
Phase 4 β MCP Protocol Completeness
- Resources support (
resources/list,resources/read) - Prompts support (
prompts/list,prompts/get) with built-in templates - Logging protocol (
logging/setLevel,notifications/message) - Progress notifications for long-running operations
Phase 5 β Developer Experience
- Plugin architecture (drop-in tool DLLs from
/pluginsfolder) -
dotnet new mcp-toolproject template for custom tools - Documentation site (Getting Started, Tool Reference, Custom Tools guide)
- Example configurations (
developer.json,data-analyst.json,api-integrator.json) -
CONTRIBUTING.md+ issue templates
Phase 6 β Advanced Features
- Multi-database support (PostgreSQL, MySQL, SQLite)
- Response caching with configurable TTL
- Audit logging (every tool call logged to file)
- Rate limiting per tool
- Tool-level authentication & permissions
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.
| Version | Downloads | Last Updated |
|---|