// bridge is a stdio↔HTTP adapter that lets Claude Code connect to the // supervisor MCP server via the stdio transport. // // Claude Code spawns this binary as a subprocess and communicates over // stdin/stdout. Each newline-delimited JSON-RPC message from stdin is // forwarded to the supervisor HTTP server and the response is written back. // // Usage: // // SUPERVISOR_URL=http://localhost:3200/mcp bridge package main import ( "bufio" "bytes" "fmt" "io" "net/http" "os" ) func main() { url := os.Getenv("SUPERVISOR_URL") if url == "" { url = "http://localhost:3200/mcp" } client := &http.Client{} scanner := bufio.NewScanner(os.Stdin) scanner.Buffer(make([]byte, 1024*1024), 1024*1024) for scanner.Scan() { line := scanner.Bytes() if len(bytes.TrimSpace(line)) == 0 { continue } req, err := http.NewRequest(http.MethodPost, url, bytes.NewReader(line)) if err != nil { fmt.Fprintf(os.Stderr, "bridge: build request: %v\n", err) continue } req.Header.Set("Content-Type", "application/json") resp, err := client.Do(req) if err != nil { fmt.Fprintf(os.Stderr, "bridge: request failed: %v\n", err) continue } io.Copy(os.Stdout, resp.Body) resp.Body.Close() os.Stdout.Write([]byte("\n")) } if err := scanner.Err(); err != nil { fmt.Fprintf(os.Stderr, "bridge: scanner: %v\n", err) os.Exit(1) } }