MCP Gateway
Production-ready Model Context Protocol (MCP) Gateway for .NET 10
Build MCP servers that work with GitHub Copilot, Claude Desktop, and other AI assistants.
Quick Start
# Install package
dotnet add package Mcp.Gateway.Tools --version 1.8.0
# Create server
dotnet new web -n MyMcpServer
using Mcp.Gateway.Tools;
var builder = WebApplication.CreateBuilder(args);
builder.AddToolsService();
var app = builder.Build();
app.UseWebSockets();
app.UseProtocolVersionValidation();
app.MapStreamableHttpEndpoint("/mcp");
app.Run();
// Define your first tool
public class MyTools
{
[McpTool("greet")]
public JsonRpcMessage Greet(TypedJsonRpc<GreetParams> request)
{
var name = request.GetParams().Name;
return ToolResponse.Success(
request.Id,
new { message = $"Hello, {name}!" });
}
}
public record GreetParams(string Name);
Thatβs it! Your MCP server is ready.
Features
β‘ Quick to Get Started
Create your first MCP server in minutes with our simple API and comprehensive examples.
π Production Ready
Built-in lifecycle hooks, metrics, authorization, and monitoring for production deployments.
π Multiple Transports
Support for HTTP, WebSocket, SSE, and stdio transports. Works with all MCP clients.
π― MCP 2025-11-25 Compliant
100% compliant with the latest MCP specification. Streamable HTTP, SSE notifications, session management.
π¦ Resource Subscriptions
Optional MCP feature for targeted notifications. Subscribe to specific resources, reduce bandwidth.
π Lifecycle Hooks
Monitor tool invocations with built-in metrics, logging, and authorization support.
π Authorization
Role-based access control via lifecycle hooks. Declarative security with attributes.
π§ͺ 273 Tests
Comprehensive test coverage. All transports tested (HTTP, WebSocket, SSE, stdio).
Installation
Install via NuGet:
dotnet add package Mcp.Gateway.Tools
Or clone from source:
git clone https://github.com/eyjolfurgudnivatne/mcp.gateway
cd mcp.gateway
dotnet build
Connect from MCP Clients
GitHub Copilot
Create .mcp.json:
{
"mcpServers": {
"my_server": {
"command": "dotnet",
"args": ["run", "--project", "C:\\path\\to\\MyMcpServer", "--", "--stdio"]
}
}
}
Then in Copilot Chat:
@my_server call greet with name = "Alice"
Claude Desktop
Configure HTTP endpoint:
{
"mcpServers": {
"my_server": {
"transport": "http",
"url": "https://your-server.example.com/mcp"
}
}
}