C++ SDK for interacting with the Copilot CLI agent runtime (JSON-RPC over stdio or TCP).
Requirements: CMake 3.20+ and a C++20 compiler.
cmake -S . -B build
cmake --build build --config ReleaseUnit tests:
ctest --test-dir build -C Release --output-on-failureE2E tests (real Copilot CLI):
- Require
copilotto be installed and authenticated. - To disable E2E tests in CI/non-interactive runs, set
COPILOT_SDK_CPP_SKIP_E2E=1.
Snapshot conformance tests (optional):
- Require Python 3 and the upstream
copilot-sdksnapshots directory. - Install Python deps:
python -m pip install --user -r tests/snapshot_tests/requirements.txt - Enable with
-DCOPILOT_BUILD_SNAPSHOT_TESTS=ONand set-DCOPILOT_SDK_CPP_SNAPSHOT_DIR=...if auto-detection fails. - Run:
cmake --build build --target run_snapshot_tests --config Release
Custom tools must be provided when creating or resuming a session. The SDK registers tool handlers locally and sends tool definitions to the server:
// Define your tool
copilot::Tool calc_tool;
calc_tool.name = "calculator";
calc_tool.description = "Perform math calculations";
calc_tool.parameters_schema = copilot::json{
{"type", "object"},
{"properties", {{"expression", {{"type", "string"}}}}},
{"required", {"expression"}}
};
calc_tool.handler = [](const copilot::ToolInvocation& inv) {
copilot::ToolResultObject result;
// Handle the tool call...
return result;
};
// Pass tools when creating the session
copilot::SessionConfig config;
config.tools = {calc_tool};
auto session = client.create_session(config).get();
// Or when resuming an existing session
copilot::ResumeSessionConfig resume_config;
resume_config.tools = {calc_tool};
auto session = client.resume_session(session_id, resume_config).get();See examples/tools.cpp and examples/resume_with_tools.cpp for complete examples.
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./install
cmake --build build --config Release
cmake --install build --config Release| Project | Language | Description |
|---|---|---|
| claude-agent-sdk-cpp | C++ | C++ port of the Claude Agent SDK |
| claude-agent-sdk-dotnet | C# | .NET port of the Claude Agent SDK |
| fastmcpp | C++ | C++ port of FastMCP for building MCP servers |
Copyright 2025 Elias Bachaalany
Licensed under the MIT License. See LICENSE for details.
This is a C++ port of copilot-sdk by GitHub.