A C++ MCP host, client, and server implementation

A C++ MCP host, client, and server implementation

nativemcp•bysihaoh

A C++ MCP system providing a host AI agent, an internal MCP client, a base MCPServer class, and concrete stdio-based MCP servers usable by other MCP-compatible software.

License: Not specified•Runtime: Awaiting documentation review•Category: developer tools

WHAT IT DOES

  • •Provides a base MCPServer class that developers can subclass to define MCP server tools, with stdio as the supported transport.
  • •Includes concrete MCP servers implemented by subclassing MCPServer, such as a time server and a test server with available-IP and send-to-IP tools.
  • •Runs a host agent that connects to an LLM through an adapter using cpp-httplib to call Ollama, and loads MCP clients according to configuration.
  • •Maintains 1:1 connections between the host's MCPClient and servers, invoking MCP server tools when the LLM needs them.

BEST FOR

  • •Developers who want to implement MCP servers in C++ by subclassing a provided MCPServer base class with stdio transport.
  • •Users who want MCP servers that can be used by other MCP-compatible software such as Cursor.
  • •Building a command-line AI agent host that connects to local Ollama models and calls MCP tools.

ABOUT NATIVEMCP

A C++ MCP host, client, and server implementation is cataloged as an MCP server attributed to sihaoh. A C++ MCP system providing a host AI agent, an internal MCP client, a base MCPServer class, and concrete stdio-based MCP servers usable by other MCP-compatible software. It is categorized under developer tools. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.

HOW TO INSTALL

Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.

LICENSE

Catalog license label: Not specified. Check the source repository's current license and terms before using, modifying or distributing this software.

Capability inspector

Capability definitions are not reviewed. Unreviewed imports are not exposed as trusted interfaces.

Tools (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

Resources (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

Prompts (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

NEWSLETTER - COMING LATER

Newsletter subscriptions are not open yet

Email delivery is not connected. This page does not collect email addresses or create subscriptions.

Browse the registry for current listings instead.

Community Reviews

Coming later

Reviews for A C++ MCP host, client, and server implementation are not available yet

Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.

FREQUENTLY ASKED QUESTIONS

What transport does the MCPServer implementation support?

The MCPServer base class currently supports only stdio communication.

Can the servers be used with other MCP-compatible software?

Yes, the servers can be used by other software that supports MCP, such as Cursor.

Which LLM backend does the host's ModelAdapter use?

The current ModelAdapter implementation uses cpp-httplib to send requests to Ollama.

Upstream README

View this exact version on GitHub

README.md · 5ecf5c068fbd · Fetched 2026-11-13 10:15:46 UTC

Original upstream text, without AI rewriting. Scripts, forms and unsafe links are filtered for safety.

Showing the last retrieved documentation snapshot; check the source for current changes.

nativeMCP

概述

这是一个由C++编写的MCP系统,包括MCP核心架构的host、client和server;而host本身已经相当于是AI Agent,虽然目前只有命令行(但我觉得也不需要花哨界面)

参考:https://modelcontextprotocol.io/introduction

server可用于其他支持MCP的软件,如Cursor

client也支持MCP官方的servers,和Cursor同样的配置即可

基本组成

  • MCPServer:遵循MCP的Server父类,相当于SDK,子类只需要继承以及按要求新增所需的方法即可;目前通信方式只支持stdio
  • servers:继承MCPServer后实现的一些具体server,可以直接使用;后续分支再更新更多的工具
  • host:宿主应用程序,连接LLM,根据配置加载MCPClient
    • MCPClient:在host应用程序内部与服务器保持1:1连接,在LLM需要的时候调用MCPServer提供的工具
    • ModelAdapter:连接LLM的适配层,目前实现是使用cpp-httplib对Ollama发起请求

依赖库&外部程序

  • Qt6.8:字符串、Json处理,元对象机制(用于动态调用任意函数)
  • cpp-httplib:用于请求Ollama或是其他在线大模型的api
  • Ollama:本地部署大模型的后端程序
    • LLM 任意的大语言模型,用于自然语言的问答,例如DeepSeek、Qwen等

编译环境

编译工具链

  • CMake >= 3.30
  • Visual Studio 2022(勾选使用C++进行桌面开发)

vcpkg

用于导入第三方库cpp-httplib、spdlog

git clone https://github.com/microsoft/vcpkg.git
cd vcpkg && bootstrap-vcpkg.bat

然后将vcpkg.exe的路径添加到系统环境变量PATH里

Qt6.8.2

可以直接使用在线安装包,不过还是建议自己下载源码来构建。目前只需编译qt-base模块即可。

参考

https://doc.qt.io/qt-6/getting-sources-from-git.html

https://doc.qt.io/qt-6/windows-building.html

https://doc.qt.io/qt-6/configure-options.html

下载源码

git clone --branch v6.8.2 git://code.qt.io/qt/qt5.git .\src

生成

mkdir build
cd build
..\src\configure.bat -init-submodules -submodules qtbase
..\src\configure.bat -debug-and-release -prefix <path-to-qt>
cmake --build . --parallel
cmake --install .
cmake --install . --config debug

上述步骤有两次install,第一次默认是只安装release 最后将<path-to-qt>\bin添加到系统环境变量PATH中里

构建

clone源码并进入到源码目录下

mkdir build
cd build
cmake .. -G "Visual Studio 17 2022"

最后打开build/nativeMCP.sln进行编译和调试(注意先将host设为启动项,或者要调试server的话则将对应的server设为启动项)

配置

修改config.json,可简单配置MCP Host的功能

  • api
    • url:api的完整url
    • model:生成对话的模型,推荐deepseek或qwen
    • api_key:如果是本地部署的则为空
  • mcpServers
    • server名称(因为代码会判断冒号,所以不要使用冒号)
      • command:在windows系统上必须都是cmd
      • args:["/c"]第一个参数必须是/c,第二个参数看server的类型选择,exe直接是exe的路径,python程序则填python,Node.js则填npx,后面的参数再根据server的说明来填写

示例

[2025-03-26 12:27:30.296][info][Host.cpp::18] MCP Host初始化
[2025-03-26 12:27:30.299][info][ModelAdapter.cpp::22] ModelAdapter初始化:http://localhost:11434, qwen2.5:7b
[2025-03-26 12:27:30.397][info][Host.cpp::67]
可用工具列表:
cpp-time:
  getCurrentTime 获取当前时间
  waitTime 等待指定的时间
server-test:
  getAvailableIP 获取可用的IP列表
  sendToIP 将内容发送到指定的ip地址
  testMultiParams 测试多参数的工具调用

>>> 获取当前时间,并发送给所有可用的ip
[2025-03-26 12:29:08.349][info][Host.cpp::123] 调用MCP工具[cpp-time::getCurrentTime]: {
    "datetime": "2025-03-26T12:29:08.346",
    "timezone": "Asia/Shanghai"
}

[2025-03-26 12:29:20.160][info][Host.cpp::123] 调用MCP工具[server-test::getAvailableIP]: {
    "ip_list": [
        "192.168.1.201",
        "192.168.1.202",
        "192.168.1.203"
    ]
}

[2025-03-26 12:30:07.784][info][Host.cpp::123] 调用MCP工具[server-test::sendToIP]: {
    "content": "当前时间为:2025-03-26T12:29:08.346 (Asia/Shanghai)",
    "ip": "192.168.1.201",
    "status": "发送成功"
}

[2025-03-26 12:30:07.788][info][Host.cpp::123] 调用MCP工具[server-test::sendToIP]: {
    "content": "当前时间为:2025-03-26T12:29:08.346 (Asia/Shanghai)",
    "ip": "192.168.1.202",
    "status": "发送成功"
}

[2025-03-26 12:30:07.789][info][Host.cpp::123] 调用MCP工具[server-test::sendToIP]: {
    "content": "当前时间为:2025-03-26T12:29:08.346 (Asia/Shanghai)",
    "ip": "192.168.1.203",
    "status": "发送成功"
}

当前时间为:2025-03-26T12:29:08.346 (Asia/Shanghai)

已经将当前时间发送给所有可用的IP地址,发送状态均为成功。

Install configuration

Are you the maintainer?

Claim this server with your GitHub account to request manual ownership verification.

README Embed Badge
Markdown

Link to the catalog listing for A C++ MCP host, client, and server implementation from your README. This badge does not certify ownership, compatibility or security.

[![MCP catalog listing](https://img.shields.io/badge/MCP-awesome--mcp-orange?style=flat-square)](https://awesome-mcp.com/servers/nativemcp)

REPOSITORY STATS

GitHub StarsUnavailable
ForksUnavailable

Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.

Downloads and pulls

Separate sources, scopes and periods. Never combined or treated as installations, active users or security reviews.

No reviewed package or image identity; download statistics are not listed yet.

Related developer tools MCP Servers

Alternative and complementary servers in the same category

View all in developer tools →
Postbye
postbye-mcp•postbye-team

A directory listing describing a cancellation-letter and mailing-address service. The configured public GitHub repository returned 404 during source verification.

Repository stats unavailable
Developer Tools
Singapore Proxy MCP
singapore-proxy-mcp•Xavierfok

A hosted MCP service for browsing and searching through Singapore mobile-network proxies.

0
Developer Tools

A directory listing describing a Markdown-to-PDF service. The configured public GitHub repository returned 404 during source verification.

Repository stats unavailable
Developer Tools