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 ¶
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
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 ¶
CloneServers copies the server slice and its nested slices and maps.
func ResolveServers ¶ added in v0.2.0
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 ¶
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.