mcpkit

module
v0.8.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2026 License: Apache-2.0

README

mcpkit

Production-grade MCP (Model Context Protocol) server and client library for Go.

Go Reference Go Report Card CI Conformance Coverage Release OpenSSF Scorecard Docs License GitHub stars

Docs site · Examples · Conformance report · Capabilities · Changelog · Quick Start

Why mcpkit

  • Batteries included. OAuth and JWT auth, Tasks, Skills, MCP Apps, Events and OpenTelemetry ship beside the core. Each is its own Go module, so the core never pulls in their dependencies.
  • Conformance first. mcpkit passes every tier-scored scenario in the official MCP conformance suite: server 31/31 and client 21/21. CI regenerates the report on every PR.
  • Both wires. One server answers session clients on 2025-11-25 and stateless clients on the 2026-07-28 draft, through one request path.
  • Draft SEPs early. Extensions still in review, such as MCP Events and agent discovery, ship under experimental/ with conformance scenarios of their own. Their APIs can change between releases.

Quick Start

import (
    "time"

    "github.com/panyam/mcpkit/core"
    "github.com/panyam/mcpkit/server"
)

srv := server.NewServer(
    core.ServerInfo{Name: "my-server", Version: "0.1.0"},
    server.WithToolTimeout(30 * time.Second),
)

srv.RegisterTool(core.ToolDef{
    Name: "greet", Description: "Say hello",
    InputSchema: map[string]any{"type": "object", "properties": map[string]any{"name": map[string]any{"type": "string"}}},
}, func(ctx core.ToolContext, req core.ToolRequest) (core.ToolResponse, error) {
    var args struct{ Name string `json:"name"` }
    req.Bind(&args)
    return core.TextResult("Hello, " + args.Name + "!"), nil
})

srv.Run(":8787") // Streamable HTTP — blocks

Run blocks. When you start it in a goroutine, wait for Ready() instead of sleeping. It closes once the listener is bound and the port is accepting:

go srv.Run(":8787")
<-srv.Ready()
// safe to connect; srv.Addr() has the bound address (useful with ":0")

A client mirrors it. Every method that talks to the server takes a context:

ctx := context.Background()

c := client.NewClient("http://localhost:8787/mcp",
    core.ClientInfo{Name: "my-client", Version: "0.1.0"},
)
if err := c.Connect(ctx); err != nil { // bounds the handshake, not the session
    log.Fatal(err)
}
defer c.Close()

out, err := c.ToolCall(ctx, "greet", map[string]any{"name": "world"})

Packages

Package Import What
core github.com/panyam/mcpkit/core Protocol types (Request, ToolDef, Content, Claims) + tool-handler APIs (Sample, Elicit, EmitLog)
server github.com/panyam/mcpkit/server Server, Dispatcher, transports (SSE + Streamable HTTP), middleware
client github.com/panyam/mcpkit/client Client, HTTP/stdio/command transports, reconnection, logging
ext/auth github.com/panyam/mcpkit/ext/auth Separate module: JWT, PRM, OAuth discovery, DCR, CIMD
ext/ui github.com/panyam/mcpkit/ext/ui Separate module: MCP Apps extension (UIExtension, RegisterAppTool)
ext/tasks github.com/panyam/mcpkit/ext/tasks Separate module: SEP-2663 v2 tasks (long-running / async tool calls)
ext/otel github.com/panyam/mcpkit/ext/otel Separate module: SEP-414 OpenTelemetry tracing adapter
ext/skills github.com/panyam/mcpkit/ext/skills Separate module: SEP-2640 skills (data-only, served over resource primitives)
experimental/ext/events github.com/panyam/mcpkit/experimental/ext/events Separate module: MCP Events protocol (webhooks, polling, streaming)
experimental/ext/agents github.com/panyam/mcpkit/experimental/ext/agents Separate module: server-declared agent discovery (agents-wg#22), with a Go client
testutil github.com/panyam/mcpkit/testutil TestClient wrapper for e2e tests

Conformance

mcpkit passes the official MCP conformance suite for the base protocol, and the scenarios for the newer SEPs it implements:

Suite Spec Result
Server tier-check MCP 2025-11-25 31/31 scenarios, 73 checks
Client tier-check MCP 2025-11-25 21/21 scenarios, 581 checks
Tasks v2 SEP-2663 44 pass, 1 skip
MRTR SEP-2322 36 pass, 1 warn
Stateless wire SEP-2575 30/30
Skills SEP-2640 45/45
Events (draft) SEP-3415 130 pass, 11 warn
Agent discovery (draft) agents-wg#22 32/32

The first six run against upstream main. We wrote the Events and agent discovery scenarios ourselves and proposed them upstream, where they are still in review. Authorization, MCP Apps, Tasks v1 and Keycloak interop have test suites of their own, and make testall runs everything.

The counts come from CONFORMANCE.md. It is generated, and CI fails a PR that leaves it stale, so read numbers there before quoting them.

Three artifacts describe mcpkit's conformance posture at increasing granularity:

Testing

make is the supported task runner and the only one CI uses, so make is preinstalled everywhere and needs no setup step.

make test          # Unit tests (200+ across core/server/client)
make testall       # ALL tests + Keycloak + conformance + HTML report
make testconf      # MCP conformance suite
make testconfauth  # Auth conformance
make test-e2e      # E2E tests (auth + apps)
make test-apps-playwright  # ext-apps Playwright suite (needs Node.js)

Justfiles mirroring the same target names also exist and are kept as an experiment. They are not used by CI, and make is authoritative when the two disagree.

Documentation

Doc What
Examples gallery Runnable, batteries-included examples (auth, tasks, apps, tracing, events, skills) — each a guided two-terminal walkthrough. Source under examples/
CHANGELOG.md Release notes (Keep a Changelog / SemVer); fuller write-ups in docs/releases/
CONTRIBUTING.md How to build, test, and contribute
CLAUDE.md Quick reference: commands, package structure, gotchas
docs/ARCHITECTURE.md Transport design, type definitions, protocol details
docs/PROMPTS.md Prompts: arguments, content types, listing
docs/ELICITATION.md Elicitation: schemas, SEP-1034 defaults, enums, URL mode
docs/COMPLETIONS.md Argument completion for prompt arguments and resource URI templates
ext/auth/docs/DESIGN.md Auth architecture, spec compliance (C1-C23, X1-X5)
docs/APPS_DESIGN.md MCP Apps extension design, protocol flows, conformance strategy

Client Features

Subprocess MCP Servers

Spawn and manage subprocess MCP servers with CommandTransport:

c := client.NewClient("", info,
    client.WithCommandTransport("python", []string{"my_server.py"},
        client.WithEnv("DEBUG=1"),
        client.WithShutdownTimeout(10*time.Second),
    ),
    client.WithMaxRetries(3), // auto-restart on crash
)
c.Connect()
defer c.Close()
Custom Request Headers

Inject headers into all outgoing HTTP requests:

c := client.NewClient(url, info,
    client.WithModifyRequest(func(req *http.Request) {
        req.Header.Set("X-Tenant-ID", "acme")
        req.Header.Set("X-Request-ID", uuid.New().String())
    }),
)

Auth Performance

For best performance, configure your authorization server to use ES256 (ECDSA P-256) instead of RS256. ES256 verification is ~10x faster, with smaller keys and tokens. See auth design doc for details.

Dependencies

  • servicekit v0.1.3 — SSE hub, graceful shutdown, HTTP error types
  • oneauth v0.1.31 — JWT/OIDC (only via ext/auth sub-module)

Star History

Star History Chart

If mcpkit is useful to you, starring the repo is the cheapest way to help, since it's the main signal we use to prioritize what to ship next.

Directories

Path Synopsis
agent module
host module
store/gorm module
store/redis module
surfaces module
surfaces/web module
auth module
cmd
external-checker command
Command external-checker drives the mcpkit CLIENT against the third-party "stateless draft" conformance gauntlet at https://mcp-checker-2026-07-28.val.run and renders conformance/EXTERNAL_CHECKER.md.
Command external-checker drives the mcpkit CLIENT against the third-party "stateless draft" conformance gauntlet at https://mcp-checker-2026-07-28.val.run and renders conformance/EXTERNAL_CHECKER.md.
testserver command
testserver is a minimal MCP server for manual testing and conformance validation.
testserver is a minimal MCP server for manual testing and conformance validation.
common module
mcpskills module
testclient module
examples
common module
experimental
ext/agents module
ext/events module
ext/protogen module
ext/rooms module
ext
auth module
otel module
protogen module
skills module
tasks module
ui module
internal
stdioframe
Package stdioframe reads and writes JSON-RPC messages on a byte stream in either of the two framings an MCP stdio peer may use.
Package stdioframe reads and writes JSON-RPC messages on a byte stream in either of the two framings an MCP stdio peer may use.
relay.go — cross-replica notification routing primitives.
relay.go — cross-replica notification routing primitives.
stateless
Package stateless holds the SEP-2575 stateless wire's public types and configuration: the wire Mode a server serves, the server/discover result, the subscriptions/listen frames, and the JSON-RPC code to HTTP status mapping.
Package stateless holds the SEP-2575 stateless wire's public types and configuration: the wire Mode a server serves, the server/discover result, the subscriptions/listen frames, and the JSON-RPC code to HTTP status mapping.
Package stores holds mcpkit's generic storage seams — backend-agnostic interfaces (plus in-memory defaults) that library features call through so a deployment can swap in Redis, SQL, or a custom backend.
Package stores holds mcpkit's generic storage seams — backend-agnostic interfaces (plus in-memory defaults) that library features call through so a deployment can swap in Redis, SQL, or a custom backend.
redis module
Package testutil provides test helpers for MCP servers built with mcpkit.
Package testutil provides test helpers for MCP servers built with mcpkit.
tools
check-auth-markers command
Command check-auth-markers keeps the ext/auth spec-coverage matrix self-verifying (issue 504).
Command check-auth-markers keeps the ext/auth spec-coverage matrix self-verifying (issue 504).
check-snippets command
Command check-snippets guards the Get Started guide's code against drift.
Command check-snippets guards the Get Started guide's code against drift.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL