Skip to content

Commit dc6652c

Browse files
fix: temporary fix, revert zod schema definitions for mcp tools to zod v3 (#1323)
1 parent 518d7ea commit dc6652c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+297
-45
lines changed

.changeset/kind-lines-melt.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
"task-master-ai": patch
3+
---
4+
5+
Fix MCP server compatibility with Draft-07 clients (Augment IDE, gemini-cli, gemini code assist)
6+
7+
- Resolves #1284
8+
9+
**Problem:**
10+
11+
- MCP tools were using Zod v4, which outputs JSON Schema Draft 2020-12
12+
- MCP clients only support Draft-07
13+
- Tools were not discoverable in gemini-cli and other clients
14+
15+
**Solution:**
16+
17+
- Updated all MCP tools to import from `zod/v3` instead of `zod`
18+
- Zod v3 schemas convert to Draft-07 via FastMCP's zod-to-json-schema
19+
- Fixed logger to use stderr instead of stdout (MCP protocol requirement)
20+
21+
This is a temporary workaround until FastMCP adds JSON Schema version configuration.

.coderabbit.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
reviews:
22
profile: chill
33
poem: false
4+
auto_review:
5+
enabled: true
6+
base_branches:
7+
- ".*"
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Why MCP Tools Use Zod v3
2+
3+
## Problem
4+
5+
- **FastMCP** uses `xsschema` to convert schemas → outputs JSON Schema **Draft 2020-12**
6+
- **MCP clients** (Augment IDE, gemini-cli, etc.) only support **Draft-07**
7+
- Using Zod v4 in tools causes "vendor undefined" errors and tool discovery failures
8+
9+
## Temporary Solution
10+
11+
All MCP tool files import from `zod/v3` instead of `zod`:
12+
13+
```typescript
14+
import { z } from 'zod/v3'; // ✅ Draft-07 compatible
15+
// NOT: import { z } from 'zod'; // ❌ Would use Draft 2020-12
16+
```
17+
18+
### Why This Works
19+
20+
- Zod v4 ships with v3 compatibility at `zod/v3`
21+
- FastMCP + zod-to-json-schema converts Zod v3 schemas → **Draft-07**
22+
- This ensures MCP clients can discover and use our tools
23+
24+
### What This Means
25+
26+
-**MCP tools** → use `zod/v3` (apps/mcp & mcp-server/src/tools)
27+
-**Rest of codebase** → uses `zod` (Zod v4)
28+
-**No conflicts** → they're from the same package, just different versions
29+
30+
## When Can We Remove This?
31+
32+
This workaround can be removed when **either**:
33+
34+
1. **FastMCP adds JSON Schema version configuration**
35+
- e.g., `new FastMCP({ jsonSchema: { target: 'draft-07' } })`
36+
- Tracking: https://github.com/punkpeye/fastmcp/issues/189
37+
38+
2. **MCP spec adds Draft 2020-12 support**
39+
- Unlikely in the short term
40+
41+
3. **xsschema adds version targeting**
42+
- Would allow FastMCP to use Draft-07
43+
44+
## How to Maintain
45+
46+
When adding new MCP tools:
47+
48+
```typescript
49+
// ✅ CORRECT
50+
import { z } from 'zod/v3';
51+
52+
export function registerMyTool(server: FastMCP) {
53+
server.addTool({
54+
name: 'my_tool',
55+
parameters: z.object({ ... }), // Will use Draft-07
56+
execute: async (args, context) => { ... }
57+
});
58+
}
59+
```
60+
61+
```typescript
62+
// ❌ WRONG - Will break MCP client compatibility
63+
import { z } from 'zod'; // Don't do this in apps/mcp/src/tools/
64+
```
65+
66+
---
67+
68+
**Last Updated:** 2025-10-18
69+
**Affects:** All files in `apps/mcp/src/tools/`
70+
**See Also:** `mcp-server/src/tools/README-ZOD-V3.md` (same workaround)

apps/mcp/src/tools/autopilot/abort.tool.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
* Abort a running TDD workflow and clean up state
44
*/
55

6-
import { z } from 'zod';
6+
// TEMPORARY: Using zod/v3 for Draft-07 JSON Schema compatibility with FastMCP's zod-to-json-schema
7+
// TODO: Revert to 'zod' when MCP spec issue is resolved (see PR #1323)
8+
import { z } from 'zod/v3';
79
import {
810
handleApiResult,
911
withNormalizedProjectRoot

apps/mcp/src/tools/autopilot/commit.tool.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
* Create a git commit with automatic staging and message generation
44
*/
55

6-
import { z } from 'zod';
6+
// TEMPORARY: Using zod/v3 for Draft-07 JSON Schema compatibility with FastMCP's zod-to-json-schema
7+
// TODO: Revert to 'zod' when MCP spec issue is resolved (see PR #1323)
8+
import { z } from 'zod/v3';
79
import {
810
handleApiResult,
911
withNormalizedProjectRoot

apps/mcp/src/tools/autopilot/complete.tool.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
* Complete the current TDD phase with test result validation
44
*/
55

6-
import { z } from 'zod';
6+
// TEMPORARY: Using zod/v3 for Draft-07 JSON Schema compatibility with FastMCP's zod-to-json-schema
7+
// TODO: Revert to 'zod' when MCP spec issue is resolved (see PR #1323)
8+
import { z } from 'zod/v3';
79
import {
810
handleApiResult,
911
withNormalizedProjectRoot

apps/mcp/src/tools/autopilot/finalize.tool.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
* Finalize and complete the workflow with working tree validation
44
*/
55

6-
import { z } from 'zod';
6+
// TEMPORARY: Using zod/v3 for Draft-07 JSON Schema compatibility with FastMCP's zod-to-json-schema
7+
// TODO: Revert to 'zod' when MCP spec issue is resolved (see PR #1323)
8+
import { z } from 'zod/v3';
79
import {
810
handleApiResult,
911
withNormalizedProjectRoot

apps/mcp/src/tools/autopilot/next.tool.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
* Get the next action to perform in the TDD workflow
44
*/
55

6-
import { z } from 'zod';
6+
// TEMPORARY: Using zod/v3 for Draft-07 JSON Schema compatibility with FastMCP's zod-to-json-schema
7+
// TODO: Revert to 'zod' when MCP spec issue is resolved (see PR #1323)
8+
import { z } from 'zod/v3';
79
import {
810
handleApiResult,
911
withNormalizedProjectRoot

apps/mcp/src/tools/autopilot/resume.tool.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
* Resume a previously started TDD workflow from saved state
44
*/
55

6-
import { z } from 'zod';
6+
// TEMPORARY: Using zod/v3 for Draft-07 JSON Schema compatibility with FastMCP's zod-to-json-schema
7+
// TODO: Revert to 'zod' when MCP spec issue is resolved (see PR #1323)
8+
import { z } from 'zod/v3';
79
import {
810
handleApiResult,
911
withNormalizedProjectRoot

apps/mcp/src/tools/autopilot/start.tool.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
* Initialize and start a new TDD workflow for a task
44
*/
55

6-
import { z } from 'zod';
6+
// TEMPORARY: Using zod/v3 for Draft-07 JSON Schema compatibility with FastMCP's zod-to-json-schema
7+
// TODO: Revert to 'zod' when MCP spec issue is resolved (see PR #1323)
8+
import { z } from 'zod/v3';
79
import {
810
handleApiResult,
911
withNormalizedProjectRoot

0 commit comments

Comments
 (0)