Files
pipelines/internal/pipeline/tools_test.go
T
alan b01cfd8eb3 Allow named MCP servers in Claude stages
Add validated per-stage MCP allowlists while keeping builtin tools separate. Enable matching Claude Code permission rules only for Claude stages, reject unsupported harnesses, and document the unattended-stage safety model.
2026-11-13 16:06:48 +00:00

36 lines
1.1 KiB
Go

package pipeline
import (
"context"
"git.a-wan.net/alan/pipelines/internal/stage"
"path/filepath"
"strings"
"testing"
)
func TestToolsBlockPersistenceAndAdapter(t *testing.T) {
source := strings.Replace(Template([]string{"one"}, true), "```tools\n```", "```tools\nmcp:ai-memory\nmcp:linear/list_issues\n```", 1)
source = strings.Replace(source, "provider=opencode-go", "provider=anthropic\nharness=claude", 1)
store, err := Open(filepath.Join(t.TempDir(), "tools.db"))
if err != nil {
t.Fatal(err)
}
defer store.Close()
ctx := context.Background()
if _, err := store.Submit(ctx, "web", source); err != nil {
t.Fatal(err)
}
items, _ := store.List(ctx)
d, err := store.Get(ctx, items[0].ID, 1)
if err != nil {
t.Fatal(err)
}
tools, explicit, err := stage.ToolNames(StageDefinition(d.Graph.Stages[0]))
if err != nil || !explicit || len(tools) != 2 || tools[0] != "mcp:ai-memory" || tools[1] != "mcp:linear/list_issues" {
t.Fatal("tool allowlist lost", tools, explicit, err)
}
if _, err := Parse(strings.Replace(source, "mcp:ai-memory\nmcp:linear/list_issues", "mcp:bad name", 1)); err == nil {
t.Fatal("unknown tool accepted")
}
}