Documentation
¶
Index ¶
- func ExtractTextContent(result *mcpsdk.CallToolResult) string
- func WriteMCPConfigToTempFile(servers map[string]schema.MCPServerConfig, toolchainPATH string) (string, error)
- type AuthEnvProvider
- type BridgedTool
- func (t *BridgedTool) Description() string
- func (t *BridgedTool) Execute(ctx context.Context, params map[string]interface{}) (*tools.Result, error)
- func (t *BridgedTool) IsRestricted() bool
- func (t *BridgedTool) Name() string
- func (t *BridgedTool) OriginalName() string
- func (t *BridgedTool) Parameters() []tools.Parameter
- func (t *BridgedTool) RequiresPermission() bool
- func (t *BridgedTool) ServerName() string
- type MCPJSONConfig
- type MCPJSONServer
- type Manager
- func (m *Manager) Get(name string) (*Session, error)
- func (m *Manager) List() []*Session
- func (m *Manager) Start(ctx context.Context, name string, opts ...StartOption) error
- func (m *Manager) Stop(name string) error
- func (m *Manager) StopAll() error
- func (m *Manager) Test(ctx context.Context, name string, opts ...StartOption) *TestResult
- type ParsedConfig
- type Session
- func (s *Session) CallTool(ctx context.Context, toolName string, args map[string]any) (*mcpsdk.CallToolResult, error)
- func (s *Session) Config() *ParsedConfig
- func (s *Session) LastError() error
- func (s *Session) Name() string
- func (s *Session) Ping(ctx context.Context) error
- func (s *Session) SetSuppressStderr(suppress bool)
- func (s *Session) Start(ctx context.Context, opts ...StartOption) error
- func (s *Session) Status() SessionStatus
- func (s *Session) Stop() error
- func (s *Session) Tools() []*mcpsdk.Tool
- type SessionStatus
- type StartOption
- type TestResult
- type ToolchainResolver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractTextContent ¶
func ExtractTextContent(result *mcpsdk.CallToolResult) string
ExtractTextContent extracts text from an MCP CallToolResult.
func WriteMCPConfigToTempFile ¶
func WriteMCPConfigToTempFile(servers map[string]schema.MCPServerConfig, toolchainPATH string) (string, error)
WriteMCPConfigToTempFile generates an MCP config and writes it to a temp file. Returns the file path. Caller must clean up the file when done.
Types ¶
type AuthEnvProvider ¶
type AuthEnvProvider interface {
PrepareShellEnvironment(ctx context.Context, identityName string, currentEnv []string) ([]string, error)
}
AuthEnvProvider is the subset of auth.AuthManager needed for MCP credential injection.
type BridgedTool ¶
type BridgedTool struct {
// contains filtered or unexported fields
}
BridgedTool wraps an external MCP tool to implement the Atmos tools.Tool interface. It namespaces the tool name with the server name to avoid conflicts.
func BridgeTools ¶
func BridgeTools(session *Session) []*BridgedTool
BridgeTools creates BridgedTools for all tools from a session.
func NewBridgedTool ¶
func NewBridgedTool(serverName string, tool *mcpsdk.Tool, session *Session) *BridgedTool
NewBridgedTool creates a new BridgedTool from an MCP tool definition.
func (*BridgedTool) Description ¶
func (t *BridgedTool) Description() string
Description returns the tool's description from the MCP server.
func (*BridgedTool) Execute ¶
func (t *BridgedTool) Execute(ctx context.Context, params map[string]interface{}) (*tools.Result, error)
Execute calls the tool on the external MCP server and returns a tools.Result.
func (*BridgedTool) IsRestricted ¶
func (t *BridgedTool) IsRestricted() bool
IsRestricted returns false.
func (*BridgedTool) Name ¶
func (t *BridgedTool) Name() string
Name returns the namespaced tool name (e.g., "aws-eks__list_clusters"). Uses double underscore as separator and sanitizes to match AI provider requirements (Anthropic requires tool names to match ^[a-zA-Z0-9_-]{1,128}$).
func (*BridgedTool) OriginalName ¶
func (t *BridgedTool) OriginalName() string
OriginalName returns the tool name without the server prefix.
func (*BridgedTool) Parameters ¶
func (t *BridgedTool) Parameters() []tools.Parameter
Parameters extracts parameter definitions from the MCP tool's InputSchema.
func (*BridgedTool) RequiresPermission ¶
func (t *BridgedTool) RequiresPermission() bool
RequiresPermission returns true — external tools require permission by default.
func (*BridgedTool) ServerName ¶
func (t *BridgedTool) ServerName() string
ServerName returns the server name.
type MCPJSONConfig ¶
type MCPJSONConfig struct {
MCPServers map[string]MCPJSONServer `json:"mcpServers"`
}
MCPJSONConfig represents the .mcp.json file format used by Claude Code, Codex CLI, and IDEs.
func GenerateMCPConfig ¶
func GenerateMCPConfig(servers map[string]schema.MCPServerConfig, toolchainPATH string) *MCPJSONConfig
GenerateMCPConfig builds a MCPJSONConfig from the given servers. ToolchainPATH is injected into each server's env if non-empty.
type MCPJSONServer ¶
type MCPJSONServer struct {
Command string `json:"command"`
Args []string `json:"args"`
Env map[string]string `json:"env,omitempty"`
}
MCPJSONServer represents a single MCP server entry in .mcp.json.
func BuildMCPJSONEntry ¶
func BuildMCPJSONEntry(serverCfg *schema.MCPServerConfig, toolchainPATH string) MCPJSONServer
BuildMCPJSONEntry creates a .mcp.json entry for a server. Servers with identity are wrapped with 'atmos auth exec' for credential injection. If toolchainPATH is non-empty, it is prepended to the server's PATH env var.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages the lifecycle of external MCP server processes.
func NewManager ¶
func NewManager(servers map[string]schema.MCPServerConfig) (*Manager, error)
NewManager creates a Manager from atmos configuration.
func RegisterMCPTools ¶
func RegisterMCPTools( registry *tools.Registry, atmosConfig *schema.AtmosConfiguration, authProvider AuthEnvProvider, toolchain ToolchainResolver, ) (*Manager, error)
RegisterMCPTools starts configured MCP servers and registers their tools in the Atmos AI tool registry. Returns the Manager so the caller can stop all servers on exit.
Optional providers:
- authProvider: injects credentials for servers with identity configured.
- toolchain: resolves command binaries and provides toolchain PATH for prerequisites like uvx/npx that may be managed by Atmos toolchain.
Servers that fail to start are reported as errors but do not prevent other servers from registering.
func (*Manager) Test ¶
func (m *Manager) Test(ctx context.Context, name string, opts ...StartOption) *TestResult
Test tests connectivity to an MCP server by starting it, listing tools, and pinging the server.
type ParsedConfig ¶
type ParsedConfig struct {
Name string
Description string
Command string
Args []string
Env map[string]string
AutoStart bool
Timeout time.Duration
Identity string
}
ParsedConfig holds a parsed server config with resolved timeout.
func ParseConfig ¶
func ParseConfig(name string, cfg schema.MCPServerConfig) (*ParsedConfig, error)
ParseConfig validates and converts an MCPServerConfig into a ParsedConfig.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session wraps an MCP client connection to an external server.
func NewSession ¶
func NewSession(config *ParsedConfig) *Session
NewSession creates a new session in stopped state.
func (*Session) CallTool ¶
func (s *Session) CallTool(ctx context.Context, toolName string, args map[string]any) (*mcpsdk.CallToolResult, error)
CallTool calls a tool on the MCP server.
func (*Session) Config ¶
func (s *Session) Config() *ParsedConfig
Config returns the parsed configuration.
func (*Session) SetSuppressStderr ¶
SetSuppressStderr controls whether subprocess stderr is forwarded to os.Stderr. When true, MCP server log output is suppressed (used during AI commands).
func (*Session) Start ¶
func (s *Session) Start(ctx context.Context, opts ...StartOption) error
Start connects to the external MCP server subprocess. StartOptions (e.g., WithAuthManager) can modify the subprocess environment.
func (*Session) Status ¶
func (s *Session) Status() SessionStatus
Status returns the current session status.
type SessionStatus ¶
type SessionStatus string
SessionStatus represents the state of an MCP client session.
const ( // StatusStopped indicates the session is not running. StatusStopped SessionStatus = "stopped" // StatusStarting indicates the session is being initialized. StatusStarting SessionStatus = "starting" // StatusRunning indicates the session is connected and ready. StatusRunning SessionStatus = "running" // StatusError indicates the session failed to start or lost connection. StatusError SessionStatus = "error" )
type StartOption ¶
StartOption is a function that modifies the subprocess environment before starting.
func WithAuthManager ¶
func WithAuthManager(authMgr AuthEnvProvider) StartOption
WithAuthManager returns a StartOption that injects auth credentials when the server has identity configured.
func WithToolchain ¶
func WithToolchain(resolver ToolchainResolver) StartOption
WithToolchain returns a StartOption that resolves the MCP server command binary via the Atmos toolchain and prepends toolchain PATH to the subprocess environment. This ensures prerequisites like uvx/npx are available even if not on the system PATH.
type TestResult ¶
type TestResult struct {
ServerStarted bool
Initialized bool
ToolCount int
PingOK bool
Error error
}
TestResult contains the results of testing an MCP server.
type ToolchainResolver ¶
ToolchainResolver resolves command binary paths and provides toolchain PATH.