mcpkit

module
v0.1.27 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: Apache-2.0

README

MCPKit

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

Quick Start

import (
    "context"
    "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 context.Context, req core.ToolRequest) (core.ToolResult, error) {
    var args struct{ Name string `json:"name"` }
    req.Bind(&args)
    return core.TextResult("Hello, " + args.Name + "!"), nil
})

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

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)
testutil github.com/panyam/mcpkit/testutil TestClient wrapper for e2e tests

Conformance

30/30 server scenarios, 14/14 auth scenarios, 21 MCP Apps conformance tests passing against the official MCP conformance suite and internal test suites.

Testing

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)

Documentation

Doc What
CLAUDE.md Quick reference: commands, package structure, gotchas
docs/ARCHITECTURE.md Transport design, type definitions, protocol details
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
CAPABILITIES.md Stack component: all capabilities listed

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.0.22 — SSE hub, graceful shutdown, HTTP error types
  • oneauth v0.0.64 — JWT/OIDC (only via ext/auth sub-module)

Directories

Path Synopsis
cmd
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.
examples
common module
experimental
ext/events module
ext/protogen module
ext
auth module
otel module
protogen module
tasks module
ui module
Package testutil provides test helpers for MCP servers built with mcpkit.
Package testutil provides test helpers for MCP servers built with mcpkit.

Jump to

Keyboard shortcuts

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