Keerukee.MCPServer.Stdio 1.0.2

dotnet add package Keerukee.MCPServer.Stdio --version 1.0.2
                    
NuGet\Install-Package Keerukee.MCPServer.Stdio -Version 1.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Keerukee.MCPServer.Stdio" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Keerukee.MCPServer.Stdio" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Keerukee.MCPServer.Stdio" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Keerukee.MCPServer.Stdio --version 1.0.2
                    
#r "nuget: Keerukee.MCPServer.Stdio, 1.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Keerukee.MCPServer.Stdio@1.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Keerukee.MCPServer.Stdio&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Keerukee.MCPServer.Stdio&version=1.0.2
                    
Install as a Cake Tool

MCPServer

A lightweight .NET library for building MCP (Model Context Protocol) servers without external dependencies. Simply decorate your methods with attributes and the library handles all the protocol communication.

Features

  • Zero external dependencies - Uses only built-in .NET libraries
  • Attribute-based registration - Decorate methods with [McpTool], [McpResource], or [McpPrompt]
  • Automatic discovery - Tools, resources, and prompts are discovered via reflection
  • JSON Schema generation - Input schemas are automatically generated from method parameters
  • Full MCP compliance - Supports all standard MCP methods for client compatibility

Installation

Add a reference to the MCPServer project:

<ItemGroup>
  <ProjectReference Include="..\MCPServer\MCPServer.csproj" />
</ItemGroup>

Or if published as a NuGet package:

<ItemGroup>
  <PackageReference Include="MCPServer" Version="1.0.0" />
</ItemGroup>

Quick Start

1. Create the Server Entry Point

using MCPServer;

var server = new McpServerHost(new McpServerOptions
{
    ServerName = "MyMCPServer",
    ServerVersion = "1.0.0"
});

server.Run();

2. Add Tools

Create a class with static methods decorated with [McpTool]:

using MCPServer.Attributes;

public static class MyTools
{
    [McpTool("greet", "Greets a person by name")]
    public static string Greet(
        [McpParameter("The name of the person to greet")] string name)
    {
        return $"Hello, {name}!";
    }

    [McpTool("calculate_sum", "Adds two numbers together")]
    public static string CalculateSum(
        [McpParameter("First number")] double a,
        [McpParameter("Second number")] double b)
    {
        return $"The sum is {a + b}";
    }
}

3. Add Resources (Optional)

Resources provide read-only data to clients:

using MCPServer.Attributes;

public static class MyResources
{
    [McpResource("config://app", "App Configuration", "Returns application configuration", "application/json")]
    public static string GetAppConfig()
    {
        return """{"version": "1.0.0", "environment": "production"}""";
    }
}

4. Add Prompts (Optional)

Prompts are reusable prompt templates:

using MCPServer.Attributes;

public static class MyPrompts
{
    [McpPrompt("code_review", "Generates a code review prompt")]
    public static string CodeReviewPrompt(
        [McpParameter("Programming language")] string language,
        [McpParameter("Code to review")] string code)
    {
        return $"Please review this {language} code:\n```{language}\n{code}\n```";
    }
}

Attributes Reference

[McpTool(name, description)]

Marks a static method as an MCP tool.

Parameter Type Description
name string Unique identifier for the tool
description string Human-readable description

[McpParameter(description, required)]

Adds metadata to method parameters.

Parameter Type Default Description
description string - Description for the JSON schema
required bool true Whether the parameter is required

[McpResource(uri, name, description, mimeType)]

Marks a static method as an MCP resource.

Parameter Type Default Description
uri string - URI that identifies this resource
name string - Human-readable name
description string - Description of the resource
mimeType string "text/plain" MIME type of the content

[McpResourceTemplate(uriTemplate, name, description, mimeType)]

Marks a static method as an MCP resource template.

Parameter Type Default Description
uriTemplate string - URI template pattern (e.g., "file:///{path}")
name string - Human-readable name
description string - Description of the template
mimeType string "text/plain" MIME type of the content

[McpPrompt(name, description)]

Marks a static method as an MCP prompt.

Parameter Type Description
name string Unique identifier for the prompt
description string Human-readable description

Server Configuration

var server = new McpServerHost(new McpServerOptions
{
    ServerName = "MyServer",           // Name shown to clients
    ServerVersion = "1.0.0",           // Your server version
    ProtocolVersion = "2024-11-05"     // MCP protocol version
});

Supported Parameter Types

The library automatically converts JSON values to these C# types:

C# Type JSON Schema Type
string string
int, long, short integer
double, float, decimal number
bool boolean
Arrays array
Other types object

MCP Client Configuration

Claude Desktop

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "my-server": {
      "command": "dotnet",
      "args": ["run", "--project", "path/to/your/project.csproj"]
    }
  }
}

Or if using a compiled executable:

{
  "mcpServers": {
    "my-server": {
      "command": "path/to/your/server.exe"
    }
  }
}

VS Code / Continue

Add to your MCP configuration:

{
  "servers": {
    "my-server": {
      "command": "dotnet",
      "args": ["path/to/your/server.dll"]
    }
  }
}

Supported MCP Methods

Method Description
initialize Returns server capabilities and info
ping Health check
tools/list Lists available tools
tools/call Executes a tool
resources/list Lists available resources
resources/read Reads a resource
resources/templates/list Lists resource templates
prompts/list Lists available prompts
prompts/get Gets a prompt with arguments
completion/complete Autocompletion (returns empty)

Example Project Structure

MyMCPServer/
├── MyMCPServer.csproj
├── Program.cs
└── Features/
    ├── Tools.cs
    ├── Resources.cs
    └── Prompts.cs

License

Keerthi RB

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.2 123 1/23/2026
1.0.1 112 1/22/2026
1.0.0 124 1/12/2026

v1.0.2: Fixed server not exiting when MCP client disconnects (stdin EOF handling)