test(filesystem): add MCP SDK regression coverage for directory_tree#3245
Conversation
|
@claude review |
|
Claude finished @cliffhall's task in 1m 13s —— View job PR Review: test(filesystem): add MCP SDK regression coverage for directory_treeTasks:
SummaryThe
|
| Change | Assessment |
|---|---|
realpath fix in structured-content.test.ts |
✅ Correct, fix a real macOS bug |
New directory-tree.mcp-sdk.test.ts |
❌ Duplicate of existing coverage in structured-content.test.ts |
The PR can be merged if the duplicate file is dropped (or if the equivalent block is removed from structured-content.test.ts).
Summary
This PR adds regression test coverage only for a
directory_treestructured-content validation bug that appears to have already been fixed upstream.There are no runtime behavior changes in this PR.
Context
The
-32602error reported in:occurs when a tool declares
outputSchema: { content: string }but returnsstructuredContent.contentas an array.From git history, this appears to have been fixed in:
e6933ca— "Fix: Changed structuredContent output to match outputSchema (Fix: Changed structuredContent output to match outputSchema #3099)" (2025-12-11)Note: I opened this PR after seeing the open bug reports and reproducing the issue in an older build, but I did not initially confirm that
mainalready contained the fix. I’m keeping this PR scoped to test coverage in case it’s still useful as a regression guard.What this PR does
src/filesystem/__tests__/directory-tree.mcp-sdk.test.ts@modelcontextprotocol/sdk+StdioClientTransportto calldirectory_treeend-to-end.structuredContent.contentis astringand JSON-parseable.structured-content.test.tsslightly more robust on macOS by resolving the temp directory withfs.realpath()so the allowlist path matches/private/...temp paths.This is intended to help prevent reintroducing the same outputSchema/structuredContent mismatch.
Minimal reproduction snippet (for older builds)
I was able to reproduce the
-32602validation error by running the filesystem server over stdio and callingdirectory_treethrough the MCP SDK client.Maintainers can run the following snippet directly (Node 20+):
On buggy builds, this call throws
McpError: -32602 ... Expected string, received array at path: ["content"].Release context
I have not traced the exact release tag for
e6933ca, but based on timestamps it looks like the fix (2025-12-11) should be included in npm releases published after that date (for example@modelcontextprotocol/server-filesystem@2025.12.18and later).Happy to update this PR with the exact release tag if you'd like me to track it down precisely.
Test plan
npm test --workspace @modelcontextprotocol/server-filesystemFollow-up suggestion (optional)
If you'd like, I can follow up with a small CI-level "functional" test job that runs a tiny MCP SDK client against the built
dist/index.jsbinaries for select servers (filesystem, memory, etc.) to assert that schema validation passes for a few representative tool calls.I didn't include CI changes in this PR since I wasn't sure how you'd want to scope cross-package functional tests.
Authorship note
This contribution (bug identification, repro, test updates, and PR drafting) was authored with OpenAI Codex.