Documentation
¶
Overview ¶
Package mcpbridge implements a stdio MCP server that exposes agentserver agent discovery and task delegation as MCP tools for Claude Code.
Protocol: JSON-RPC 2.0 over stdin/stdout (newline-delimited). Methods: initialize, notifications/initialized, tools/list, tools/call.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunMCPServer ¶
func RunMCPServer()
RunMCPServer is the entry point for the `agentserver mcp-server` subcommand. Reads config from env vars and runs the MCP stdio server.
Types ¶
type AgentListing ¶
type AgentListing struct {
// contains filtered or unexported fields
}
AgentListing periodically fetches the available agent list and formats it for injection into the delegate_task tool description.
func NewAgentListing ¶
func NewAgentListing(serverURL, token, workspaceID, selfID string) *AgentListing
NewAgentListing creates a new listing that will poll for agents.
func (*AgentListing) FormatForToolDescription ¶
func (l *AgentListing) FormatForToolDescription() string
FormatForToolDescription generates the agent list appended to delegate_task description.
func (*AgentListing) Refresh ¶
func (l *AgentListing) Refresh() error
Refresh fetches the latest agent list from the server.
func (*AgentListing) Start ¶
func (l *AgentListing) Start(ctx context.Context)
Start begins periodic refresh. Call once on startup.
type Bridge ¶
type Bridge struct {
// contains filtered or unexported fields
}
Bridge is the MCP bridge server connecting Claude Code to agentserver.
func (*Bridge) HandleTool ¶
func (b *Bridge) HandleTool(name string, args json.RawMessage) (*ToolResult, error)
HandleTool dispatches a tool call to the appropriate handler.
func (*Bridge) StartListing ¶
StartListing begins periodic agent listing refresh.
type BridgeConfig ¶
type BridgeConfig struct {
ServerURL string
Token string // tunnel_token or proxy_token
WorkspaceID string
SandboxID string // self (exclude from discovery)
}
BridgeConfig holds the agentserver connection settings.
type DiscoveredAgent ¶
type DiscoveredAgent struct {
AgentID string `json:"agent_id"`
DisplayName string `json:"display_name"`
Description string `json:"description"`
AgentType string `json:"agent_type"`
Status string `json:"status"`
Card struct {
Tags []string `json:"tags"`
Skills []struct {
Name string `json:"name"`
Description string `json:"description"`
} `json:"skills"`
Languages []struct {
Name string `json:"name"`
Version string `json:"version"`
} `json:"languages"`
Tools []struct {
Name string `json:"name"`
Version string `json:"version"`
} `json:"tools"`
Hardware map[string]any `json:"hardware"`
} `json:"card"`
}
DiscoveredAgent is an agent from the discovery API.
type Request ¶
type Request struct {
JSONRPC string `json:"jsonrpc"`
ID json.RawMessage `json:"id,omitempty"` // absent for notifications; "null" is valid request id
Method string `json:"method"`
Params json.RawMessage `json:"params,omitempty"`
}
Request is a JSON-RPC 2.0 request or notification.
func (*Request) IsNotification ¶
IsNotification returns true if this is a notification (no id field).
type Response ¶
type Response struct {
JSONRPC string `json:"jsonrpc"`
ID json.RawMessage `json:"id"`
Result any `json:"result,omitempty"`
Error *Error `json:"error,omitempty"`
}
Response is a JSON-RPC 2.0 response.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server handles JSON-RPC 2.0 messages on stdin/stdout.
func NewServer ¶
func NewServer(tools []ToolDef, handler func(string, json.RawMessage) (*ToolResult, error)) *Server
NewServer creates an MCP stdio server.
type ToolDef ¶
type ToolDef struct {
Name string
InputSchema map[string]any
Annotations map[string]any
// contains filtered or unexported fields
}
ToolDef defines an MCP tool.
func (*ToolDef) Description ¶
Description returns the tool description, using dynamic if available.
type ToolResult ¶
type ToolResult struct {
Content []map[string]string `json:"content"`
IsError bool `json:"isError,omitempty"`
}
ToolResult is the MCP tool call result.