Skip to content

Normalize MCP Accept handling, add canonical root discovery, bump server version, and expand tests#42

Merged
Trailgenic merged 2 commits into
mainfrom
codex/create-branch-for-mcp-compatibility-fixes-66rd62
Jul 14, 2026
Merged

Normalize MCP Accept handling, add canonical root discovery, bump server version, and expand tests#42
Trailgenic merged 2 commits into
mainfrom
codex/create-branch-for-mcp-compatibility-fixes-66rd62

Conversation

@Trailgenic

Copy link
Copy Markdown
Owner

Motivation

  • Improve content negotiation for MCP endpoints so clients that send Accept: application/json, */*, or omit Accept are supported while rejecting unsupported single text/event-stream only requests.
  • Expose a canonical MCP discovery payload at the root host and preserve route aliasing for /mcp requests.
  • Bump MCP server version metadata and ensure behavior is covered by automated tests.

Description

  • Added accept header parsing and normalization logic with acceptMediaTypes, acceptedMcpRequestNeedsNormalization, and normalizedMcpRequest and use a normalized Accept of application/json, text/event-stream when needed in app/mcp/route.ts.
  • Updated POST handler to pass the normalized request to handleEllaMcpPost and tightened error messages for invalid Accept/Content-Type combinations.
  • Implemented canonical MCP root discovery via isCanonicalMcpRootRequest and discoveryBody to return a JSON discovery payload; added ELLA_* constants from lib/ella-registry into the discovery payload.
  • Adjusted CORS/OPTIONS/GET behaviors to return proper Allow headers and 403/405 semantics for non-allowed origins or methods.
  • Added MCP_ROOT_HOST and rewrote the root host rewrite in next.config.ts to include ?mcpRoot=1 for the /mcp route.
  • Bumped ELLA_MCP_SERVER_INFO.version from 1.1.2 to 1.1.4 in lib/ella-registry.ts and exported additional registry constants consumed by the discovery payload.
  • Extended and updated tests/mcp.test.ts with new acceptance negotiation tests, a pingWithHeaders helper, canonical root discovery and alias-preservation tests, and additional assertions against registry constants.

Testing

  • Ran the MCP unit tests (tests/mcp.test.ts) under node:test and all tests completed successfully.
  • Verified content negotiation scenarios by exercising POST with a variety of Accept headers and asserting responses returned status 200 for supported types and 406/415/403 for invalid combinations.
  • Verified canonical root discovery and alias behavior via GET and POST requests to the root host and /mcp alias and asserted discovery payload fields match registry constants.

Codex Task

@vercel

vercel Bot commented Jul 14, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
ellaentity Ready Ready Preview, Comment Jul 14, 2026 2:23am

Request Review

@Trailgenic
Trailgenic merged commit b9b49c4 into main Jul 14, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant