Serve the Pipelines chat tools over a loopback MCP endpoint and register it with Claude Code, Codex and OpenCode chats

This commit is contained in:
2026-11-09 16:34:21 +00:00
parent 3ab029cd7b
commit 9791f09230
33 changed files with 2308 additions and 7 deletions
+21 -3
View File
@@ -11,6 +11,7 @@ import (
"errors"
"fmt"
"io"
"log"
"net/http"
"net/url"
"os"
@@ -307,13 +308,30 @@ func OpenChat(ctx context.Context, executable, directory string) (*Connection, e
if err != nil {
return nil, err
}
if overrides != nil && backend == "v2" {
if c.configContent, err = configContent(os.Getenv("OPENCODE_CONFIG_CONTENT"), overrides); err != nil {
if backend != "v2" {
overrides = nil
}
// The Pipelines chat tools are registered on every spawned chat service.
withTools := withPipelinesTools(overrides)
if withTools != nil {
if c.configContent, err = configContent(os.Getenv("OPENCODE_CONFIG_CONTENT"), withTools); err != nil {
return nil, err
}
}
if err := c.startServe(ctx); err != nil {
return nil, err
if withTools == nil || ctx.Err() != nil {
return nil, err
}
log.Printf("OpenCode chat service did not start with the Pipelines tools (%v); starting without them", err)
c.process, c.configContent = nil, ""
if overrides != nil {
if c.configContent, err = configContent(os.Getenv("OPENCODE_CONFIG_CONTENT"), overrides); err != nil {
return nil, err
}
}
if err := c.startServe(ctx); err != nil {
return nil, err
}
}
return c, nil
}