|
| 1 | +// Package mcp implements the MCP server logic. |
| 2 | +package mcp |
| 3 | + |
| 4 | +import ( |
| 5 | + "github.com/co-browser/agent-browser/internal/log" |
| 6 | + "go.uber.org/fx" |
| 7 | +) |
| 8 | + |
| 9 | +// RemoteMCPServer defines a remote MCP server to connect to |
| 10 | +type RemoteMCPServer struct { |
| 11 | + URL string `json:"url"` |
| 12 | + Name string `json:"name"` |
| 13 | + Description string `json:"description"` |
| 14 | +} |
| 15 | + |
| 16 | +// MCPServerConfig holds the configuration for the MCP server |
| 17 | +type MCPServerConfig struct { |
| 18 | + RemoteServers []RemoteMCPServer `json:"remote_servers"` |
| 19 | + Port int `json:"port" default:"8087"` |
| 20 | +} |
| 21 | + |
| 22 | +// ConfigParams contains the parameters needed for configuration |
| 23 | +type ConfigParams struct { |
| 24 | + fx.In |
| 25 | + |
| 26 | + Logger log.Logger |
| 27 | +} |
| 28 | + |
| 29 | +// ConfigResult contains the configuration output |
| 30 | +type ConfigResult struct { |
| 31 | + fx.Out |
| 32 | + |
| 33 | + Config MCPServerConfig |
| 34 | +} |
| 35 | + |
| 36 | +// NewMCPConfig creates a new MCP configuration |
| 37 | +func NewMCPConfig(p ConfigParams) (ConfigResult, error) { |
| 38 | + // TODO: Load from environment or config file |
| 39 | + config := MCPServerConfig{ |
| 40 | + Port: 8087, |
| 41 | + RemoteServers: []RemoteMCPServer{ |
| 42 | + { |
| 43 | + URL: "http://0.0.0.0:8001/sse", |
| 44 | + Name: "Local Test Server", |
| 45 | + Description: "Local MCP test server", |
| 46 | + }, |
| 47 | + { |
| 48 | + URL: "https://api-gateway.cobrowser.xyz/mcp/api/sse?api_key=REDACTED_API_KEY", |
| 49 | + Name: "API Gateway", |
| 50 | + Description: "API Gateway MCP server", |
| 51 | + }, |
| 52 | + }, |
| 53 | + } |
| 54 | + |
| 55 | + p.Logger.Info(). |
| 56 | + Int("port", config.Port). |
| 57 | + Int("remote_servers", len(config.RemoteServers)). |
| 58 | + Msg("MCP configuration loaded") |
| 59 | + |
| 60 | + return ConfigResult{Config: config}, nil |
| 61 | +} |
0 commit comments