perf+docs: cut list_incidents token usage — pagination hint + Code Mode as default#151
Open
spencerhcheng wants to merge 5 commits into
Open
perf+docs: cut list_incidents token usage — pagination hint + Code Mode as default#151spencerhcheng wants to merge 5 commits into
spencerhcheng wants to merge 5 commits into
Conversation
spencerhcheng
force-pushed
the
feat/list-incidents-pagination-hint
branch
from
June 30, 2026 19:09
45db5c3 to
d94223e
Compare
…ination Some clients walk the full incident history one tiny page at a time (e.g. page_size=1), turning a bounded fetch into hundreds of tool calls — a single sweep of 281 incidents at page_size=1 is 281 calls. When list_incidents is called with a below-default page_size against a result set large enough to require many paginated calls, the response now includes an advisory `_use_tool` hint steering callers to collect_incidents (bulk fetch in one call), a larger page_size, or narrowing filters. This matches the existing `_use_tool` convention used for the alert-routing deprecation. The hint is non-breaking: it does not alter the returned data, status, or pagination — it is purely advisory, so existing clients are unaffected. - tools/incidents.py: _pagination_efficiency_hint helper + wiring into list_incidents (fires only when page_size < 25, has_more, and the sweep would exceed 5 paginated calls). - tests: direct coverage of the hint's boundary conditions plus list_incidents integration (fires at page_size=1, silent at default).
Code Mode (/mcp-codemode) exposes a compact set of meta-tools (list_tools, tool_search, get_schema, tags, execute) instead of ~200 individual tools, and lets the model chain multiple call_tool() calls server-side in a single execute block. That means dramatically lower token usage (a handful of tool schemas re-sent per turn instead of hundreds) and fewer round-trips for multi-step work — verified working end-to-end, including OAuth2 (identical challenge to the classic endpoint). - Lead the hosted transport options with Code Mode (recommended) + a rationale callout; demote plain Streamable HTTP / SSE to alternatives. - Lead the general remote setup and Claude Code quick-add with the /mcp-codemode URL; keep the classic one-tool-per-operation endpoints documented for clients that can't use the execute sandbox.
spencerhcheng
force-pushed
the
feat/list-incidents-pagination-hint
branch
from
July 23, 2026 22:23
d59622c to
050ae63
Compare
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.
Two complementary changes that reduce token usage for the hosted Rootly MCP, consolidated into one PR.
1. Pagination efficiency hint (
list_incidents)MCPCat/Datadog traces show clients walking the full incident history one tiny page at a time (
page_size=1) — a single sweep of 281 incidents = 281 tool calls. Whenlist_incidentsis called with a below-defaultpage_sizeagainst a result set large enough to require many paginated calls, the response now includes an advisory_use_toolhint steering the caller tocollect_incidents(bulk fetch in one call), a largerpage_size, or filters. Reuses the existing_use_toolconvention.page_size < 25andhas_moreand the sweep would exceed 5 paginated calls.tools/incidents.py:_pagination_efficiency_hinthelper + wiring; tests cover all boundary conditions and thelist_incidentsintegration.2. Recommend Code Mode as the default hosted endpoint (README)
Code Mode (
/mcp-codemode) exposes a compact set of meta-tools (list_tools,tool_search,get_schema,tags,execute) instead of ~200 individual tools, and lets the model chaincall_tool()calls server-side in oneexecuteblock — dramatically lower token usage and fewer round-trips. Verified end-to-end including OAuth2 and Claude Desktop's tool-discovery flow./mcp-codemode.execute, losing the savings.Testing
(Supersedes #152, which is folded in here.)