mcp-client-demo

MCP.Pizza Chef: KelvinQiu802

mcp-client-demo is a fundamental MCP client implementation designed to integrate DeepSeek into the MCP ecosystem. It uses JSON-RPC 2.0 for strict communication protocols between MCP clients and servers, enabling unified service registration and discovery. This client standardizes interactions across different LLM providers by abstracting API differences, facilitating easy reuse and interoperability of MCP tools.

Use This MCP client To

Integrate DeepSeek with MCP ecosystem for real-time context sharing Standardize communication between LLMs and MCP servers using JSON-RPC Enable unified service discovery and registration for MCP tools Abstract API differences across OpenAI, Anthropic, and DeepSeek Develop interoperable MCP clients compatible with multiple MCP servers

README

MCP Client

内容

  • 实现一个最基本的Client,让deepseek接入MCP生态
    • 核心架构
    • JSON-RPC 2.0
      • RPC是什么
  • MCP和Function Calling的区别
  • 各家API的差异
    • OpenAI / Anthropic / DeepSeek
  • 参考5ire源码如何抹平API差异

MCP架构

https://modelcontextprotocol.io/docs/concepts/architecture

https://www.jsonrpc.org/

MCP Client的实现

https://modelcontextprotocol.io/quickstart/client

https://github.com/modelcontextprotocol/typescript-sdk

MCP 和 Function Calling的区别

MCP的tool调用

graph LR
  LLM <--> MCP_Client <--> MCP_Server
Loading
  • MCP Client和MCP Server之间有严格的通讯协议
  • Server端提供了统一的接口规范和服务注册机制
  • Client端知道如何与Server通信,以及可用的服务列表
  • 由于有统一的协议规范,不同开发者开发的工具可以很容易地被其他MCP客户端复用
  • 服务端的注册机制使得工具的发现和共享变得简单

FunctionCalling的tool调用

graph LR
  LLM <--> AnyClient <--> AnyServer
Loading

API差异

https://platform.openai.com/docs/api-reference/chat

https://docs.anthropic.com/en/api/messages

https://api-docs.deepseek.com/api/create-chat-completion

  • 差异
    1. function_calling的函数定义格式
    2. function_calling返回的数据结构
    3. 调用结束后,message的数据结构

5ire抹平API差异的方式

  • 各家模型的API返回的数据结构不一样,如何抹平LLM模型的输出和mcp-client之间的差异?
  • 既然知道不一样 → 就可以转换成一样的
  • https://github.com/nanbingxyz/5ire
  1. 函数定义方式不同 → ChatService的makeTool来处理
  2. 函数调用结果不同 → Reader的parseReply和parseTools来处理
  3. message格式不同 → ChatService的makeToolMessages来处理

mcp-client-demo FAQ

How does mcp-client-demo handle communication with MCP servers?
It uses JSON-RPC 2.0 protocol to ensure strict, standardized communication between clients and servers.
What makes mcp-client-demo different from typical function calling?
It enforces a unified protocol and service registration, enabling tool discovery and cross-client compatibility.
Can mcp-client-demo work with multiple LLM providers?
Yes, it abstracts API differences among providers like OpenAI, Anthropic, and DeepSeek for seamless integration.
Is mcp-client-demo compatible with existing MCP servers?
Yes, it follows MCP protocol standards to communicate effectively with compliant MCP servers.
Where can I find the source code for mcp-client-demo?
The implementation references the official MCP TypeScript SDK available on GitHub.
How does mcp-client-demo simplify tool reuse across different clients?
By adhering to a unified protocol and service registration, tools developed for one client can be reused by others easily.
What architecture does mcp-client-demo follow?
It follows the MCP modular client-server architecture with strict JSON-RPC communication.
Does mcp-client-demo support service discovery?
Yes, it supports a service registration mechanism that simplifies tool discovery and sharing.