Skip to content

[mcp] Add escalations_get tool with pagination defaults#351

Closed
rahul-roy-glean wants to merge 1 commit into
mainfrom
cursor/escalations-get-pagination-fc28
Closed

[mcp] Add escalations_get tool with pagination defaults#351
rahul-roy-glean wants to merge 1 commit into
mainfrom
cursor/escalations-get-pagination-fc28

Conversation

@rahul-roy-glean
Copy link
Copy Markdown

Description

Adds a new escalations_get MCP tool with built-in pagination (limit/offset) and a default limit of 50 to prevent unbounded response sizes.

Related Issue

Slack report: escalations_get is called with empty params {}, returning a 21MB response body. This PR adds the tool with safe defaults so empty params return a bounded result set.

Motivation and Context

The escalations_get tool existed on the remote Glean MCP server but was missing from the local MCP server. When called with {}, the remote version returns every escalation (~21MB). This change:

  1. Adds the tool to the local MCP server
  2. Enforces a default limit=50 (max 100), so empty {} calls return a bounded result
  3. Adds offset for pagination, allowing callers to page through results when needed
  4. Keeps the tool surface minimal — all params are optional with sensible defaults

This is the "smallest safe change" approach: default limit first, explicit pagination via offset as an escape hatch.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring
  • Build/CI pipeline changes
  • Other (please describe):

How Has This Been Tested?

  • Unit tests
  • Integration tests
  • Manual testing
  • Other (please describe):

Tests added:

  • src/test/tools/escalations.test.ts — 15 tests covering schema validation (JSON schema snapshot, empty params, query, limit/offset, rejection of invalid values), API integration (default pagination, query filtering, offset pagination), and response formatting (empty results, null, normal results, pagination hints, description truncation)
  • server.test.ts — 3 integration tests for end-to-end tool execution via callToolHandler (default pagination, query filter, pagination with hasMoreResults)
  • MSW mock handler in mcp-test-utils for POST /rest/api/v1/escalations

Checklist

  • My code follows the code style of this project
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • I have checked for potential breaking changes and addressed them

Additional Notes

No existing flows are brokenescalations_get is a net-new tool in the local MCP server. The remote MCP server's equivalent tool is unaffected since this change only touches the local server.

Files changed:

  • packages/local-mcp-server/src/tools/escalations.ts — New tool implementation (schema, API call via raw fetch, response formatter)
  • packages/local-mcp-server/src/server.ts — Register tool in TOOL_NAMES, listToolsHandler, and callToolHandler
  • packages/mcp-test-utils/src/mocks/handlers.ts — MSW mock for the escalations endpoint
  • packages/local-mcp-server/src/test/tools/escalations.test.ts — Unit tests
  • packages/local-mcp-server/src/test/server.test.ts — Integration tests

Slack Thread

Open in Web Open in Cursor 

Adds a new escalations_get MCP tool that addresses the 21MB response
problem when the tool is called with empty params ({}).

Key changes:
- New tool: escalations_get with limit (default 50, max 100) and offset
  parameters, preventing unbounded fetches
- All params are optional; empty {} now defaults to limit=50 instead
  of returning everything
- Query parameter for filtering escalations by text search
- Response formatting with truncated descriptions and pagination hints
- MSW mock handler in mcp-test-utils for the /rest/api/v1/escalations
  endpoint
- Unit tests covering schema validation, API integration, response
  formatting, and pagination
- Integration tests in server.test.ts for end-to-end tool execution

Co-authored-by: Rahul Roy <rahul-roy-glean@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants