Skip to content

Commit 18b0aca

Browse files
authored
fix: correct MCP tools' input schemas (coder#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 <danny@coder.com>
1 parent 8ff4ba0 commit 18b0aca

File tree

1 file changed

+33
-39
lines changed

1 file changed

+33
-39
lines changed

codersdk/toolsdk/toolsdk.go

Lines changed: 33 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,21 +1576,19 @@ var WorkspaceEditFile = Tool[WorkspaceEditFileArgs, codersdk.Response]{
15761576
"edits": map[string]any{
15771577
"type": "array",
15781578
"description": "An array of edit operations.",
1579-
"items": []any{
1580-
map[string]any{
1581-
"type": "object",
1582-
"properties": map[string]any{
1583-
"search": map[string]any{
1584-
"type": "string",
1585-
"description": "The old string to replace.",
1586-
},
1587-
"replace": map[string]any{
1588-
"type": "string",
1589-
"description": "The new string that replaces the old string.",
1590-
},
1579+
"items": map[string]any{
1580+
"type": "object",
1581+
"properties": map[string]any{
1582+
"search": map[string]any{
1583+
"type": "string",
1584+
"description": "The old string to replace.",
1585+
},
1586+
"replace": map[string]any{
1587+
"type": "string",
1588+
"description": "The new string that replaces the old string.",
15911589
},
1592-
"required": []string{"search", "replace"},
15931590
},
1591+
"required": []string{"search", "replace"},
15941592
},
15951593
},
15961594
},
@@ -1641,37 +1639,33 @@ var WorkspaceEditFiles = Tool[WorkspaceEditFilesArgs, codersdk.Response]{
16411639
"files": map[string]any{
16421640
"type": "array",
16431641
"description": "An array of files to edit.",
1644-
"items": []any{
1645-
map[string]any{
1646-
"type": "object",
1647-
"properties": map[string]any{
1648-
"path": map[string]any{
1649-
"type": "string",
1650-
"description": "The absolute path of the file to write in the workspace.",
1651-
},
1652-
"edits": map[string]any{
1653-
"type": "array",
1654-
"description": "An array of edit operations.",
1655-
"items": []any{
1656-
map[string]any{
1657-
"type": "object",
1658-
"properties": map[string]any{
1659-
"search": map[string]any{
1660-
"type": "string",
1661-
"description": "The old string to replace.",
1662-
},
1663-
"replace": map[string]any{
1664-
"type": "string",
1665-
"description": "The new string that replaces the old string.",
1666-
},
1667-
},
1668-
"required": []string{"search", "replace"},
1642+
"items": map[string]any{
1643+
"type": "object",
1644+
"properties": map[string]any{
1645+
"path": map[string]any{
1646+
"type": "string",
1647+
"description": "The absolute path of the file to write in the workspace.",
1648+
},
1649+
"edits": map[string]any{
1650+
"type": "array",
1651+
"description": "An array of edit operations.",
1652+
"items": map[string]any{
1653+
"type": "object",
1654+
"properties": map[string]any{
1655+
"search": map[string]any{
1656+
"type": "string",
1657+
"description": "The old string to replace.",
1658+
},
1659+
"replace": map[string]any{
1660+
"type": "string",
1661+
"description": "The new string that replaces the old string.",
16691662
},
16701663
},
1664+
"required": []string{"search", "replace"},
16711665
},
1672-
"required": []string{"path", "edits"},
16731666
},
16741667
},
1668+
"required": []string{"path", "edits"},
16751669
},
16761670
},
16771671
},

0 commit comments

Comments
 (0)