Skip to content

Conversation

@Scra3
Copy link
Member

@Scra3 Scra3 commented Feb 11, 2026

Summary

  • Capture and log the HTTP response body when the transport returns status >= 500
  • Log after handleRequest when the transport returned a 500

Context

A client gets a silent 500 on notifications/initialized after a successful initialize. The server logs show:

info: [MCP] Incoming POST /mcp [initialize]
info: [MCP] [200] POST /mcp - 7ms
info: [MCP] Incoming POST /mcp [notifications/initialized]
error: [MCP] [500] POST /mcp - 1ms

No error message is logged between the "Incoming" and the "[500]".

This happens because the Hono adapter (@hono/node-server) inside @modelcontextprotocol/sdk catches errors internally and writes 500 directly to the Node.js response, bypassing our logger entirely. Two error paths in Hono produce silent 500s:

  1. handleFetchError — when the Web Standard transport handler's Promise rejects → returns Response(null, {status: 500}) (empty body)
  2. handleResponseError — when writing the response to the Node.js res fails → writes Error: <message> as plain text body

With this PR, the same scenario would log:

info: [MCP] Incoming POST /mcp [notifications/initialized]
error: [MCP] HTTP 500 response body: Error: <actual error message>    ← NEW
error: [MCP] Transport returned HTTP 500 for [notifications/initialized]  ← NEW
error: [MCP] [500] POST /mcp - 1ms

Test plan

  • All 487 existing MCP server tests pass
  • Lint passes
  • Deploy to client environment and check logs for the actual error message

🤖 Generated with Claude Code

alban bertolini and others added 2 commits February 11, 2026 14:12
…sport

The Hono adapter inside @modelcontextprotocol/sdk catches errors internally
and writes 500 directly to the response without going through our logger.
This makes debugging impossible when the transport returns 500.

Add two diagnostic log points:
- Capture and log the HTTP response body when status >= 500
- Log after handleRequest when the transport returned a 500

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@qltysh
Copy link

qltysh bot commented Feb 11, 2026

Qlty

Coverage Impact

⬆️ Merging this pull request will increase total coverage on main by 0.05%.

Modified Files with Diff Coverage (2)

RatingFile% DiffUncovered Line #s
Coverage rating: B Coverage rating: B
packages/mcp-server/src/server.ts100.0%
Coverage rating: C Coverage rating: B
packages/mcp-server/src/utils/sse-error-logger.ts100.0%
Total100.0%
🚦 See full report on Qlty Cloud »

🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

Add edge case tests (Buffer, Uint8Array, late status change, boundary
statuses) and strengthen assertions per review feedback.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Scra3 Scra3 force-pushed the fix/mcp-server-diagnostic-silent-500 branch from 62c1192 to 1c4726e Compare February 11, 2026 13:25
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Scra3 Scra3 merged commit 6849c4c into main Feb 11, 2026
27 checks passed
@Scra3 Scra3 deleted the fix/mcp-server-diagnostic-silent-500 branch February 11, 2026 13:46
forest-bot added a commit that referenced this pull request Feb 11, 2026
# @forestadmin/mcp-server [1.8.0](https://github.com/ForestAdmin/agent-nodejs/compare/@forestadmin/mcp-server@1.7.7...@forestadmin/mcp-server@1.8.0) (2026-02-11)

### Bug Fixes

* **mcp-server:** add diagnostic logging for silent HTTP 500 from transport ([#1461](#1461)) ([6849c4c](6849c4c))

### Features

* **mcp-server:** add Forest Admin logo ([#1459](#1459)) ([7eaec86](7eaec86))
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.

2 participants