mcp

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TransportStdio launches the MCP server as a subprocess and communicates
	// over stdin/stdout. It is the default when Type is empty.
	TransportStdio = "stdio"
	// TransportHTTP connects to a remote MCP server over streamable HTTP.
	TransportHTTP = "http"
	// TransportSSE connects to a remote MCP server over server-sent events.
	// Deprecated by the MCP spec; prefer TransportHTTP.
	TransportSSE = "sse"
)

Transport types for MCP server connections. The set mirrors the transports an ACP client may specify in session lifecycle requests.

Variables

This section is empty.

Functions

This section is empty.

Types

type CredentialResolver added in v0.2.0

type CredentialResolver interface {
	ResolveMCP(context.Context, string) (Credentials, error)
}

CredentialResolver resolves host-owned references immediately before an MCP connection. Implementations should return short-lived credentials.

type Credentials added in v0.2.0

type Credentials struct {
	Env     []EnvVariable
	Headers []HTTPHeader
}

Credentials are ephemeral values returned for a durable CredentialRef.

type EnvVariable

type EnvVariable struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

EnvVariable is a single environment variable for a stdio MCP server.

type HTTPHeader

type HTTPHeader struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

HTTPHeader is a single HTTP header sent with requests to an HTTP-based MCP server.

type MCPConfig

type MCPConfig struct {
	// Name is a human-readable identifier for the server. It is used as the
	// tool namespace so that tools from this server are grouped together and
	// disambiguated from tools provided by other servers or the harness itself.
	Name string `json:"name"`

	// Type selects the MCP transport: TransportHTTP ("http") or
	// TransportSSE ("sse"). When empty or TransportStdio ("stdio"), the
	// server is launched as a subprocess over stdio.
	Type string `json:"type,omitempty"`

	// Command is the path to the MCP server executable (stdio transport).
	Command string `json:"command,omitempty"`

	// Args are command-line arguments passed to the server (stdio transport).
	Args []string `json:"args,omitempty"`

	// Env are explicit environment variables set when launching the server.
	// Host process variables are inherited only through host-only policy.
	Env []EnvVariable `json:"env,omitempty"`

	// URL is the endpoint URL (http and sse transports).
	URL string `json:"url,omitempty"`

	// Headers are HTTP headers included in requests to the server (http and
	// sse transports). Authorization and other credentials are carried here.
	Headers []HTTPHeader `json:"headers,omitempty"`

	// CredentialRef is a durable opaque reference resolved by the host. Inline
	// Env and Headers remain connection-scoped and are never persisted.
	CredentialRef string `json:"credentialRef,omitempty"`

	// HostEnv is a host-only allowlist of environment variable names inherited
	// by a stdio subprocess. It is never accepted from ACP JSON.
	HostEnv []string `json:"-"`

	// InheritHostEnv is a host-only trusted escape hatch. Client-supplied JSON
	// cannot enable full process environment inheritance.
	InheritHostEnv bool `json:"-"`
}

MCPConfig describes a single MCP server connection for the harness or ACP session lifecycle. It matches the ACP mcpServers wire shape: a stdio server sets Command/Args/Env with no Type, while HTTP and SSE servers set Type plus URL/Headers. Connection and tool discovery are handled internally by the harness — library consumers only supply configs.

func DurableConfigs added in v0.2.0

func DurableConfigs(configs []MCPConfig) []MCPConfig

DurableConfigs copies MCP topology while removing inline credentials.

func (MCPConfig) Durable added in v0.2.0

func (c MCPConfig) Durable() MCPConfig

Durable returns the non-secret topology safe for a wire session store.

func (MCPConfig) Resolve added in v0.2.0

func (c MCPConfig) Resolve(ctx context.Context, resolver CredentialResolver) (MCPConfig, error)

Resolve applies a host credential reference to an ephemeral config copy.

func (MCPConfig) Validate added in v0.2.0

func (c MCPConfig) Validate() error

Validate rejects incomplete transports and unsafe environment/header names.

Jump to

Keyboard shortcuts

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