Documentation
¶
Index ¶
- func ExpandEnv(env map[string]string) []string
- func ExpandHeaders(headers map[string]string) map[string]string
- func LoadAllMCPServers(cwd string) map[string]ServerConfig
- type Client
- type MCPTool
- type Manager
- func (m *Manager) Close()
- func (m *Manager) Instructions() []string
- func (m *Manager) MarkDirty()
- func (m *Manager) RefreshIfDirty(ctx context.Context) ([]agentcore.Tool, bool)
- func (m *Manager) StartAll(ctx context.Context, servers map[string]ServerConfig) []error
- func (m *Manager) Status(ctx context.Context) []ServerStatus
- func (m *Manager) Tools(ctx context.Context) []agentcore.Tool
- type ServerConfig
- type ServerStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExpandEnv ¶
ExpandEnv converts a map of env vars to KEY=VALUE format, expanding ${VAR} references from the OS environment. The result is appended to the current process environment.
func ExpandHeaders ¶
ExpandHeaders expands ${VAR} in header values.
func LoadAllMCPServers ¶
func LoadAllMCPServers(cwd string) map[string]ServerConfig
LoadAllMCPServers merges MCP server configs from global (~/.codebot/settings.json) and project (<cwd>/.codebot/settings.json). Project-level overrides global.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps a single MCP server connection.
func Connect ¶
Connect establishes an MCP connection using the transport specified in cfg. onChange is called when the server sends a tools/list_changed notification.
func (*Client) CallTool ¶
func (c *Client) CallTool(ctx context.Context, name string, args map[string]any) (*protocol.CallToolResult, error)
CallTool invokes a tool on the server.
func (*Client) Instructions ¶
Instructions returns server instructions from the initialize result, if any.
type MCPTool ¶
type MCPTool struct {
// contains filtered or unexported fields
}
MCPTool adapts an MCP server tool to the agentcore.Tool interface.
func NewMCPTool ¶
NewMCPTool creates an adapter from an MCP tool definition.
func (*MCPTool) ApprovalMetadata ¶ added in v0.0.4
func (t *MCPTool) ApprovalMetadata() approval.ToolMetadata
func (*MCPTool) Description ¶
func (*MCPTool) Execute ¶
func (t *MCPTool) Execute(ctx context.Context, args json.RawMessage) (json.RawMessage, error)
Execute calls the MCP tool and converts the result to JSON.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages the lifecycle of multiple MCP server connections.
func (*Manager) Instructions ¶
Instructions collects server instructions from all connected servers.
func (*Manager) MarkDirty ¶ added in v0.0.3
func (m *Manager) MarkDirty()
MarkDirty forces the dirty flag so that the next RefreshIfDirty call triggers a tool reload. Used after initial async connection completes.
func (*Manager) RefreshIfDirty ¶
RefreshIfDirty re-fetches tools from all servers if any sent a list_changed notification since the last call. Returns the new tool list and true, or nil and false if nothing changed. Safe to call from the main loop.
func (*Manager) StartAll ¶
StartAll connects to all configured MCP servers in parallel. Partial failures are collected; successful servers remain active.
type ServerConfig ¶
type ServerConfig struct {
Type string `json:"type,omitempty"` // "stdio" (default) or "http"
Command string `json:"command,omitempty"`
Args []string `json:"args,omitempty"`
Env map[string]string `json:"env,omitempty"`
URL string `json:"url,omitempty"`
Headers map[string]string `json:"headers,omitempty"`
}
ServerConfig describes a single MCP server connection.
Stdio example (default):
{"command": "npx", "args": ["-y", "@upstash/context7-mcp"], "env": {"KEY": "${VAR}"}}
HTTP example:
{"type": "http", "url": "https://mcp.example.com/mcp", "headers": {"Authorization": "Bearer ${TOKEN}"}}