feat: añadir cliente MCP para consumir servidores externos
Implementa el cliente MCP que permite a los agentes conectarse a servidores MCP externos y usar sus tools como si fueran tools nativas del agente. Arquitectura implementada: - shell/mcp/client.go: Cliente MCP con soporte stdio y SSE - shell/mcp/manager.go: Gestor de múltiples clientes MCP - tools/mcptools/mcp.go: Bridge que convierte MCP tools → tools.Tool - shell/mcp/server.go: Movido desde shell/protocols/ para colocación junto al client Cambios en config: - MCPServerCfg extendido con campos Transport, Command, Args, Env, Headers, Prefix, Timeout para soportar stdio y SSE transport Integración en runtime: - agents/runtime.go: Inicializa MCP manager si config.Tools.MCP.Enabled - buildToolRegistry: Registra tools MCP automáticamente con prefijos configurables - Agent: Campo mcpManager que se cierra en shutdown Transportes soportados: - stdio: Lanza subproceso (ej: npx -y @anthropic/mcp-server-brave-search) - SSE: Se conecta a servidor HTTP MCP Las tools MCP son indistinguibles de tools nativas desde el punto de vista del LLM. Auto-discovery via ListTools(), conversión de JSON Schema a tools.Param. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -178,9 +178,16 @@ type MCPToolCfg struct {
|
||||
}
|
||||
|
||||
type MCPServerCfg struct {
|
||||
Name string `yaml:"name"`
|
||||
URL string `yaml:"url"`
|
||||
Tools []string `yaml:"tools"`
|
||||
Name string `yaml:"name"` // nombre logico del servidor
|
||||
Transport string `yaml:"transport"` // "stdio" | "sse" (default: auto-detect)
|
||||
Command string `yaml:"command"` // stdio: comando a ejecutar
|
||||
Args []string `yaml:"args"` // stdio: argumentos del comando
|
||||
Env map[string]string `yaml:"env"` // stdio: variables de entorno extra
|
||||
URL string `yaml:"url"` // sse: URL del servidor
|
||||
Headers map[string]string `yaml:"headers"` // sse: headers HTTP extra (auth, etc.)
|
||||
Tools []string `yaml:"tools"` // filtro: solo exponer estas tools (vacio = todas)
|
||||
Prefix string `yaml:"prefix"` // prefijo para nombres de tools (evitar colisiones)
|
||||
Timeout time.Duration `yaml:"timeout"` // timeout por llamada (default: 30s)
|
||||
}
|
||||
|
||||
type MCPExposeCfg struct {
|
||||
|
||||
Reference in New Issue
Block a user