From 18b0acab4d1fe445ce5234f601de4fda855c2e10 Mon Sep 17 00:00:00 2001 From: Danny Kopping Date: Mon, 15 Sep 2025 17:56:44 +0200 Subject: [PATCH] fix: correct MCP tools' input schemas (#19825) The input schemas of `coder_workspace_edit_file` and `coder_workspace_edit_files` were violating the JSON Schemas of both Anthropic and OpenAI. Follow-up: we should add a test to ensure future compatibility with these specs. Signed-off-by: Danny Kopping --- codersdk/toolsdk/toolsdk.go | 72 +++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 39 deletions(-) diff --git a/codersdk/toolsdk/toolsdk.go b/codersdk/toolsdk/toolsdk.go index 42ae809015..5cd437eb36 100644 --- a/codersdk/toolsdk/toolsdk.go +++ b/codersdk/toolsdk/toolsdk.go @@ -1576,21 +1576,19 @@ var WorkspaceEditFile = Tool[WorkspaceEditFileArgs, codersdk.Response]{ "edits": map[string]any{ "type": "array", "description": "An array of edit operations.", - "items": []any{ - map[string]any{ - "type": "object", - "properties": map[string]any{ - "search": map[string]any{ - "type": "string", - "description": "The old string to replace.", - }, - "replace": map[string]any{ - "type": "string", - "description": "The new string that replaces the old string.", - }, + "items": map[string]any{ + "type": "object", + "properties": map[string]any{ + "search": map[string]any{ + "type": "string", + "description": "The old string to replace.", + }, + "replace": map[string]any{ + "type": "string", + "description": "The new string that replaces the old string.", }, - "required": []string{"search", "replace"}, }, + "required": []string{"search", "replace"}, }, }, }, @@ -1641,37 +1639,33 @@ var WorkspaceEditFiles = Tool[WorkspaceEditFilesArgs, codersdk.Response]{ "files": map[string]any{ "type": "array", "description": "An array of files to edit.", - "items": []any{ - map[string]any{ - "type": "object", - "properties": map[string]any{ - "path": map[string]any{ - "type": "string", - "description": "The absolute path of the file to write in the workspace.", - }, - "edits": map[string]any{ - "type": "array", - "description": "An array of edit operations.", - "items": []any{ - map[string]any{ - "type": "object", - "properties": map[string]any{ - "search": map[string]any{ - "type": "string", - "description": "The old string to replace.", - }, - "replace": map[string]any{ - "type": "string", - "description": "The new string that replaces the old string.", - }, - }, - "required": []string{"search", "replace"}, + "items": map[string]any{ + "type": "object", + "properties": map[string]any{ + "path": map[string]any{ + "type": "string", + "description": "The absolute path of the file to write in the workspace.", + }, + "edits": map[string]any{ + "type": "array", + "description": "An array of edit operations.", + "items": map[string]any{ + "type": "object", + "properties": map[string]any{ + "search": map[string]any{ + "type": "string", + "description": "The old string to replace.", + }, + "replace": map[string]any{ + "type": "string", + "description": "The new string that replaces the old string.", }, }, + "required": []string{"search", "replace"}, }, - "required": []string{"path", "edits"}, }, }, + "required": []string{"path", "edits"}, }, }, },