| 1 | package plugin |
| 2 | |
| 3 | import ( |
| 4 | "encoding/json" |
| 5 | "strings" |
| 6 | "testing" |
| 7 | |
| 8 | "reasonix/internal/tool" |
| 9 | ) |
| 10 | |
| 11 | func TestServerStatusPreservesCanonicalDiagnosticBindings(t *testing.T) { |
| 12 | c := &Client{name: "figma", spec: Spec{Package: "design", StripRawPrefix: "figma_"}} |
| 13 | adapter := &remoteTool{client: c, name: ModelToolName("figma", "search"), rawName: "figma_search", visibleName: "search"} |
| 14 | c.toolCatalog = toolCatalogSnapshot{listed: true, adapters: []tool.Tool{adapter}} |
| 15 | h := NewHost() |
| 16 | h.clients = []*Client{c} |
| 17 | statuses := h.Servers() |
| 18 | if len(statuses) != 1 || len(statuses[0].ToolBindings) != 1 { |
| 19 | t.Fatalf("bindings missing: %+v", statuses) |
| 20 | } |
| 21 | binding := statuses[0].ToolBindings[0] |
| 22 | if binding.Package != "design" || binding.RawName != "figma_search" || binding.VisibleName != "search" || binding.CallableName != "mcp__figma__search" { |
| 23 | t.Fatalf("lost runtime identity: %+v", binding) |
| 24 | } |
| 25 | statuses[0].ToolBindings[0].RawName = "changed" |
| 26 | if h.Servers()[0].ToolBindings[0].RawName != "figma_search" { |
| 27 | t.Fatal("snapshot aliases host state") |
| 28 | } |
| 29 | raw, err := json.Marshal(statuses) |
| 30 | if err != nil { |
| 31 | t.Fatal(err) |
| 32 | } |
| 33 | if strings.Contains(string(raw), "ToolBindings") { |
| 34 | t.Fatal("diagnostic metadata leaked into serialized status") |
| 35 | } |
| 36 | } |
| 37 |