Help us shape the future of Go! Take the 2026 Go Developer Survey

officialsdk

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

README

MCPKit Official SDK Adapter

officialsdk adapts the official github.com/modelcontextprotocol/go-sdk client session into the transport-neutral mcpkit.Client interface.

It supports stdio MCP servers through the SDK's mcp.CommandTransport and Streamable HTTP MCP servers through mcp.StreamableClientTransport. It intentionally does not expose resources, prompts, or server implementation helpers.

Use

client, err := officialsdk.ConnectStdio(ctx, officialsdk.StdioConfig{
    Command: "node",
    Args: []string{"./server.js"},
    Name: "goagents-host",
    Version: "v0.1.0",
})
if err != nil {
    return err
}
defer client.Close()

_, err = mcpkit.RegisterTools(ctx, registry, client, mcpkit.RegisterOptions{
    MaxLLMChars:            2000,
    TrustServerAnnotations: true, // Only after host-side server verification.
})

For Streamable HTTP:

client, err := officialsdk.ConnectStreamableHTTP(ctx, officialsdk.StreamableHTTPConfig{
    Endpoint: "https://example.com/mcp",
    Name: "goagents-host",
    Version: "v0.1.0",
})
if err != nil {
    return err
}
defer client.Close()

Verify

go test ./...
go run ./examples/stdio-smoke
go run ./examples/http-smoke
go run ./examples/goagent-mcp-http

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client adapts an official MCP SDK client session to the transport-neutral mcpkit.Client interface.

func ConnectStdio

func ConnectStdio(ctx context.Context, cfg StdioConfig) (*Client, error)

func ConnectStreamableHTTP

func ConnectStreamableHTTP(ctx context.Context, cfg StreamableHTTPConfig) (*Client, error)

func (*Client) CallTool

func (c *Client) CallTool(ctx context.Context, name string, arguments json.RawMessage) (*mcpkit.ToolCallResult, error)

func (*Client) Close

func (c *Client) Close() error

func (*Client) ListTools

func (c *Client) ListTools(ctx context.Context) ([]mcpkit.ToolDescriptor, error)

type StdioConfig

type StdioConfig struct {
	Command           string
	Args              []string
	Env               []string
	Dir               string
	Name              string
	Version           string
	TerminateDuration time.Duration
}

StdioConfig describes a local MCP server process managed through the official SDK CommandTransport. Command, Args, Env, and Dir are host-owned config.

type StreamableHTTPConfig

type StreamableHTTPConfig struct {
	Endpoint            string
	HTTPClient          *http.Client
	MaxRetries          int
	EnableStandaloneSSE bool
	OAuthHandler        auth.OAuthHandler
	Name                string
	Version             string
}

StreamableHTTPConfig describes a remote MCP endpoint managed through the official SDK StreamableClientTransport. The first adapter slice defaults to request/response mode by disabling standalone SSE unless explicitly enabled.

Directories

Path Synopsis
examples
http-smoke command
stdio-smoke command

Jump to

Keyboard shortcuts

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