Token导航 LogoToken导航TokenDH.com
MCP C logo
开发工具未说明官方级别未说明来源级核验

MCP C

MCP Server

mcp server frarmwork written in c, developing efficiently and effortlessly

工具数

0

提示词数

0

GitHub Stars

6

资源数

0
C++代码生成服务器开发

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

ZenWayne

提供方

ZenWayne

最后核验

2026/5/18 04:04

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

mcp-c

用c编写的mcp服务器框架,高效轻松地开发 利用注释自动生成代码,只需要关注需要编写什么mcp服务器函数

如何使用

  1. 在下面编写自己的mcp工具 src/mcp_server

- 添加属性 EXPORTEXPORT_AS(name) 到要使用的函数和结构

  1. 构建项目, cmake -B build -S . && cmake --build .,export.cpp将为您生成所有繁琐的代码(如工具列表、将json桥接到struct等)
  2. 运行项目, ./mcpc

快速开始

  1. 先决条件
  • vcpkg(仅适用于windows)
  • cmake
  • 铿锵
  • cJSON
  1. 构建项目

窗户

cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ^
    -DCMAKE_TOOLCHAIN_FILE="path/to/vcpkg/scripts/buildsystems/vcpkg.cmake" ^
    -G "Ninja" ^
    -DVCPKG_APPLOCAL_DEPS=ON ^
    -DCMAKE_BUILD_TYPE=Release ^
    -B build -S . 
  1. 运行项目
./mcpc

支持的功能

  1. 导出结构体

首先,您需要将宏添加到结构中 考虑这个文件名struct.c

#include "export_macro.h" //first include the export macro
typedef enum EXPORT COLOR {
    RED,
    GREEN,
    BLUE
} COLOR;

typedef struct EXPORT_AS(cloth) cloth {
    enum COLOR color DES("color of the cloth");
    int size;
} cloth;

typedef struct EXPORT person {
    bool isMale DES("whether is male or not male is true");
    int age DES("age of the person");
    char* name;
    cloth wearing_cloths;
} person;

执行export.exe struct.c后 这将在src文件夹下生成序列化代码 generatedbridge_code.c包含将json解析为对象的代码 generated函数签名.c包含结构体的定义代码

上面的代码示例将生成一个get_allfunction_signatures_json函数 生成定义json,如下所示

{
        "$defs":        {
                "COLOR":        {
                        "type": "integer",
                        "enum": ["RED", "GREEN", "BLUE"]
                },
                "cloth":        {
                        "type": "object",
                        "properties":   {
                                "color":        {
                                        "$ref": "#/$defs/COLOR",
                                        "description":  "color of the cloth"
                                },
                                "size": {
                                        "type": "integer"
                                }
                        },
                        "required":     ["color", "size"]
                },
                "person":       {
                        "type": "object",
                        "properties":   {
                                "isMale":       {
                                        "type": "boolean",
                                        "description":  "whether is male or not male is true"
                                },
                                "age":  {
                                        "type": "integer",
                                        "description":  "age of the person"
                                },
                                "name": {
                                        "type": "string"
                                },
                                "wearing_cloths":       {
                                        "$ref": "#/$defs/cloth"
                                }
                        },
                        "required":     ["isMale", "age", "name", "wearing_cloths"]
                }
        },
        "tools":[]
}
  1. 通过注释导出函数签名和结构

首先,您需要为需要导出的函数和结构添加宏 考虑这个文件名func.c

#include "export_macro.h" //first include the export macro
... //struct definition here, with the code sample in section 1
EXPORT_AS(get_color) //if the function is a handler of tool "get_color", you need to add this macro
cJSON* get_color(COLOR c)
{

}

EXPORT_AS(get_person_info) //if the function is a handler of tool "get_person_info", you need to add this macro
cJSON* get_person_info(person* p, int id)
{

}

EXPORT_AS(tools, list) // if the function is a handler of tool "tools/list", you need to add this macro, use the comma to separate the tool name and the function name
cJSON* tools_list() {
    int i = 0;
    return get_all_function_signatures_json();
}

这将生成一个get_allfunction_signatures_json函数,该函数将返回以下函数签名json

{
   "#def": { ... } // param type defition here
   "tools":        [{
                        "name": "tools/list",
                        "description":  "",
                        "inputSchema":  {
                                "type": "object",
                                "properties":   {
                                },
                                "required":     [],
                                "additionalProperties": false,
                                "$schema":      "http://json-schema.org/draft-07/schema#"
                        }
                }, {
                        "name": "get_color",
                        "description":  "",
                        "inputSchema":  {
                                "type": "object",
                                "properties":   {
                                        "c":    {
                                                "$ref": "#/$defs/COLOR"
                                        }
                                },
                                "required":     ["c"],
                                "additionalProperties": false,
                                "$schema":      "http://json-schema.org/draft-07/schema#"
                        }
                }, {
                        "name": "get_person_info",
                        "description":  "",
                        "inputSchema":  {
                                "type": "object",
                                "properties":   {
                                        "p":    {
                                                "$ref": "#/$defs/person"
                                        },
                                        "id":   {
                                                "type": "integer"
                                        }
                                },
                                "required":     ["p", "id"],
                                "additionalProperties": false,
                                "$schema":      "http://json-schema.org/draft-07/schema#"
                        }
     }]
}
  1. 简称EXPORT

目录标签

目录标签

C++代码生成服务器开发developer-toolsmcpmcp-server本地部署自动化开发C语言框架

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明none部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP