fix: format mcp-client.ts to fix validation error - #1283
awhite0030 wants to merge 3 commits into
Conversation
When an MCP tool schema specifies an argument type as `string`, but the provided arguments contain an object instead, Nanocoder previously only sanitized the top-level keys. Deeply nested properties and array items inside these arguments were skipped and passed to the MCP server directly as objects. This commit introduces a recursive `sanitizeArgs` function to properly ensure objects are stringified anywhere in the object tree if the schema defines them as `string`. It also adds a comprehensive regression test.
nc-review: needs work — 1 blocking, 1 important, 3 nits@awhite0030 — there is a blocking item below. Replaces the one-level 🔴 blocking · The PR ships five regenerated 🟠 important · The added changeset uses the filename ⚪ nit · Minor: when ⚪ nit · The new regression test relies on the same ⚪ nit ·
🔴 blocking · 🟠 a reviewer would ask for a change · ⚪ optional Automated code review — correctness, security, design, tests, plus duplicates and scope. A human still decides; this is not a substitute for review and is not exhaustive. The required status checks separately cover lint, formatting, types, unused dependencies, the test suite and the build. This bot never merges. Maintainers can rerun with |
Description
Brief description of what this PR does
Type of Change
Changeset
pnpm changeset) describing this change for the changelogDocs-only or internal chores need no changeset (or run
pnpm changeset --emptyto note that intentionally).Testing
Automated Tests
.spec.ts/tsxfilespnpm test:allcompletes successfully)Manual Testing
Checklist
Root cause: The previous commit correctly fixed the issue by introducing
sanitizeArgsbut the new code failedpnpm test:formatcheck due to a long line exceeding Biome's limit.Fix: Formatted
source/mcp/mcp-client.tsusingpnpm test:format --writeto resolve the linting error.Validation: Ran
pnpm run build,pnpm test:format,pnpm test:lint,pnpm test:types,pnpm test:knip, and targetedpnpm test:ava source/mcp/mcp-client.spec.ts, and all checks pass successfully.Fixes #1147
Fixes #1147