McpClientServerExample logo

McpClientServerExample

by dks50217

McpClientServerExample is a sample project based on the Model Context Protocol (MCP), demonstrating client-server communication. It includes McpClient and McpServer components.

View on GitHub

Last updated: N/A

What is McpClientServerExample?

McpClientServerExample is a .NET project demonstrating client-server communication using the Model Context Protocol (MCP). It provides a client (McpClient) that can interact with a server (McpServer), supporting OpenAI GPT models and tool function calling.

How to use McpClientServerExample?

  1. Install .NET 8.0 SDK. 2. Set your OpenAI API key as an environment variable: export OPENAI_API_KEY=your_api_key_here. 3. Run the client project: dotnet run --project client/McpClient.csproj.

Key features of McpClientServerExample

  • Client-server communication using MCP

  • OpenAI GPT model support in the client

  • Tool function calling support in the client

  • Built-in tools (Echo, ReverseEcho) in the server

Use cases of McpClientServerExample

  • Building custom clients for interacting with language models

  • Implementing MCP-based communication protocols

  • Developing applications that utilize tool functions with language models

  • Creating custom server implementations for specific tasks

FAQ from McpClientServerExample

What is Model Context Protocol (MCP)?

MCP is a protocol for communication between a client and a server, often used in the context of language models and tool function calling.

What is the purpose of McpClient?

McpClient is a client application that uses the ModelContextProtocol.Client to communicate with an MCP server, supporting OpenAI GPT models and tool function calling.

What is the purpose of McpServer?

McpServer is a server application that provides MCP server functionality using ModelContextProtocol.Server, supporting standard input/output communication and built-in tools.

What are the built-in tools provided by McpServer?

McpServer provides two built-in tools: Echo (returns the user's input) and ReverseEcho (returns the reversed version of the user's input).

Do I need an OpenAI API key to use this project?

Yes, if you plan to use the GPT model functionality in the client, you need to set your OpenAI API key as an environment variable.