get_merge_request API response exceeds token limit for large MRs
Issue Description
When using the get_merge_request MCP function on merge requests with extensive content (many files, large diffs, or numerous discussions), the response exceeds the maximum allowed token limit of 25,000 tokens.
Error Details
Error: MCP tool "get_merge_request" response (25853 tokens) exceeds maximum allowed tokens (25000).
Please use pagination, filtering, or limit parameters to reduce the response size.
Reproduction Steps
- Use the
get_merge_requestfunction on a merge request with:- Multiple file changes
- Large diffs
- Extensive discussions/comments
- Example call that triggers the error:
mcp__GitLab__get_merge_request(project_id: "71424686", merge_request_iid: 7)
Expected Behavior
The function should either:
- Automatically paginate or truncate the response to stay within token limits
- Provide parameters to control the response size (e.g., exclude diffs, limit discussions)
- Split the response into multiple parts that can be retrieved separately
Suggested Solutions
-
Add optional parameters to control response content:
get_merge_request( project_id: string, merge_request_iid: number, options?: { include_diffs?: boolean, // default: true include_discussions?: boolean, // default: true diff_limit?: number, // limit number of diff entries discussion_limit?: number // limit number of discussions } ) -
Implement automatic response truncation:
- Detect when response would exceed token limit
- Prioritize essential information (MR metadata, status)
- Indicate that content was truncated
-
Provide separate endpoints for large content:
-
get_merge_request_metadata- Just the MR info without diffs/discussions - Keep existing
list_merge_request_diffsfor diff content - Keep existing
discussion_listfor discussions
-
Environment
- MCP Tool: gitlab-mcp
- Use case: Code review on large merge requests
- Token limit: 25,000
Impact
This limitation prevents proper code review and MR analysis for substantial changes, which are common in real-world development scenarios.
Related
This issue particularly affects development tools and AI assistants that need to analyze complete merge request content for code reviews.