Skip to content

fix(mcp): OpenAPI compositors, stdio build, Cursor MCP config, Vitest… - #5

Closed
debankurghosh2061 wants to merge 1 commit into
mainfrom
bug/fix-schema-validation
Closed

fix(mcp): OpenAPI compositors, stdio build, Cursor MCP config, Vitest…#5
debankurghosh2061 wants to merge 1 commit into
mainfrom
bug/fix-schema-validation

Conversation

@debankurghosh2061

Copy link
Copy Markdown

Problem

Request-body fields defined only with OpenAPI anyOf/oneOf (e.g. booking payment on POST /rates/book) were converted to z.any(), so MCP clients often sent nested objects as JSON strings. LiteAPI then returned 4002 (readObjectStart / payment parse errors).

Schema & runtime

  • Route all OpenAPI→Zod conversion through src/utils/schema-converter.ts (anyOf/oneOf/allOfz.union / z.intersection) in:
    • lib/mcp-tools.ts (Next.js HTTP MCP)
    • src/server.ts (stdio MCP)
  • lib/mcp-tools.ts: import openAPIToZod + OpenAPISchema casts for typing.
  • run-mcp-server.mjs: import LiteAPIMCPServer from dist/server.js (index only runs main() and does not export the class).
  • src/server.ts: remove unused createJSONSchema / openAPIToJSONSchema.

Build & TypeScript

  • Add tsconfig.stdio.json: emit dist/ from src/ with NodeNext (stdio Claude/Inspector workflows).
  • package.json: build:stdiotsc -p tsconfig.stdio.json; scripts test:unit / test:unit:watch (Vitest).
  • tsconfig.json: exclude test/, vitest.config.ts from Next app typecheck.

Tests (Vitest, no live API)

  • test/schema-converter.test.ts: anyOf payment-style → ZodUnion, basic oneOf / objects / undefined.
  • test/api-client.test.ts: mock fetch; assert POST body keeps payment as a nested object (not a string).
  • test/booking-flow.test.ts: load openapi-schemas/booking.json; assert /rates/book paymentZodUnion and prebook body requirements.

Tooling & repo hygiene

  • .gitignore: .env.*.local, *.tsbuildinfo, .cursor/debug*.log; dedupe .DS_Store; group .next with build artifacts.
  • .vscode/launch.json: node --import tsx for stdio MCP; npm run dev for Next HTTP MCP (replace broken ts-node config).
  • .cursor/mcp.json: project LiteAPI MCP (stdio via tsx, envFile.env.local).
  • .env.example: template for LITEAPI_API_KEY (copy to .env.local).

Documentation

  • README.md: NPM scripts table; HTTP vs stdio; npm start vs stdio; Cursor
    • .env.local; unit vs integration tests; Inspector uses run-mcp-server.mjs after build:stdio; project structure (app/, lib/, test/, etc.).

Dependencies

  • devDependencies: vitest (+ lockfile rollup/vitest transitive updates).

@vercel

vercel Bot commented Mar 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
mcp-server Ready Ready Preview Aug 5, 2026 3:12pm

Request Review

@squallstar squallstar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make sure you test with the AI chatbot to ensure tools work once deployed

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.

3 participants