44 lines
1.4 KiB
Go
44 lines
1.4 KiB
Go
package claude
|
|
|
|
import (
|
|
"log"
|
|
|
|
"git.a-wan.net/alan/pipelines/internal/chattools"
|
|
)
|
|
|
|
// pipelinesToolArgs registers the Pipelines MCP server for one chat: its own
|
|
// endpoint (a per-session token) as an inline --mcp-config, added to the
|
|
// operator's configured MCP servers rather than replacing them, with the tools
|
|
// pre-approved because they only present content in Pipelines. Without a
|
|
// configured registry, or when the endpoint cannot be issued, the chat starts
|
|
// without them.
|
|
func pipelinesToolArgs(sessionID string) []string {
|
|
registry := chattools.Current()
|
|
if registry == nil {
|
|
return nil
|
|
}
|
|
url, err := registry.SessionURL(sessionID)
|
|
if err != nil {
|
|
log.Printf("claude chat %s: Pipelines tools not registered: %v", sessionID, err)
|
|
return nil
|
|
}
|
|
return []string{"--mcp-config", chattools.ClaudeMCPConfig(url), "--allowedTools", chattools.ClaudeAllowedTools()}
|
|
}
|
|
|
|
// disableTools reacts to a failed spawn: when the Pipelines tools were part of
|
|
// it, they are turned off for this chat (logged with the reason) and true asks
|
|
// the caller to retry without them.
|
|
func (s *session) disableTools(err error) bool {
|
|
if chattools.Current() == nil {
|
|
return false
|
|
}
|
|
s.mu.Lock()
|
|
defer s.mu.Unlock()
|
|
if s.toolsOff {
|
|
return false
|
|
}
|
|
s.toolsOff = true
|
|
log.Printf("claude chat %s: start with the Pipelines tools failed (%v); retrying without them", s.id, err)
|
|
return true
|
|
}
|