A Model Context Protocol (MCP) client — library and CLI — written in Go with
zero third-party dependencies. It connects to any MCP server over stdio
(launching it as a child process) or HTTP, and is the paired client for
mcpkit.
There is an official MCP Go SDK, and for most production clients it's the right choice. mcpc is a deliberate alternative — a from-scratch, zero-dependency implementation built to make the interesting part legible: the concurrency.
One connection, many in-flight requests, responses arriving out of order, plus
server-initiated notifications. mcpc solves this with a single background read
loop that demultiplexes responses to their waiting callers by request id — so you
can fan out calls from as many goroutines as you like, with per-call timeouts and
cancellation that propagates to the server as notifications/cancelled. It's all
on the standard library, so the read loop and the cancellation plumbing are here
to read, not hidden behind a dependency.
- Full client protocol — MCP
2025-06-18: initialize handshake, tools, resources, prompts, logging and cancellation. - Three transports — a subprocess transport that launches a stdio server, an HTTP transport for gateways, and an in-memory pipe for tests.
- Concurrent by design — a demultiplexing read loop, a
pendingmap keyed by id, and first-class context timeouts. - Reliability —
CallToolRetrywith exponential backoff, aProgressTrackerfor streaming progress, and aPoolof server processes for CPU-bound work. - A real CLI —
ping,tools,describe,call,runand an interactiverepl. - A scripted agent runner — execute a JSON plan of tool calls with output
chaining (
${1}feeds one step's result into the next). - Tested — table-driven unit tests against a mock server over the in-memory
pipe, benchmarks, and an optional live integration test against
mcpkit.
# Build the CLI
make build
# List a server's tools (launches mcpkit as a child process)
mcpc -server mcpkit tools
# Call a tool
mcpc -server mcpkit call calculate expression="2 ^ 10 + sqrt(81)"
# Run a scripted plan
mcpc -server mcpkit run examples/plan.json
# Interactive session
mcpc -server mcpkit replAgainst a running HTTP gateway instead:
mcpc -http http://localhost:8080/rpc pingctx := context.Background()
c, info, err := client.DialCommand(ctx, "mcpkit", nil)
if err != nil {
log.Fatal(err)
}
defer c.Close()
tools, _ := c.ListTools(ctx)
res, _ := c.CallTool(ctx, "calculate", map[string]string{"expression": "6*7"})
fmt.Println(res.Content[0].(mcp.TextContent).Text) // 42cmd/mcpc/ the command-line client
client/ the reusable client: read loop, retry, progress, pool
agent/ scripted plan parser and runner with output chaining
transport/ subprocess, HTTP and in-memory pipe transports
mcp/ MCP protocol types
jsonrpc/ JSON-RPC 2.0 core
internal/ config, logging, metrics, version
docs/ architecture, protocol, cli, library, transports, agent
examples/ a library example and sample plans
mcpc is developed alongside the mcpkit
server. Build mcpkit and point the live integration test at it:
go build -o /tmp/mcpkit github.com/adam-eques/mcpkit/cmd/mcpkit
MCPKIT_BIN=/tmp/mcpkit go test ./client -run TestLiveServer- Architecture
- Protocol support
- Command-line usage
- Using mcpc as a library
- Transports
- Scripted plans
- Configuration
MIT — see LICENSE.