Repository navigation
Releases
v0.5.0
Adds mcp.StatefulToolPack(State, defs) for tool packs whose handlers share mutable state (a daemon client, a database handle). The generated struct holds state: *State and passes it as the handlers' first parameter:
fn record(self: *Bridge, allocator: Allocator, args: RecordArgs) !types.CallToolResultMotivated by migrating a real downstream server whose tools are all stateful; the stateless ToolPack could not express it without globals. No breaking changes.
Install
zig fetch --save https://github.com/PaytonWebber/zig-mcp-sdk/archive/refs/tags/v0.5.0.tar.gzv0.4.0
Highlights
mcp.ToolPack: one declaration per tool.
fn hello(allocator: Allocator, args: HelloArgs) !types.CallToolResult {
const msg = try std.fmt.allocPrint(allocator, "Hello, {s}!", .{args.name});
return types.CallToolResult.text(allocator, msg);
}
const MyTools = mcp.ToolPack(.{
.hello = .{ .description = "Say hello", .handler = hello },
});That is a complete tool server: the JSON Schema, the tools/list entry, name dispatch, and typed argument parsing are generated at compile time from the handler's signature. The pack implements listTools/callTool, so it works directly as a Server handler or embedded in a larger one.
ToolContextfor handlers that report progress:tc.sendProgress(i, total)is a no-op when the client sent no progress token. Over HTTP, progress streams on the POST's own SSE response.- Composition:
ToolPack(.{ lib_a.tool_defs, my_defs })merges def groups, so libraries can export tools without owning a server binary. Duplicate names are a compile error. - Unknown tools and failed argument validation return descriptive
isErrorresults. types.parseArgsaccepts absent arguments when every field has a default.
No breaking changes; hand-written listTools/callTool handlers keep working. Both greeter examples now use packs.
See CHANGELOG.md.
Install
zig fetch --save https://github.com/PaytonWebber/zig-mcp-sdk/archive/refs/tags/v0.4.0.tar.gzv0.3.0
Closes the three remaining Streamable HTTP gaps from v0.2.0.
Highlights
- POST response streaming:
callToolmay take a per-callContext(fn(*Handler, Allocator, Context, CallToolParams), detected at compile time). Over HTTP, notifications sent during the call stream on the POST's own SSE response, progress events first, then the result, as the spec prefers. Over stdio they interleave on stdout. - Resumable event streams: SSE events carry ids, notifications sent with no stream open are buffered per session (
sse_replay_events) and replayed when one opens, andLast-Event-IDresumes after a reconnect. A new GET takes over the stream (last connection wins), so reconnecting clients are never locked out. - Session idle reaper: sessions inactive for
session_idle_seconds(default 600) are terminated by a background task, so clients that never send DELETE no longer pin session slots.
Behavior change
- A second GET stream on a session now takes over instead of receiving 409. Between keepalives a dead client is indistinguishable from a quiet one, so 409 locked out reconnecting clients for up to a keepalive interval.
See CHANGELOG.md for details.
Install
zig fetch --save https://github.com/PaytonWebber/zig-mcp-sdk/archive/refs/tags/v0.3.0.tar.gzv0.2.0
Highlights
- Concurrent HTTP transport: multiple live sessions (refcounted session map,
max_sessionscap), connections handled in parallel, per-session protocol version negotiation. - Server-sent events:
GETwithAccept: text/event-streamopens a per-session stream. Server-initiated notifications (logging, progress, channel events) arrive as SSE events with periodic keepalives. - Pagination: list handlers may take
(self, Allocator, types.ListParams)to receive the cursor; detected at compile time, existing 2-arg handlers keep working. - Cancellation + progress:
notifications/cancelledroutes to an optionalonCancelledhook;Context.sendProgressandCallToolParams.progressToken()support progress reporting. - HTTP conformance in CI: a curl-driven script exercises sessions, SSE delivery, security rejections, and termination on every push.
Breaking changes
Contextconstruction is now sink-based (.{ .sink = .{ .writer = w } }). Handler-facing methods are unchanged.- The HTTP transport handles connections concurrently: pass a thread-safe allocator (e.g.
std.heap.smp_allocator) and make handler methods tolerant of concurrent calls.
See CHANGELOG.md for the full list including bug fixes.
Install
zig fetch --save https://github.com/PaytonWebber/zig-mcp-sdk/archive/refs/tags/v0.2.0.tar.gzv0.1.0
First tagged release of zig-mcp-sdk, a Model Context Protocol SDK for Zig 0.16.0.
Highlights
- Comptime tool schemas:
types.schemaForStructgenerates MCP JSON Schema from a plain Zig struct at compile time;types.parseArgsparses incoming arguments into the same struct, so schema and parser cannot drift. Server(Handler): comptime-generic MCP server over stdio with request-scoped arena allocators, full lifecycle handling, and protocol version negotiation.- Streamable HTTP transport: session management, Origin validation (DNS rebinding protection), Content-Type/Accept validation, configurable body size limit. Cross-platform session IDs via
Io.randomSecure. - Logging:
logging/setLevelrouting andContext.sendLogMessagefornotifications/message. - Claude channel support: channel events, permission relay, experimental capabilities.
- Conformance-tested: CI runs the full test suite plus a stdio conformance script covering the handshake, tools, resources, prompts, error codes, and parse-error recovery.
See CHANGELOG.md for details.
Install
zig fetch --save https://github.com/PaytonWebber/zig-mcp-sdk/archive/refs/tags/v0.1.0.tar.gz