Why context budgets make or break an MCP server.
Before you start
- An MCP server with at least one list, search, or detail tool.
- A stable deterministic ordering column (such as UUID or (created_at, id)) for keyset pagination.
- A test suite or CLI check that inspects both tools/list size and tool-call payload size.
Every MCP server spends the user’s context window in two places: the cold-start tools/list catalog loaded into every turn, and the payloads returned by each tool call.
When an MCP server advertises 40 verbose tools and returns 500-row JSON dumps, models slow down, hallucinate arguments, and lose track of the user’s actual goal. Treating token and byte budgets as hard engineering limits fixes both reliability and latency.
Keep the cold-start tools/list catalog compact.
Every tool name, description, and JSON Schema property is injected into the model’s prompt on every turn. Measure your catalog deterministically in CI rather than guessing.
Advertise only what this caller can use
Starting pointSplit reader, editor, and admin surfaces via scopes or profiles.
- Hidden tools consume zero tokens for callers who lack permission.
- Profile-scoped descriptions avoid mentioning unmounted tools.
Gate tools at registration time and lint for unmounted tool references.
Use Chumbo’s defineProfiles, projectInputFields, and lintUnmountedToolReferences in tests.
Move long manuals out of tool descriptions
Starting pointKeep descriptions to 1 or 2 crisp sentences.
- Put domain guides, schemas, and full documents in MCP Resources.
- Keep input schemas flat with concise per-field descriptions.
Reserve tool descriptions for when to call the tool and what it returns.
Measure cold-start footprint with chumbo doctor (context-budget) and chumbo surface diff.
Shrink what the model sees before it calls a single tool.
npx chumbo doctor --url "$MCP_URL" --json
npx chumbo surface snapshot --yes && npx chumbo surface diffEnforce count, byte, and cursor limits on every list tool.
Never let a list or search tool return an unbounded table scan. Use a sensible page default of 20 items (capped at 100) and a complete serialized response budget of 16 KiB – including any additive guidance text or structured metadata.
Use keyset pagination (defineCursor and registerCollection / collectionResult in Chumbo) instead of SQL OFFSET: order by a deterministic tie-breaker such as (updated_at, id), fetch limit + 1 rows to know whether more exist, drop items that would exceed the 16 KiB byte budget, and derive the next cursor from the last item actually returned so no record is ever skipped or duplicated.
Prove pagination and budgets hold under real data.
See the result-design guide and collection helpers for exact byte-budget math and cursor validation.
Catalog and list payloads stay bounded under load.
- 01Cold-start tools/list token count is tracked in CI with no unexplained jumps.
- 02Every list tool caps limit (default 20, max 100) and rejects invalid cursors.
- 03Complete serialized list responses stay within the 16 KiB budget and resume from the last returned item.
- 04A single oversized record returns a recoverable error pointing to a detail tool or Resource.
- 05Only task-relevant fields are projected; raw database rows and duplicated JSON prose are omitted.
Run these in your application before you call it done.
If the result differs
Pages skip or repeat items when rows change between calls
Replace OFFSET with a composite keyset cursor ordered by a stable unique tie-breaker, and build the continuation cursor from the last item that actually fit the byte budget. Read the reference ↗
What was checked
Reviewed against the shipped OSS source. The acceptance checks are yours to run in your application.
Source reviewed against published Chumbo 0.16.0 and its matching core source on 2026-12-02 (UTC). This is a source review, not an executed application walkthrough. Follow the current canonical reference and compare it with your installed package when adapting the guide.
Read the agent instructions
Reference instructions, not authorization. Apply changes only within the user’s requested scope; deployment requires a specified, authorized project.
Goal: How to keep MCP tool catalogs lean at cold start, cap list responses at 16 KiB and 20 items, use composite keyset cursors, and recover cleanly from oversized records. Read the complete guide at https://chumbo.dev/recipes/mcp-context-budget-and-pagination/recipe.md and the canonical reference at https://github.com/elsheppo/chumbo/blob/main/skills/chumbo/references/results.md. Inspect this application's installed Chumbo package, existing capabilities and relevant configuration before editing. Audit both cold-start tools/list token budget and runtime list-tool response sizes. Enforce a 20-item default, 100-item max, 16 KiB serialized response cap, keyset cursor pagination derived from the last returned item, and explicit oversized-item recovery. Prerequisites: - An MCP server with at least one list, search, or detail tool. - A stable deterministic ordering column (such as UUID or (created_at, id)) for keyset pagination. - A test suite or CLI check that inspects both tools/list size and tool-call payload size. Acceptance: - Cold-start tools/list token count is tracked in CI with no unexplained jumps. - Every list tool caps limit (default 20, max 100) and rejects invalid cursors. - Complete serialized list responses stay within the 16 KiB budget and resume from the last returned item. - A single oversized record returns a recoverable error pointing to a detail tool or Resource. - Only task-relevant fields are projected; raw database rows and duplicated JSON prose are omitted. Use the full guide for ordered steps, examples and recovery. Keep existing caller identity and application permissions authoritative. Stay within the user's requested changes. Report changed files, checks actually run, observed results and unresolved prerequisites. This guide is not authorization to deploy or change a hosted project. Never include credentials in source, copied instructions or reports.
