feat: run HTTP tools/call handlers on a dedicated worker task - #7
Merged
Conversation
abcsnowwolf
commented
Jul 27, 2026
Contributor
- execute tools/call on a queue-fed worker task instead of the async_tcp task, so slow or blocking handlers no longer starve the TCP stack or trip the task watchdog
- deliver results via a deferred chunked response (RESPONSE_TRY_AGAIN); protocol methods, notifications, and transport errors stay inline
- bound pending calls with MCP_HTTP_JOB_QUEUE_DEPTH (default 4) and answer JSON-RPC -32000 "server busy" when the queue is full
- manage jobs with an intrusive refcount allocated via new (std::nothrow): allocation failure answers JSON-RPC -32603 / HTTP 500 echoing the request id, in both exception modes, instead of aborting under -fno-exceptions; degrade to inline execution if the worker task cannot be created
- reject HTTP/1.0 tools/call with 505 instead of trusting the fork-dependent close-delimited fallback behind __has_include
- extend the ESPAsyncWebServer mock with chunked-response support and add tests: slow handlers, queue overflow, client abort, teardown with in-flight jobs, OOM injection, HTTP/1.0 rejection
- document the HTTP execution model in the README
- bump version to 0.3.0 and point examples at ESP-MCP ^0.3.0
* execute tools/call on a queue-fed worker task instead of the async_tcp task, so slow or blocking handlers no longer starve the TCP stack or trip the task watchdog * deliver results via a deferred chunked response (RESPONSE_TRY_AGAIN); protocol methods, notifications, and transport errors stay inline * bound pending calls with MCP_HTTP_JOB_QUEUE_DEPTH (default 4) and answer JSON-RPC -32000 "server busy" when the queue is full * manage jobs with an intrusive refcount allocated via new (std::nothrow): allocation failure answers JSON-RPC -32603 / HTTP 500 echoing the request id, in both exception modes, instead of aborting under -fno-exceptions; degrade to inline execution if the worker task cannot be created * reject HTTP/1.0 tools/call with 505 instead of trusting the fork-dependent close-delimited fallback behind __has_include * extend the ESPAsyncWebServer mock with chunked-response support and add tests: slow handlers, queue overflow, client abort, teardown with in-flight jobs, OOM injection, HTTP/1.0 rejection * document the HTTP execution model in the README * bump version to 0.3.0 and point examples at ESP-MCP ^0.3.0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.