| Filename | Latest commit message | Latest commit date |
|---|---|---|
* Server support (stdio) * TestServer project * Refactored McpClient class to extract shared endpoint logic (with McpServer) to a base class, McpJsonRpcEndpoint. * Improved xmldoc comments for protocol types, mirroring specification schema comments. * Update README.MD |
||
| .. | ||
| anthropic/tools/ToolsConsole | ||
| microsoft.extensions.ai/tools/ToolsConsole | ||
| README.md | ||
Samples
This directory contains example projects demonstrating how to use mcpdotnet with different LLM SDKs and platforms.
Environment Setup
Before running the samples, you'll need to set up the following environment variables:
ANTHROPIC_API_KEY- Required for the Anthropic sampleOPENAI_API_KEY- Required for the MEAI/OpenAI sample
Sample Projects
Anthropic Integration
Located in samples/anthropic, this sample demonstrates integration with Anthropic's Claude API using mcpdotnet. The example shows how to:
- Configure an MCP client for use with Anthropic
- Map between MCP protocol types and Anthropic SDK types
- Handle tool invocations and responses
Microsoft.Extensions.AI Integration
Located in samples/microsoft.extensions.ai, this sample shows how to use mcpdotnet with Microsoft's AI SDK. It demonstrates:
- Setting up an MCP client with MEAI
- Mapping MCP tools to MEAI function calls
- Handling streaming responses and tool invocations
Implementation Notes
Each sample focuses on the mapping between MCP types and SDK-specific types, which is the primary integration point when working with different LLM SDKs. The samples provide reusable mapping code that can serve as a starting point for your own implementations.
The complexity of this mapping varies depending on how closely the SDK's design aligns with typical LLM APIs. The provided samples demonstrate best practices for both straightforward and more complex mapping scenarios.
Running the Samples
- Clone the repository
- Set up the required environment variables
- Navigate to the desired sample directory
- Run
dotnet runto execute the sample
For more detailed examples of mcpdotnet usage, you can also refer to the integration tests in the tests/McpDotNet.IntegrationTests project.