Skip to content

fix(filesystem): emit object input schemas - #4775

Open
Tiancheng-Xu wants to merge 1 commit into
modelcontextprotocol:mainfrom
Tiancheng-Xu:fix/filesystem-input-schema-type
Open

fix(filesystem): emit object input schemas#4775
Tiancheng-Xu wants to merge 1 commit into
modelcontextprotocol:mainfrom
Tiancheng-Xu:fix/filesystem-input-schema-type

Conversation

@Tiancheng-Xu

Copy link
Copy Markdown

Description

Closes #4772.

server-filesystem registered tools with raw Zod shapes (Schema.shape or inline field objects). With older SDK schema conversion, that representation can omit the root type: "object" from the JSON Schema returned by tools/list, causing strict JSON Schema 2020-12 clients to reject the server.

This change:

  • registers every filesystem tool with a complete z.object(...) schema;
  • adds a real stdio MCP regression test that calls tools/list and checks every tool's inputSchema.type.

No tool arguments or unrelated servers were changed.

How Has This Been Tested?

  • npm run build — passed for all workspaces.
  • cd src/filesystem && npx vitest run --coverage __tests__/tools-list-schema.test.ts — passed, 1 test.
  • The focused non-Unicode filesystem suite — passed, 166 tests across 10 files.
  • The complete filesystem suite — 166 passed and 3 pre-existing macOS Unicode-path failures. The failures are caused by /var vs /private/var realpath handling and NFD/NFC directory behavior; the same 3 failures reproduce on the parent commit.
  • The published @modelcontextprotocol/server-filesystem@2025.8.21 baseline reproduces the reported strict-client failure for all 13 tools (inputSchema.type is missing).

The new regression test passes on the current repository baseline because the current @modelcontextprotocol/sdk@1.30.0 compatibility layer normalizes raw shapes. The implementation removes that dependency on implicit SDK behavior for future releases.

Breaking Changes

None. Tool names, arguments, and handlers are unchanged.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature
  • Breaking change
  • Documentation update

Checklist

  • I have read the MCP Protocol Documentation
  • My changes follow MCP security best practices
  • I have updated the server's README accordingly (not applicable)
  • I have tested this with an LLM client (the regression uses the MCP SDK stdio client)
  • My code follows the repository's style guidelines
  • Targeted and unaffected existing tests pass locally
  • No new error-handling path was introduced
  • Environment variables or configuration options are not applicable

AI assistance disclosure

This PR was prepared with OpenAI Codex under human direction. The final diff, test evidence, and issue/PR state were reviewed before submission.

中文说明

关闭 #4772。filesystem 原先把裸 Zod shape 注册给 SDK;在受影响的旧 SDK 转换路径中,tools/list 返回的 JSON Schema 会缺少根级 type: "object",严格的 JSON Schema 2020-12 客户端因此拒绝启动。本 PR 将全部 filesystem 工具改为使用完整的 z.object(...) schema,并增加真实 stdio MCP tools/list 回归测试,确认每个工具都声明 inputSchema.type: "object"。工具名称、参数和处理器保持不变。完整测试中的 3 个 Unicode 路径失败在父提交上也能复现,属于当前 macOS 环境基线问题,未将其写成通过。

Copilot AI balanced review requested due to automatic review settings September 7, 2026 17:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The change is a small, well-scoped schema fix whose 14 substitutions are each semantically equivalent to prior definitions, matches an existing repo convention, and is covered by a regression test following an established pattern.

Pull request overview

This PR fixes a JSON Schema compliance bug in server-filesystem (issue #4772), where tools/list responses could omit the required root type: "object" from each tool's inputSchema, causing strict JSON Schema 2020-12 clients (e.g. Claude Desktop's "Cowork and Code" shared pool) to reject the server. It converts every tool registration from raw Zod shapes (Schema.shape / inline field objects) to complete z.object(...) schemas, and adds a real stdio MCP regression test that asserts every tool advertises inputSchema.type: "object".

Changes:

  • Replaces raw Zod shapes / inline field objects with the already-defined z.object(...) named schemas across all 14 filesystem tool registrations (and z.object({}) for list_allowed_directories).
  • Adds __tests__/tools-list-schema.test.ts, which spawns the built server over stdio, calls tools/list, and checks each tool's inputSchema.type.
File summaries
File Description
src/filesystem/index.ts Registers every tool with a full z.object(...) input schema instead of a raw shape/.shape, ensuring the root type: "object" is emitted.
src/filesystem/tests/tools-list-schema.test.ts New stdio MCP regression test verifying every tool's inputSchema.type is "object".

Notes from verification:

  • All 14 substituted schemas are semantically equivalent to the inline definitions they replace (schemas defined at index.ts:97-161); handlers already typed their args via z.infer<typeof …Schema>, so this also removes duplication.
  • Passing a z.object(...) (ZodObject) directly to registerTool's inputSchema matches the existing repo convention (src/everything/tools/echo.ts:15), so it is the idiomatic form.
  • The new test mirrors the existing directory-tree.mcp-sdk.test.ts pattern (spawning ../dist/index.js), so its build dependency is not a new concern.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

server-filesystem: missing inputSchema.type breaks JSON Schema 2020-12 validators (all versions 0.6.2–2025.8.21)

2 participants