{"record":{"id":"82d02624b62e6266","repo":"Hmbown/CodeWhale","slug":"exceeded-the-item-catalogue-limit","errorCode":null,"errorMessage":"{} exceeded the {}-item catalogue limit","messagePattern":"(.+?) exceeded the (.+?)-item catalogue limit","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/mcp.rs","lineNumber":1498,"sourceCode":"    }\n\n    fn observe_page(\n        &mut self,\n        result: &serde_json::Value,\n        item_count: usize,\n    ) -> Result<Option<String>> {\n        self.pages = self.pages.saturating_add(1);\n        self.items = self.items.saturating_add(item_count);\n        self.bytes = self.bytes.saturating_add(serde_json::to_vec(result)?.len());\n        if self.pages > MAX_MCP_CATALOG_PAGES {\n            anyhow::bail!(\n                \"{} exceeded the {}-page catalogue limit\",\n                self.method,\n                MAX_MCP_CATALOG_PAGES\n            );\n        }\n        if self.items > MAX_MCP_CATALOG_ITEMS {\n            anyhow::bail!(\n                \"{} exceeded the {}-item catalogue limit\",\n                self.method,\n                MAX_MCP_CATALOG_ITEMS\n            );\n        }\n        if self.bytes > MAX_MCP_CATALOG_BYTES {\n            anyhow::bail!(\n                \"{} exceeded the {}-byte aggregate catalogue limit\",\n                self.method,\n                MAX_MCP_CATALOG_BYTES\n            );\n        }\n        let cursor = result\n            .get(\"nextCursor\")\n            .and_then(|value| value.as_str())\n            .map(str::to_owned);\n        if let Some(cursor) = cursor.as_ref()\n            && !self.seen_cursors.insert(cursor.clone())","sourceCodeStart":1480,"sourceCodeEnd":1516,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/mcp.rs#L1480-L1516","documentation":"The MCP catalogue tracker also caps the total number of items (individual tools/resources across all pages) at MAX_MCP_CATALOG_ITEMS. This error is thrown when cumulative item count crosses that limit, independent of page count. Like the page cap it defends against unbounded catalogue responses flooding memory and the model context.","triggerScenarios":"track() accumulates item_count per result page and bails when self.items > MAX_MCP_CATALOG_ITEMS — a server whose aggregate catalogue exceeds the item ceiling, even if pages stay within MAX_MCP_CATALOG_PAGES.","commonSituations":"Server exposing thousands of tools/resources; a gateway aggregating many backend servers into one huge catalogue; compact limits set for context-budget reasons exceeded by a legitimately large server.","solutions":["Trim the server's exposed tools/resources below the item limit","Raise MAX_MCP_CATALOG_ITEMS if the large catalogue is trusted and desired","Split the catalogue across multiple MCP servers with smaller, focused tool sets"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match discovery_result {\n    Err(e) if e.to_string().contains(\"-item catalogue limit\") => {\n        eprintln!(\"Server exposes more items than allowed; split the server or raise MAX_MCP_CATALOG_ITEMS.\");\n    }\n    Ok(catalogue) => use_catalogue(catalogue),\n    other => other?,\n}","preventionTips":["Split gateway servers aggregating many backends into separate, smaller MCP servers","Only enable tools you actually use (server-side filtering) to stay under the item cap","Track item counts in your own tooling when aggregating multiple MCP servers into one client"],"tags":["mcp","limit","resource-exhaustion"],"backgroundTag":"payload-too-large","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}