Skip to content

v0.9.0-beta.9: MCP number coercion fix + modifyOrder safety#100

Merged
luokerenx4 merged 3 commits intomasterfrom
dev
Apr 3, 2026
Merged

v0.9.0-beta.9: MCP number coercion fix + modifyOrder safety#100
luokerenx4 merged 3 commits intomasterfrom
dev

Conversation

@luokerenx4
Copy link
Copy Markdown
Contributor

Summary

  • fix: MCP number coercion — MCP clients sending string numbers ("80" instead of 80) caused Zod -32602 errors. Extract shared core/mcp-export.ts with z.coerce.number() at the MCP boundary.
  • fix: modifyOrder null-check bugs — Alpaca sent undefined fields to exchange API due to missing null guards. CCXT editOrder lacked auxPrice/tif/trailing field forwarding.
  • chore: bump to 0.9.0-beta.9

Test plan

  • 945 unit tests passing (includes 7 new TDD modifyOrder tests)
  • Build clean
  • MCP coercion fix verified by existing MCP test suite

🤖 Generated with Claude Code

Ame and others added 3 commits April 3, 2026 09:34
…ding

Alpaca: add null guards before UNSET_DOUBLE comparisons on lmtPrice,
auxPrice, trailingPercent — prevents sending undefined to exchange API.

CCXT: add null guard on lmtPrice, forward auxPrice/trailStopPrice/
trailingPercent/tif via params object to editOrder.

MockBroker: extend modifyOrder to handle trailStopPrice, trailingPercent,
orderType, tif fields.

TDD: 7 new tests (3 Alpaca + 4 CCXT) verify correct field isolation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
MCP SDK validates tool inputs with strict Zod parse before the handler
runs. When MCP clients send "80" (string) instead of 80 (number), the
call fails with -32602. Both mcp.ts and tool-bridge.ts had duplicated
code (toMcpContent, .shape extraction, execute wrapper) and the same
missing coercion.

Add core/mcp-export.ts as the single Vercel→MCP bridge:
- extractMcpShape(): extracts Zod shape + coerces number fields
  (z.number() → z.coerce.number(), preserving all refinements)
- wrapToolExecute(): shared try/catch + content conversion
- toMcpContent(): deduplicated from both consumers

Tool definitions stay strict; coercion only at the MCP boundary.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@luokerenx4 luokerenx4 merged commit bbb679f into master Apr 3, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant