From c95110501d27eb5f90cc1b49779e1292cf3228c6 Mon Sep 17 00:00:00 2001 From: "GPT-5.2" Date: Sun, 6 Sep 2026 13:42:25 +0800 Subject: [PATCH] feat(protocol): expose dynamic MCP health fields --- mcpcontract/contract_test.go | 11 +++++++++++ mcpcontract/output.go | 14 +++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/mcpcontract/contract_test.go b/mcpcontract/contract_test.go index af1fc69..735905c 100644 --- a/mcpcontract/contract_test.go +++ b/mcpcontract/contract_test.go @@ -130,6 +130,17 @@ func TestContextHasExplicitLocalAndFleetProfiles(t *testing.T) { if _, ok := fleet["properties"].(map[string]any)["nodes"]; !ok { t.Fatal("fleet context is missing nodes") } + dynamicMCP := localProperties["dynamic_mcp"].(map[string]any) + dynamicItem := dynamicMCP["items"].(map[string]any) + dynamicProperties := dynamicItem["properties"].(map[string]any) + for _, name := range []string{"name", "description", "status", "tool_count", "last_error_code"} { + if _, ok := dynamicProperties[name]; !ok { + t.Fatalf("dynamic MCP context item is missing %s", name) + } + } + if dynamicItem["additionalProperties"] != false { + t.Fatalf("dynamic MCP context item must remain strict: %#v", dynamicItem) + } if reflect.DeepEqual(local, fleet) { t.Fatal("local and fleet context profiles unexpectedly match") } diff --git a/mcpcontract/output.go b/mcpcontract/output.go index 394fb40..e49b239 100644 --- a/mcpcontract/output.go +++ b/mcpcontract/output.go @@ -173,7 +173,7 @@ func localContextProperties(includeShared bool) map[string]any { "items": map[string]any{"type": "array", "items": commonSkill}, }, "root", "total", "truncated", "items") commonSkills["description"] = "Lower-priority common Agent Skill capability index; installed AgentDock Skills take precedence on conflicts." - dynamicItem := contextItemSchema(true) + dynamicItem := dynamicMCPItemSchema() indexItem := contextItemSchema(false) warning := map[string]any{ "type": "object", "properties": map[string]any{ @@ -227,3 +227,15 @@ func contextItemSchema(requireDescription bool) map[string]any { "additionalProperties": false, } } + +func dynamicMCPItemSchema() map[string]any { + schema := contextItemSchema(true) + properties := schema["properties"].(map[string]any) + properties["status"] = map[string]any{ + "type": "string", "description": "Runtime health state: idle, ready, or error.", + "enum": []string{"idle", "ready", "error"}, + } + properties["tool_count"] = integerProperty("Discovered tool count from the latest successful refresh.") + properties["last_error_code"] = stringProperty("Safe machine-readable code for the latest refresh error.") + return schema +}