Skip to content

Commit 89970f2

Browse files
committed
Fix ingest_traces array schema missing items property
VS Code 1.112+ validates that all MCP tool array-type parameters include an "items" definition (microsoft/vscode#248810). The ingest_traces tool's "traces" parameter was missing this, causing startup failures.
1 parent d6a5f89 commit 89970f2

2 files changed

Lines changed: 32 additions & 1 deletion

File tree

src/mcp/mcp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,8 @@ static const tool_def_t TOOLS[] = {
304304
"\"sections\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}}}"},
305305

306306
{"ingest_traces", "Ingest runtime traces to enhance the knowledge graph",
307-
"{\"type\":\"object\",\"properties\":{\"traces\":{\"type\":\"array\"},\"project\":{\"type\":"
307+
"{\"type\":\"object\",\"properties\":{\"traces\":{\"type\":\"array\",\"items\":{\"type\":"
308+
"\"object\"}},\"project\":{\"type\":"
308309
"\"string\"}},\"required\":[\"traces\"]}"},
309310
};
310311

tests/test_mcp.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,35 @@ TEST(mcp_tools_list) {
129129
PASS();
130130
}
131131

132+
TEST(mcp_tools_array_schemas_have_items) {
133+
/* VS Code 1.112+ rejects array schemas without "items" (see
134+
* https://github.com/microsoft/vscode/issues/248810).
135+
* Walk every tool's inputSchema and verify that every "type":"array"
136+
* property also contains "items". */
137+
char *json = cbm_mcp_tools_list();
138+
ASSERT_NOT_NULL(json);
139+
140+
/* Scan for all occurrences of "type":"array" — each must be followed
141+
* by "items" before the next closing brace of that property. */
142+
const char *p = json;
143+
while ((p = strstr(p, "\"type\":\"array\"")) != NULL) {
144+
/* Find the enclosing '}' for this property object */
145+
const char *end = strchr(p, '}');
146+
ASSERT_NOT_NULL(end);
147+
/* "items" must appear between p and end */
148+
size_t span = (size_t)(end - p);
149+
char *segment = malloc(span + 1);
150+
memcpy(segment, p, span);
151+
segment[span] = '\0';
152+
ASSERT_NOT_NULL(strstr(segment, "\"items\"")); /* array missing items */
153+
free(segment);
154+
p = end;
155+
}
156+
157+
free(json);
158+
PASS();
159+
}
160+
132161
TEST(mcp_text_result) {
133162
char *json = cbm_mcp_text_result("{\"total\":5}", false);
134163
ASSERT_NOT_NULL(json);
@@ -1198,6 +1227,7 @@ SUITE(mcp) {
11981227
/* MCP protocol helpers */
11991228
RUN_TEST(mcp_initialize_response);
12001229
RUN_TEST(mcp_tools_list);
1230+
RUN_TEST(mcp_tools_array_schemas_have_items);
12011231
RUN_TEST(mcp_text_result);
12021232
RUN_TEST(mcp_text_result_error);
12031233

0 commit comments

Comments
 (0)