
afrise/mcpsharp
Developer toolsこのページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る
MCPSharpは、モデルコンテキストプロトコル(MCP)サーバーとクライアントを構築するのを支援する.NETライブラリです。MCPはAIアシスタントやモデルが使用する標準化されたAPIプロトコルです。
概要
MCPSharpは、モデルコンテキストプロトコル(MCP)サーバーとクライアントを構築するのを支援する.NETライブラリです。これはAIアシスタントやモデルが使用する標準化されたAPIプロトコルです。MCPSharpを使えば、以下のことができます: - AIモデルが発見し使用できるMCP準準のツールや関数の作成 - 使いやすいクライアントでC#コードから既存のMCPサーバーに直接接続 - .NETメソッドをMCPエンドポイントとしてシンプルな属性で公開する - MCPプロトコルの詳細とJSON-RPC通信をシームレスに処理する - : MCPSharpは現在Microsoft.Extensionsと統合されています。
概要(AI 翻訳)
MCPSharpは、モデルコンテキストプロトコル(MCP)サーバーとクライアントを構築するのを支援する.NETライブラリです。これはAIアシスタントやモデルが使用する標準化されたAPIプロトコルです。MCPSharpを使えば、以下のことができます:
- AIモデルが発見し利用できるMCP準拠のツールや機能の作成
- 使いやすいクライアントで既存のMCPサーバーに直接C#コードから接続
- .NETメソッドをMCPエンドポイントとしてシンプルな属性で公開する
- MCPプロトコルの詳細およびJSON-RPC通信をシームレスに処理
🚀 MCPSharpの最新情報
- Microsoft.Extensions.AI 統合:MCPSharpは Microsoft.Extensions.AI と統合され、ツールをAIFunctionsとして公開できるようになりました
- セマンティックカーネルサポート:セマンティックカーネルのKernelFunctionAttributeを使ったツールの追加
- 動的ツールレジストレーション:カスタム実装ロジックを用いたレジスタツールのオンザフライ
- ツール変更通知:サーバーはツールの追加、更新、削除時にクライアントに通知します
- 複雑なオブジェクトパラメータサポート:ツールパラメータにおける複雑なオブジェクトのより良い取り扱い
- より良いエラー処理:詳細なスタックトレースによるエラー処理の改善
MCPSharpの使い方
MCPSharpを使いたいときに使う:
このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。
README
以下は原文 README の抜粋です。原文を見る。
MCPSharp
MCPSharp is a .NET library that helps you build Model Context Protocol (MCP) servers and clients - the standardized API protocol used by AI assistants and models. With MCPSharp, you can:
- Create MCP-compliant tools and functions that AI models can discover and use
- Connect directly to existing MCP servers from C# code with an easy to use client
- Expose your .NET methods as MCP endpoints with simple attributes
- Handle MCP protocol details and JSON-RPC communication seamlessly
🚀 What’s New in MCPSharp
- Microsoft.Extensions.AI Integration: MCPSharp now integrates with Microsoft.Extensions.AI, allowing tools to be exposed as AIFunctions
- Semantic Kernel Support: Add tools using Semantic Kernel’s KernelFunctionAttribute
- Dynamic Tool Registration: Register tools on-the-fly with custom implementation logic
- Tool Change Notifications: Server now notifies clients when tools are added, updated, or removed
- Complex Object Parameter Support: Better handling of complex objects in tool parameters
- Better Error Handling: Improved error handling with detailed stack traces
When to Use MCPSharp
Use MCPSharp when you want to:
- Create tools that AI assistants like Anthropic’s Claude Desktop can use
- Build MCP-compliant APIs without dealing with the protocol details
- Expose existing .NET code as MCP endpoints
- Add AI capabilities to your applications through standardized interfaces
- Integrate with Microsoft.Extensions.AI and/or Semantic Kernel without locking into a single vendor
Features
- Easy-to-use attribute-based API (
[McpTool],[McpResource]) - Built-in JSON-RPC support with automatic request/response handling
- Automatic parameter validation and type conversion
- Rich documentation support through XML comments
- Near zero configuration required for basic usage
Prerequisites
- Any version of .NET that supports standard 2.0
Installation
dotnet add package MCPSharp
Quick Start
1. Define a Tool
Create a class and mark your method(s) with the [McpTool] attribute:
using MCPSharp;
public class Calculator
{
[McpTool("add", "Adds two numbers")] // Note: [McpFunction] is deprecated, use [McpTool] instead
public static int Add([McpParameter(true)] int a, [McpParameter(true)] int b)
{
return a + b;
}
}
2. Start the Server
await MCPServer.StartAsync("CalculatorServer", "1.0.0");
インストール
This server does not publish a one-line install command.
Open the repository installation guide MCP 初心者?mcpskill.org のガイドから始めましょう →