Skip to content

Cap MCP response byte-limit environment overrides #2861

Description

@Widthdom

Problem

src/CodeIndex/Mcp/McpServer.cs and src/CodeIndex/Mcp/McpToolHandlers.cs accept any positive integer from MCP response-limit environment variables.

Impact

A misconfigured or inherited environment can raise response limits to extremely large values, defeating the guardrails intended to bound MCP memory and transport usage.

Expected

Clamp environment-provided limits to a documented maximum, reject nonsensical values with diagnostics, and keep conservative defaults when overrides are invalid.

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