koan-mcp-integration

MCP server patterns, Code Mode integration, tool building

⭐2stars🔀1forks📁View on GitHub🕐Updated Nov 11, 2025⬇️1downloads

When & Why to Use This Skill

The Koan MCP Integration skill enables developers to build and deploy Model Context Protocol (MCP) servers using the Koan framework in C#. It provides a standardized approach to exposing application services as tools for Claude, facilitating seamless integration with Claude's Code Mode for enhanced AI-driven development and automation.

Use Cases

  • Scenario 1: Building custom MCP servers to expose internal business logic, such as database entities or proprietary APIs, directly to Claude as executable tools.
  • Scenario 2: Integrating C# applications with Claude's Code Mode to allow the AI to perform real-time data retrieval and manipulation during coding sessions.
  • Scenario 3: Developing standardized tool schemas using the Koan framework to create reusable agentic capabilities for Claude-based workflows.
namekoan-mcp-integration
descriptionMCP server patterns, Code Mode integration, tool building

Koan MCP Integration

Core Principle

Expose Koan services as MCP tools for Claude integration. Use framework patterns for tool implementations.

MCP Server Setup

Basic MCP Server

using Koan.Mcp;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddKoan();
builder.Services.AddKoanMcp(); // Adds MCP capabilities
var app = builder.Build();
app.Run();

Expose Entity as MCP Tool

public class TodoMcpTool : IMcpTool
{
    public string Name => "get_todo";
    public string Description => "Retrieve a todo by ID";

    public McpToolSchema Schema => new()
    {
        Parameters = new[]
        {
            new McpParameter { Name = "id", Type = "string", Required = true }
        }
    };

    public async Task<McpToolResult> ExecuteAsync(
        Dictionary<string, object> args,
        CancellationToken ct)
    {
        var id = args["id"].ToString();
        var todo = await Todo.Get(id, ct);

        return new McpToolResult
        {
            Content = todo != null
                ? $"Todo: {todo.Title} (Completed: {todo.Completed})"
                : "Todo not found"
        };
    }
}

Configuration

{
  "Koan": {
    "Mcp": {
      "ServerName": "Todo MCP Server",
      "Version": "1.0.0",
      "Transport": "stdio",
      "Capabilities": {
        "Tools": true,
        "Resources": true,
        "Prompts": false
      }
    }
  }
}

Code Mode Integration

MCP servers integrate with Claude Code Mode for enhanced capabilities.

When This Skill Applies

  • ✅ Building MCP servers
  • ✅ Claude integrations
  • ✅ Tool development
  • ✅ MCP Code Mode

Reference Documentation

  • Guide: docs/guides/mcp-http-sse-howto.md
  • Sample: samples/S16.PantryPal/MCP/ (MCP server example)
  • Module: src/Koan.Mcp/