Implement get_repository_file MCP Tool and service
Proposal
Add support for new MCP tool: get_repository_file as a custom tool that enhances the standard Repository Files API - Get file from repository with line range functionality and multiple file support.
Custom Tool Features
- Support for multiple file paths in a single request
- Line range functionality for retrieving specific portions of files
- Intelligent file truncation with helpful prompts for accessing more content
- Custom prompt system to guide users when files are truncated
API Parameters
The custom tool will accept the following parameters:
"file_paths": "Array (required)",
"line_start": "integer (optional)",
"line_end": "integer (optional)",
"max_lines": "integer (optional, default: 100)"
File Truncation Behavior
When files are truncated, the tool will provide helpful guidance:
File truncated. To view more content, use:
- Lines 101-200: {"line_start": 101, "line_end": 200}
- Lines around specific area: {"line_start": 250, "line_end": 300}
- Remaining lines: 350 lines available
Requirements
- Ensure Duo Context Exclusion is respected for this tool
- Implement custom backend logic to handle line range functionality
- Support array of file paths for batch file retrieval
- Provide intelligent truncation with user-friendly prompts
Technical Notes
Note: Line range functionality exists for git blame but not for file retrieval. This implementation will require custom logic beyond the standard API mapping approach to provide enhanced file access capabilities.
Edited by Nathan Weinshenker