{"id":29091260,"url":"https://github.com/liuli-neko/coro-cpp-mcp","last_synced_at":"2026-01-20T16:27:40.375Z","repository":{"id":289699222,"uuid":"970809657","full_name":"liuli-neko/coro-cpp-mcp","owner":"liuli-neko","description":"Lightweight C++ MCP (Model Context  Protocol) SDK implemented using cpp20 coroutines.","archived":false,"fork":false,"pushed_at":"2025-11-16T09:12:53.000Z","size":75,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-16T09:19:07.445Z","etag":null,"topics":["coroutines","cpp20","mcp","mcp-client","mcp-sdk","mcp-server","mcpclient","mcpserver"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/liuli-neko.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-22T15:11:01.000Z","updated_at":"2025-11-16T09:12:56.000Z","dependencies_parsed_at":"2025-04-24T16:35:14.824Z","dependency_job_id":"13d54a88-09f4-4a0c-9dd1-0ade0431a9cc","html_url":"https://github.com/liuli-neko/coro-cpp-mcp","commit_stats":null,"previous_names":["liuli-neko/coro-cpp-mcp"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/liuli-neko/coro-cpp-mcp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liuli-neko%2Fcoro-cpp-mcp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liuli-neko%2Fcoro-cpp-mcp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liuli-neko%2Fcoro-cpp-mcp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liuli-neko%2Fcoro-cpp-mcp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/liuli-neko","download_url":"https://codeload.github.com/liuli-neko/coro-cpp-mcp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liuli-neko%2Fcoro-cpp-mcp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28607082,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T16:10:39.856Z","status":"ssl_error","status_checked_at":"2026-01-20T16:10:39.493Z","response_time":117,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["coroutines","cpp20","mcp","mcp-client","mcp-sdk","mcp-server","mcpclient","mcpserver"],"created_at":"2025-06-28T06:06:29.534Z","updated_at":"2026-01-20T16:27:40.359Z","avatar_url":"https://github.com/liuli-neko.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# coro-cpp-mcp\nLightweight C++ Coroutines MCP (Model Context  Protocol)\n\n## Overview\n该项目为轻量级C++协程库，基于C++20协程实现。提供了基础的mcp-server的实现框架。\n项目使用xmake构建，所有依赖均可全头。\n\n## Usage\n[xmake](https://github.com/xmake-io/xmake)\n### install deps\n```shell\nxmake f -m debug -cvy\n```\n\n### build\nbuild example/server 下面的示例\n```shell\nxmake build server-example\n```\n\n### run\n运行example/server 下面的示例，\n```shell\nxmake run server-example\n```\n\n该示例基于stdio。可以手动输入json进行交互\n```json\n{\"method\":\"initialize\",\"params\":{\"protocolVersion\":\"2024-11-05\",\"capabilities\":{},\"clientInfo\":{\"name\":\"Cline\",\"version\":\"3.13.1\"}},\"jsonrpc\":\"2.0\",\"id\":0}\n{\"method\":\"notifications/initialized\",\"jsonrpc\":\"2.0\"}\n{\"method\": \"tools/list\", \"jsonrpc\": \"2.0\", \"id\": 1}\n{\"method\": \"tools/call\", \"params\": {\"name\": \"add\", \"arguments\": {\"a\": 13, \"b\": 22}}, \"jsonrpc\": \"2.0\", \"id\": 2}\n{\"method\": \"tools/call\", \"params\": {\"name\": \"mult\", \"arguments\": {\"a\": 15, \"b\": 42}}, \"jsonrpc\": \"2.0\", \"id\": 3}\n{\"method\": \"tools/call\", \"params\": {\"name\": \"div\", \"arguments\": {\"a\": 16, \"b\": 22}}, \"jsonrpc\": \"2.0\", \"id\": 4}\n{\"method\": \"tools/call\", \"params\": {\"name\": \"div\", \"arguments\": {\"a\": 1, \"b\": 0}}, \"jsonrpc\": \"2.0\", \"id\": 5}\n```\n也可以配置到cline的本地服务中，配置完成后即可让ai使用。\n\n## Example\n### server\n以下是服务端简易的使用说明，完整的示例请参考`example/server`。\n```c++\n// 定义\nstruct TowParams { // 定义参数结构体\n    double a;\n    double b;\n};\nstruct MCPTools {\n    ToolFunction\u003cdouble(TowParams), \"add\"\u003e add{\"sum of two numbers\"}; // 定义add函数。\n};\nint main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[]) {\n    ILIAS_NAMESPACE::PlatformContext platform;\n    McpServer\u003cMCPTools\u003e server(platform); // 创建服务,并自动注册MCPTools中的函数\n    server.set_instructions(\"This is a test server\");   // 设置说明(可选)\n    server.setCapabilities(ResourcesCapability{.subscribe = {}, .list_changed = {}}); // 设置能力(可选)\n    server-\u003eadd.paramsDescription({{\"a\", \"first number\"}, {\"b\", \"second number\"}}); // 设置参数说明(可选)\n    server.register_tool_function(\"mult\", std::function([](Params p) { return p.a * p.b;})); // 通过函数注册函数\n\n    auto logFile = (std::filesystem::current_path() / \"log.txt\").string();\n    server.register_local_file_resource(\"log\", logFile); // 注册本地文件资源\n\n    // 注册静态资源\n    server.register_resource({.uri         = \"my_uri\",\n                              .name        = \"my_name\",\n                              .description = \"my github name\",\n                              .metadata    = std::nullopt,\n                              .annotations = std::nullopt},\n                             TextResourceContents{.text = \"liuli-neko\"});\n\n    // 注册动态资源\n    server.register_resource({.uri         = \"my_uri2\",\n                              .name        = \"my_name2\",\n                              .description = \"my github name2\",\n                              .metadata    = std::nullopt,\n                              .annotations = std::nullopt},\n                             [](std::optional\u003cccmcp::Meta\u003e meta) -\u003e TextResourceContents {\n                                 // you can use the meta to determine what to return\n                                 return TextResourceContents{.text = \"https://github.com/liuli-neko\"};\n                             });\n\n    // 自定以jsonrpc回复\n    server.json_rpc_server()-\u003eresourcesTemplatesList = [](auto) -\u003e ListResourceTemplatesResult { \n        // 您可以在这里返回你自己的资源模板列表\n        return {}; \n    };\n\n    ilias_wait server.start\u003cStdio\u003e(\"stdio://stdout-stdin\"); // 启动服务\n    ilias_wait server.wait(); // 等待服务结束\n}\n```\n\n### client\n以下是一个简单的客户端示例，完整的示例请参考`example/client/`。\n```cpp\nstruct TowParams { // 定义参数结构体\n    double a;\n    double b;\n};\nstruct MCPTools {\n    ToolFunction\u003cdouble(TowParams), \"add\"\u003e add{\"sum of two numbers\"}; // 定义一个方法，参数为TowParams，返回值为double\n};\n\nint main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[]) {\n    ILIAS_NAMESPACE::PlatformContext platform;\n    McpClient\u003cMCPTools\u003e client(platform); // 创建客户端并自动注册MCPTools里面定义的方法\n\n    ilias_wait client.connect\u003cStdio\u003e(\"stdio://stdout-stdin\"); // 连接服务\n    auto ret = ilias_wait client-\u003eadd({.a = 5, .b = 2}); // 调用服务端的方法\n    std::cout \u003c\u003c \"add: \" \u003c\u003c ret.value_or(-1) \u003c\u003c std::endl; // 输出结果\n\n    return 0;\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliuli-neko%2Fcoro-cpp-mcp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliuli-neko%2Fcoro-cpp-mcp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliuli-neko%2Fcoro-cpp-mcp/lists"}