oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package provider
2
3import (
4 "encoding/json"
5 "path/filepath"
6 "strings"
7)
8
9// A Mac's MCP tool endpoint (Mac runners spec §8.1, §8.2). Linux mounts
10// the certified tool proxy at /opt/equipo-tool-proxy and the step's
11// socket at /tool/equipo.sock inside the namespace. A Mac has neither:
12// the runner binary itself serves the same stdio MCP protocol in its
13// tool-proxy mode, dialling the step's tool socket at its real path.
14const (
15 // DarwinToolProxyCommand is the runner's subcommand for it:
16 // equipo-runner tool-proxy --socket <path>.
17 DarwinToolProxyCommand = "tool-proxy"
18 // MaxDarwinSocketPath is the longest Unix socket path a Mac takes:
19 // sun_path holds 104 bytes there, the NUL included, and with no
20 // /proc/self/fd a socket is reached by its path alone.
21 MaxDarwinSocketPath = 103
22)
23
24// DarwinToolMCP is the CLI's --mcp-config on a Mac: runner (the runner
25// binary's absolute path) in its tool-proxy mode as the only MCP server,
26// on socket, the step's tool socket. Both must be clean absolute paths,
27// and socket must fit a Mac's sun_path.
28func DarwinToolMCP(runner, socket string) (json.RawMessage, error) {
29 for _, p := range []string{runner, socket} {
30 if !filepath.IsAbs(p) || filepath.Clean(p) != p || strings.ContainsAny(p, "\x00\n\r") {
31 return nil, ErrPolicy
32 }
33 }
34 if len(socket) > MaxDarwinSocketPath {
35 return nil, ErrPolicy
36 }
37 type server struct {
38 Type string `json:"type"`
39 Command string `json:"command"`
40 Args []string `json:"args"`
41 }
42 raw, err := json.Marshal(struct {
43 MCPServers map[string]server `json:"mcpServers"`
44 }{map[string]server{"equipo": {Type: "stdio", Command: runner, Args: []string{DarwinToolProxyCommand, "--socket", socket}}}})
45 if err != nil {
46 return nil, ErrPolicy
47 }
48 return raw, nil
49}
50