Skip to content

Commit c665dcc

Browse files
jack-arturoclaude
andcommitted
fix(build): resolve TS2589 in server.ts and axios header type drift
package-lock.json is gitignored, so CI's fresh npm install resolves newer zod/axios than long-lived local node_modules and surfaced two type errors (same pair as upstream InstaWP#22, fix adapted to keep the tool description argument): - server.tool's generic resolves ShapeOutput<Args> against the SDK's z3|z4 union schema type, exploding instantiation depth (TS2589); call through an explicitly-typed cast. - axios headers['content-type'] is AxiosHeaderValue (can be null/number); narrow to string before normalizeMimeType. Verified with tsc --noEmit against both a fresh npm install and the existing local node_modules, plus a stdio protocol probe (164-byte initialize, 43/43 tool descriptions intact). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 076540b commit c665dcc

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

‎src/server.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
77
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
88
import { allTools, toolHandlers } from './tools/index.js';
99
import { z } from 'zod';
10-
import { zodToJsonSchema } from 'zod-to-json-schema';
1110

1211

1312
// Create MCP server instance.
@@ -43,8 +42,12 @@ for (const tool of allTools) {
4342

4443
// Tool modules define inputSchema.properties as zod shapes (see CLAUDE.md);
4544
// passing raw JSON Schema here collapses the published schema to {}.
46-
const zodSchema = z.object(tool.inputSchema.properties as z.ZodRawShape);
47-
server.tool(tool.name, tool.description ?? '', zodSchema.shape, wrappedHandler)
45+
const rawShape = tool.inputSchema.properties as z.ZodRawShape;
46+
// Cast bypasses TS2589: server.tool's generic resolves ShapeOutput<Args>
47+
// against the SDK's z3|z4 union schema type, exploding instantiation depth.
48+
(server.tool as (name: string, description: string, schema: z.ZodRawShape, cb: typeof wrappedHandler) => unknown)(
49+
tool.name, tool.description ?? '', rawShape, wrappedHandler
50+
);
4851

4952
}
5053

‎src/tools/media.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,8 @@ async function loadUploadFromUrl(sourceUrl: string, explicitTitle?: string): Pro
255255
}
256256

257257
const response = await axios.get<ArrayBuffer>(sourceUrl, { responseType: 'arraybuffer' });
258-
const mimeType = normalizeMimeType(response.headers['content-type']);
258+
const contentTypeHeader = response.headers['content-type'];
259+
const mimeType = normalizeMimeType(typeof contentTypeHeader === 'string' ? contentTypeHeader : undefined);
259260
const originalFilename = deriveFilenameFromUrl(sourceUrl, mimeType);
260261
const filename = buildUploadFilename(originalFilename, explicitTitle);
261262

0 commit comments

Comments
 (0)