Skip to content

feat(transport): add max_line_length to TokioChildProcessBuilder - #1522

Open
Koobi33 wants to merge 2 commits into
modelcontextprotocol:mainfrom
Koobi33:feat/child-process-max-line-length
Open

Koobi33 wants to merge 2 commits into
modelcontextprotocol:mainfrom
Koobi33:feat/child-process-max-line-length

Conversation

@Koobi33

@Koobi33 Koobi33 commented Nov 30, 2026

Copy link
Copy Markdown

Part of #1513

Problem

TokioChildProcess reads the child's stdout through AsyncRwTransport with the default 16 MiB line limit, and the builder gives no way to change it. A client that expects larger responses from a stdio server can't raise the limit.

Change

TokioChildProcessBuilder::max_line_length(usize) sets the limit on the child's stdout transport (AsyncRwTransport::with_max_line_length). The default stays DEFAULT_MAX_LINE_LENGTH. TokioChildProcess::new is unchanged.

The other half of #1513, failing the pending request right away instead of waiting for the timeout, needs the request id from the dropped line, so it fits after #1471.

Tests

crates/rmcp/tests/test_child_process_max_line_length.rs (unix): a child prints a notification of a given size and then a short one.

  • default limit: the 4 KB line arrives
  • max_line_length(1024): the 4 KB line is dropped and the short one still arrives
  • max_line_length(DEFAULT_MAX_LINE_LENGTH + 2048): a line over 16 MiB arrives

cargo +nightly fmt --all -- --check, cargo clippy --all-targets --all-features -- -D warnings and cargo test -p rmcp --all-features --lib pass.

This PR was written primarily by Claude Code.

@Koobi33
Koobi33 requested a review from a team as a code owner November 30, 2026 09:06
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-30T19:32:19.767150Z 8af6b15 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added T-test Testing related changes T-core Core library changes T-transport Transport layer changes labels Nov 30, 2026
@github-actions
github-actions Bot requested a review from connor4312 November 30, 2026 09:06
@github-actions

Copy link
Copy Markdown
Contributor

@connor4312 is on triage rotation this week and is the reviewer for this one.

Labels come from the PR labeler. Please review the change.

Automated triage. Labels are a first pass and the assigned maintainer has the final say.

@jokemanfire jokemanfire 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.

Verified at head 99c900a3, base c78f2764.

  • base + the new test file -> compile error E0599: no method named max_line_length (the entry point genuinely does not exist yet)
  • head -> cargo test -p rmcp --features client,transport-child-process --test test_child_process_max_line_length = 3 passed, including the line above the 16 MiB default
  • cargo fmt --all -- --check clean

Read the wiring: the new field defaults to DEFAULT_MAX_LINE_LENGTH, is forwarded to AsyncRwTransport::new(...).with_max_line_length(...) in spawn(); TokioChildProcess::new is untouched. Only the stdout transport is a read path, so applying it there is the complete change. The shell-generated child avoids argv limits, which is why the 16 MiB case works.

One nit, not blocking: max_line_length(0) is accepted, and then every line is discarded and receive() never yields a message, which looks identical to a server that sends nothing. Either document "must be greater than zero" or clamp/assert in the setter. The doc pointer to with_max_line_length also carries the usize::MAX unbounded note, so callers can find it.

The remaining half of #1513 (failing the pending request instead of waiting for the timeout) is correctly deferred to the #1471 shape.

@Koobi33

Koobi33 commented Nov 30, 2026

Copy link
Copy Markdown
Author

Thanks for checking.

Zero comes from with_max_line_length on the underlying transport, which accepts it the same way. Added "must be greater than zero" to the doc comment on both setters.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-core Core library changes T-test Testing related changes T-transport Transport layer changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants