Documentation
¶
Overview ¶
Package mcp provides CLI-based MCP tool discovery and registration.
Index ¶
- func AvailableCLIs() map[string][]string
- func BackupConfig(path string) (string, error)
- func KnownCLINames() []string
- func RemoveCopilotMCPConfig(path, serverName string) error
- func RemoveMCPConfig(path, serverName string) error
- func RestoreConfig(path, backupPath string) error
- func WriteCopilotMCPConfig(path, serverName string, entry MCPServerEntry) error
- func WriteGenericMCPConfig(path, serverName string, entry MCPServerEntry) error
- func WriteMCPConfig(path, serverName string, entry MCPServerEntry) error
- type BBMCPServer
- type CLISpec
- type ClaudeCodeMCPConfig
- type CopilotMCPConfig
- type DaemonClient
- type Discoverer
- type DiscoveryResult
- type GenericMCPConfig
- type MCPServerEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AvailableCLIs ¶
AvailableCLIs returns the subset of known CLIs that are present in PATH. It performs an exec.LookPath check for each CLI and returns a map of CLI name → tool names for those that are installed.
func BackupConfig ¶
BackupConfig copies the file at path to path.ratchet-bak and returns the backup path. Returns ("", nil) if the file does not exist.
func KnownCLINames ¶
func KnownCLINames() []string
KnownCLINames returns the names of all CLIs that can be discovered.
func RemoveCopilotMCPConfig ¶
RemoveCopilotMCPConfig removes a server entry from a Copilot-format MCP config.
func RemoveMCPConfig ¶
RemoveMCPConfig removes a server entry from a Claude Code-format MCP config.
func RestoreConfig ¶
RestoreConfig restores the backup to the original path and removes the backup.
func WriteCopilotMCPConfig ¶
func WriteCopilotMCPConfig(path, serverName string, entry MCPServerEntry) error
WriteCopilotMCPConfig merges a server entry into a Copilot-format MCP config file.
func WriteGenericMCPConfig ¶ added in v0.12.0
func WriteGenericMCPConfig(path, serverName string, entry MCPServerEntry) error
WriteGenericMCPConfig merges a server entry into a generic MCP config file.
func WriteMCPConfig ¶
func WriteMCPConfig(path, serverName string, entry MCPServerEntry) error
WriteMCPConfig merges a server entry into a Claude Code-format MCP config file. Creates the file and parent directories if they don't exist.
Types ¶
type BBMCPServer ¶
type BBMCPServer struct {
// contains filtered or unexported fields
}
BBMCPServer exposes Blackboard operations as MCP tools over stdio.
func NewBBMCPServer ¶
func NewBBMCPServer(bb *mesh.Blackboard) *BBMCPServer
NewBBMCPServer creates an MCP server backed by the given Blackboard.
func NewDaemonMCPServer ¶ added in v0.12.0
func NewDaemonMCPServer(daemon DaemonClient) *BBMCPServer
NewDaemonMCPServer creates an MCP server backed by a running ratchet daemon.
type CLISpec ¶
type CLISpec struct {
Name string
Tools []cliTool
}
CLISpec describes a CLI tool and the MCP tools derived from it.
type ClaudeCodeMCPConfig ¶
type ClaudeCodeMCPConfig struct {
MCPServers map[string]MCPServerEntry `json:"mcpServers"`
}
ClaudeCodeMCPConfig is the structure of .claude/mcp.json.
type CopilotMCPConfig ¶
type CopilotMCPConfig struct {
Servers map[string]MCPServerEntry `json:"servers"`
}
CopilotMCPConfig is the structure of ~/.copilot/mcp-config.json.
type DaemonClient ¶ added in v0.12.0
type DaemonClient interface {
ListSessions() ([]*pb.Session, error)
KillSession(id string) error
ListProjects() ([]*pb.ProjectStatus, error)
ReadBlackboard(section, key string) (*pb.BlackboardReadResp, error)
WriteBlackboard(section, key, value string) (*pb.BlackboardEntry, error)
ListBlackboard(section string) (*pb.BlackboardListResp, error)
ListTeams() ([]*pb.TeamStatus, error)
GetTeamStatus(teamID string) (*pb.TeamStatus, error)
DirectMessage(teamID, toAgent, content string) error
}
DaemonClient is the daemon surface exposed as MCP tools.
type Discoverer ¶
type Discoverer struct {
// contains filtered or unexported fields
}
Discoverer wraps CLI discovery and caches results.
func NewDiscoverer ¶
func NewDiscoverer(registry *ratchetplugin.ToolRegistry) *Discoverer
NewDiscoverer creates a Discoverer backed by the given ToolRegistry.
func (*Discoverer) Disable ¶
func (d *Discoverer) Disable(cliName string)
Disable removes tools for the given CLI from the registry.
func (*Discoverer) Discover ¶
func (d *Discoverer) Discover() *DiscoveryResult
Discover detects available CLIs and registers their tools. Results are cached; subsequent calls return the cached result immediately.
func (*Discoverer) Enable ¶
func (d *Discoverer) Enable(cliName string) error
Enable re-runs discovery (cache cleared first) and returns the result.
func (*Discoverer) InvalidateCache ¶
func (d *Discoverer) InvalidateCache()
InvalidateCache forces the next Discover() call to re-detect CLIs.
type DiscoveryResult ¶
type DiscoveryResult struct {
// Registered maps CLI name to the tool names registered.
Registered map[string][]string
}
DiscoveryResult is the result of a CLI discovery run.
type GenericMCPConfig ¶ added in v0.12.0
type GenericMCPConfig struct {
Servers map[string]MCPServerEntry `json:"servers"`
}
GenericMCPConfig is a portable MCP config shape for clients that accept a servers map.