anthropics / anthropics/claude-agent-sdk-typescript

createSdkMcpServer drops Zod v4 field .describe() if nested or added after via registerTool

Aperta
#325 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
bug
Lingua principale
Shell
Stelle
1.8k
Fork
226
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

### **Summary**
Follow-up to #243. That fix correctly backfills descriptions for top-level shape values passed via the tools array, but two problems
1. does not do nested properties
2. only works if you add the tools during createSdkMcpServer call, if you do registerTool after, it also does not get backfilled

### **Minimal repro:**
```typescript
import { createSdkMcpServer } from '@anthropic-ai/claude-agent-sdk';
import { z } from 'zod';

const mcpServer = createSdkMcpServer({
name: 'test',
version: '1.0.0',
tools: [{
name: 'test_tool',
description: 'A test tool',
inputSchema: {
options: z.object({
followUp: z.string().describe('This description is dropped'),
}).optional().describe('This description is preserved'),
},
handler: async () => ({ content: [] }),
}],
});

mcpServer.instance.registerTool('test_tool', {query: z.string().describe('dropped too'));
```
Both the nested "followup" and the "test_tool" descriptions will be dropped

### **Root cause**
Here's what I think is the root cause, the original fix only backfills the top level during createSdkMcpServer, so nested is dropped, and any tools added after that call does not get the benefit of the backfill

``` typescript
// Backfill loop — flat, no recursion
for (const field of Object.values(tool.inputSchema)) {
if (!isZodType(field)) continue;
const desc = field.description;
if (desc && !z6.has(field)) z6.add(field, { description: desc });
}
```

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.