Skip to content

Commit c7a0037

Browse files
committed
parse string input into json objects...
bad assumptions about wire format in MCP requests
1 parent f2370cd commit c7a0037

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

packages/mcp/src/tools/create-card.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@ export async function handleCreateCard(
2323
try {
2424
// Validate input and log start
2525
const validatedInput = CreateCardInputSchema.parse(input);
26+
27+
// Fix: Claude Code's MCP client sends data as a JSON string instead of an object
28+
// Parse it if it's a string
29+
if (typeof validatedInput.data === 'string') {
30+
try {
31+
validatedInput.data = JSON.parse(validatedInput.data);
32+
} catch (e) {
33+
throw new Error(`Invalid JSON in data parameter: ${e instanceof Error ? e.message : String(e)}`);
34+
}
35+
}
36+
2637
logToolStart(TOOL_NAME, validatedInput);
2738

2839
// Get course config to validate datashape

0 commit comments

Comments
 (0)