Skip to content

Commit 7284905

Browse files
committed
fix(filesystem): correct outputSchema for directory_tree and move_file
Why this change was needed: Both tools declared outputSchema as { content: z.string() } but their handlers return { content: [{ type: "text", text: "..." }] } - an array of content blocks. This mismatch caused MCP validation error -32602. What changed: - Updated directory_tree outputSchema to declare content as array of text content blocks - Updated move_file outputSchema with the same fix - Schema now matches the actual return type of both handlers Problem solved: Clients using structured content validation no longer receive -32602 errors when calling directory_tree or move_file tools. Fixes #3093, Fixes #3106
1 parent dcb47d2 commit 7284905

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/filesystem/index.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,12 @@ server.registerTool(
518518
path: z.string(),
519519
excludePatterns: z.array(z.string()).optional().default([])
520520
},
521-
outputSchema: { content: z.string() },
521+
outputSchema: {
522+
content: z.array(z.object({
523+
type: z.literal("text"),
524+
text: z.string()
525+
}))
526+
},
522527
annotations: { readOnlyHint: true }
523528
},
524529
async (args: z.infer<typeof DirectoryTreeArgsSchema>) => {
@@ -588,7 +593,12 @@ server.registerTool(
588593
source: z.string(),
589594
destination: z.string()
590595
},
591-
outputSchema: { content: z.string() },
596+
outputSchema: {
597+
content: z.array(z.object({
598+
type: z.literal("text"),
599+
text: z.string()
600+
}))
601+
},
592602
annotations: { readOnlyHint: false, idempotentHint: false, destructiveHint: false }
593603
},
594604
async (args: z.infer<typeof MoveFileArgsSchema>) => {

0 commit comments

Comments
 (0)