Back to Catalog
#

Setup Guide

Get started with single-file MCP servers

.NET 10 Any LLM Single File

Prerequisites

What you need before getting started

  • • The .NET 10 SDK, or later. Check with dotnet --list-sdks; one line must show 10 or higher. Running a .cs file directly is a .NET 10 feature, so earlier SDKs fail. Use --list-sdks rather than --version, which reports the SDK a global.json selects.
  • • An LLM client that supports MCP (Claude Code, Claude Desktop, Cursor, Visual Studio, VS Code)
  • • A single .cs file from the catalog, saved in your project

Basic Configuration

Put the server file in .mcp-servers/ in your project, then create .mcp.json in the project root. Commit both, and everyone who clones the project gets the server. The path is relative, so it works on every operating system.

Note: This example is for Claude Code, Claude Desktop, Cursor, and Windsurf. Visual Studio and VS Code use servers instead of mcpServers.

{
  "mcpServers": {
    "MyUtilityServer": {
      "type": "stdio",
      "command": "dotnet",
      "args": ["run", "./.mcp-servers/mcp-server.cs", "-v", "q"]
    }
  }
}

Environment Variables

Pass tokens and authentication keys securely

Note: The inputs block below belongs to Visual Studio and VS Code, which also use servers. Claude Code, Claude Desktop, Cursor, and Windsurf use mcpServers, and expand ${MY_KEY} from the environment instead.

Configuration with inputs:

{
  "inputs": [
    {
      "id": "user_email",
      "description": "Your email",
      "type": "promptString",
      "password": true
    }
  ],
  "servers": {
    "DotnetMcpFile": {
      "type": "stdio",
      "command": "dotnet",
      "args": ["run", "./.mcp-servers/mcp-server.cs", "-v", "q"],
      "env": {
        "USER_EMAIL": "${input:user_email}"
      }
    }
  }
}

Using environment variables in C#:

[McpServerToolType]
public static class EnvironmentExamples
{
    [McpServerTool, Description("Gets environment variable value")]
    public static string GetEnvironmentVariable(string variableName, string? defaultValue = null)
    {
        var value = Environment.GetEnvironmentVariable(variableName);
        
        if (string.IsNullOrEmpty(value))
        {
            if (defaultValue != null)
                return $"Environment variable '{variableName}' not found, using default: {defaultValue}";
            else
                return $"Environment variable '{variableName}' not found";
        }
        
        return $"{variableName} = {value}";
    }
}

Docker Deployment

For containerized environments

FROM mcr.microsoft.com/dotnet/sdk:10.0-alpine
WORKDIR /app
COPY mcp-server.cs .
ENTRYPOINT ["dotnet", "run", "mcp-server.cs", "-v", "q"]

Quick Start

Get up and running in your project, in 4 steps

  1. 1 Save a .cs file from the catalog into .mcp-servers/ in your project
  2. 2 Run dotnet build .mcp-servers/your-server.cs -v q one time, so the first client start is not a timeout
  3. 3 Create .mcp.json in the project root with the configuration above, and commit it
  4. 4 Restart your LLM client in the project directory, and start using the tools