Skip to content

Bound HTTP MCP request bodies and queue depth #2815

Description

@Widthdom

Summary

HttpMcpTransport reads HTTP request bodies to the end and uses an unbounded request queue. Even though the transport is intended for local/single-tenant use, this can allow local memory pressure or denial-of-service behavior.

Evidence

Relevant code paths:

  • src/CodeIndex/Mcp/HttpMcpTransport.cs:36 uses Channel.CreateUnbounded<PendingRequest>().
  • src/CodeIndex/Mcp/HttpMcpTransport.cs:273 reads the entire request with reader.ReadToEndAsync(cancellationToken).
  • A search for MaxRequest under src/ returned no request-size limit.

Expected

HTTP MCP should enforce bounded resource usage, for example:

  • reject requests over a configured max body size before reading them fully;
  • use a bounded channel or backpressure for queued requests;
  • return an appropriate 413/429-style response where applicable;
  • expose defaults and tuning knobs in docs/help if user-visible.

Impact

A local process can send very large or many HTTP requests and force the MCP server to allocate unbounded memory or queue work faster than it can be processed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingsecurity

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions