mcp

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package mcp provides CLI-based MCP tool discovery and registration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AvailableCLIs

func AvailableCLIs() map[string][]string

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

func BackupConfig(path string) (string, error)

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

func RemoveCopilotMCPConfig(path, serverName string) error

RemoveCopilotMCPConfig removes a server entry from a Copilot-format MCP config.

func RemoveMCPConfig

func RemoveMCPConfig(path, serverName string) error

RemoveMCPConfig removes a server entry from a Claude Code-format MCP config.

func RestoreConfig

func RestoreConfig(path, backupPath string) error

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 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 (*BBMCPServer) Serve

func (s *BBMCPServer) Serve(r *bufio.Reader, w io.Writer) error

Serve reads JSON-RPC requests from r and writes responses to w. It blocks until r is exhausted or an error occurs.

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 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 MCPServerEntry

type MCPServerEntry struct {
	Command string            `json:"command"`
	Args    []string          `json:"args"`
	Env     map[string]string `json:"env,omitempty"`
}

MCPServerEntry describes a single MCP server in a config file.

Jump to

Keyboard shortcuts

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