package provider import ( "encoding/json" "path/filepath" "strings" ) // A Mac's MCP tool endpoint (Mac runners spec §8.1, §8.2). Linux mounts // the certified tool proxy at /opt/equipo-tool-proxy and the step's // socket at /tool/equipo.sock inside the namespace. A Mac has neither: // the runner binary itself serves the same stdio MCP protocol in its // tool-proxy mode, dialling the step's tool socket at its real path. const ( // DarwinToolProxyCommand is the runner's subcommand for it: // equipo-runner tool-proxy --socket . DarwinToolProxyCommand = "tool-proxy" // MaxDarwinSocketPath is the longest Unix socket path a Mac takes: // sun_path holds 104 bytes there, the NUL included, and with no // /proc/self/fd a socket is reached by its path alone. MaxDarwinSocketPath = 103 ) // DarwinToolMCP is the CLI's --mcp-config on a Mac: runner (the runner // binary's absolute path) in its tool-proxy mode as the only MCP server, // on socket, the step's tool socket. Both must be clean absolute paths, // and socket must fit a Mac's sun_path. func DarwinToolMCP(runner, socket string) (json.RawMessage, error) { for _, p := range []string{runner, socket} { if !filepath.IsAbs(p) || filepath.Clean(p) != p || strings.ContainsAny(p, "\x00\n\r") { return nil, ErrPolicy } } if len(socket) > MaxDarwinSocketPath { return nil, ErrPolicy } type server struct { Type string `json:"type"` Command string `json:"command"` Args []string `json:"args"` } raw, err := json.Marshal(struct { MCPServers map[string]server `json:"mcpServers"` }{map[string]server{"equipo": {Type: "stdio", Command: runner, Args: []string{DarwinToolProxyCommand, "--socket", socket}}}}) if err != nil { return nil, ErrPolicy } return raw, nil }