mcp

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 10 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mcp defines one external MCP server configuration shared by the native Codex and Claude SDKs and the adapter-neutral agent layer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LiteralValues added in v0.2.0

func LiteralValues(values []NamedValue) (map[string]string, error)

LiteralValues converts resolved entries into the flat representation that native providers accept. It rejects unresolved entries.

func ValidateServers

func ValidateServers(servers []Server) error

ValidateServers checks transport-independent structure and fields shared by every supported provider. Provider-specific support is checked by its SDK.

Types

type FileKeyRef added in v0.2.0

type FileKeyRef struct {
	Path string `json:"path" yaml:"path"`
	Key  string `json:"key" yaml:"key"`
}

FileKeyRef reads a case-sensitive key from a file.

type FileRef added in v0.2.0

type FileRef struct {
	Path string `json:"path" yaml:"path"`
}

FileRef names a local absolute path or a path relative to a supplied filesystem.

type ImportSource added in v0.2.0

type ImportSource struct {
	FileRef *FileRef `json:"fileRef,omitempty" yaml:"fileRef,omitempty"`
}

ImportSource imports all entries from one file, using the file's keys as names.

type NamedValue added in v0.2.0

type NamedValue struct {
	Name      string       `json:"name" yaml:"name"`
	Value     *string      `json:"value,omitempty" yaml:"value,omitempty"`
	ValueFrom *ValueSource `json:"valueFrom,omitempty" yaml:"valueFrom,omitempty"`
}

NamedValue assigns an environment variable or an HTTP header. Exactly one of Value and ValueFrom is required. A pointer preserves an explicit empty value.

func Literal added in v0.2.0

func Literal(name, value string) NamedValue

Literal creates a NamedValue with an explicit value.

type Server

type Server struct {
	Name      string
	Transport Transport

	Command string
	Args    []string
	Env     []NamedValue
	EnvFrom []ImportSource
	Cwd     string

	URL               string
	Headers           []NamedValue
	HeadersFrom       []ImportSource
	EnvHeaders        map[string]string
	BearerTokenEnvVar string
}

Server declares one external MCP server. Name is the case-sensitive, configuration-local key. Transport is required, and every entry point rejects a transport it cannot represent instead of inferring or rewriting it.

Stdio uses Command, Args, Env, EnvFrom, and Cwd. HTTP and SSE use URL, Headers, and HeadersFrom. EnvHeaders and BearerTokenEnvVar are HTTP-only Codex extensions.

func CloneServers

func CloneServers(servers []Server) []Server

CloneServers copies the server slice and its nested slices and maps.

func ResolveServers added in v0.2.0

func ResolveServers(servers []Server, files fs.FS) ([]Server, error)

ResolveServers validates the declarations and returns operation-local copies with file references replaced by literal values. It reads each referenced file once per invocation. Re-run it when opening or resuming a Session to use current file contents.

A nil filesystem reads absolute paths on the local host. Accept absolute paths only from callers trusted to read files as the SDK process. Supply a rooted filesystem such as os.Root.FS to restrict references to relative paths within that filesystem. Native MCP configuration carries the resolved values, so protect the native transport and diagnostics as needed.

type Transport

type Transport string

Transport identifies how an external MCP server is reached.

const (
	// TransportStdio starts a local MCP server and communicates over stdio.
	TransportStdio Transport = "stdio"
	// TransportHTTP selects MCP Streamable HTTP.
	TransportHTTP Transport = "http"
	// TransportSSE selects the legacy HTTP+SSE transport supported by Claude.
	TransportSSE Transport = "sse"
)

type ValidationError

type ValidationError struct {
	Reason  string
	Message string
}

ValidationError reports a structural MCP server error without exposing configuration values.

func (*ValidationError) Error

func (e *ValidationError) Error() string

type ValueSource added in v0.2.0

type ValueSource struct {
	FileKeyRef *FileKeyRef `json:"fileKeyRef,omitempty" yaml:"fileKeyRef,omitempty"`
}

ValueSource selects one value from a file.

Jump to

Keyboard shortcuts

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