mcp-core¶
A reusable C17 library that turns any C program into an MCP 2.0 stdio server with minimal glue code. It implements the Model Context Protocol revision 2026-07-28 (MCP 2.0) server side — JSON-RPC 2.0 framing, server discovery, protocol version negotiation, cancellation and the tools primitive — so an application only has to register its tools and fill in the answers.
It was created as the common foundation for our MCP-based retro computing tools (see z80mcp): one well-tested, spec-faithful protocol core instead of every server hand-rolling framing and dispatch.
Features¶
- MCP 2.0 (protocol revision 2026-07-28) stdio server, newline-delimited JSON, UTF-8 — no LSP-style headers (verified against the spec).
server/discoverhandling with name, version, supportedVersions, capabilities, caching hints and theinstructionsfield for LLMs.- Per-request
_metaprotocol version contract, includingUnsupportedProtocolVersionErroron mismatch. notifications/cancelledhonored for in-flight tool calls.- Tools primitive:
tools/listwith cursor pagination andtools/call. - Tool registration API: name, title, description, JSON-Schema input schema declared as data (minimal required/type/enum validation).
- Plain C17, no external dependencies beyond libc; ships as a static library with a Unity-based test suite (ASan/UBSan clean).
Prerequisites¶
- GNU make and any C compiler (
cc); no external libraries — cJSON and the Unity test framework are vendored invendor/.
Usage¶
Build and run the test suite:
make # builds libmcpcore.a and the test binary
make test # unit tests, ASan/UBSan clean
Link it into your server and register a tool (sketch):
#include "mcpcore.h"
static int hello(void *ctx, const char *args, char **out) {
*out = strdup("{\"result\":\"hello\"}");
return 0;
}
int main(void) {
mcp_server *s = mcp_server_init(&(mcp_server_info){
.name = "example", .version = "1.0.0",
.instructions = "Example MCP server."
});
mcp_register_tool(s, &(mcp_tool){
.name = "hello", .title = "Hello",
.description = "Says hello.",
.input_schema = "{ \"type\": \"object\" }",
.handler = hello, .ctx = NULL
});
return mcp_server_run(s); /* reads stdin, writes stdout */
}
Run it under any MCP host as a stdio server:
./example-server
See SPEC.md for the full behavioral specification and the agreed
protocol decisions.
Download¶
- Release build:
mcp-core-2026-12-04.zip(version = release date) - Release notes: releasenotes/
License¶
MIT — see https://opensource.org/license/mit.
Contact¶
devel ät datenbrei.de
Download & Release Notes¶
- Download:
mcp-core-2026-12-04.zip(version = release date) - Release Notes: releasenotes/