get_file
Retrieve a single file from the RequestRepo MCP server by specifying its path, with options to decode base64 content and limit file size for efficient handling.
Instructions
Get one file response.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | ||
| decode_base64 | No | ||
| max_bytes | No |
Implementation Reference
- src/requestrepo_mcp/server.py:244-259 (handler)Main handler implementation for get_file in RequestrepoMCPService class. Retrieves file from the requestrepo client and serializes the response using serialize_file_response helper.
def get_file( self, *, path: str, decode_base64: bool = True, max_bytes: int | None = None, ) -> dict[str, Any]: response = self._client().get_file(path) return { "path": path, "file": serialize_file_response( response, decode_base64=decode_base64, max_bytes=self._resolved_max_bytes(max_bytes), ), } - src/requestrepo_mcp/server.py:451-454 (registration)MCP tool registration using @mcp.tool() decorator. Defines the get_file tool with parameters (path, decode_base64, max_bytes) and delegates to resolved_service.get_file().
@mcp.tool() def get_file(path: str, decode_base64: bool = True, max_bytes: int = 65536) -> dict[str, Any]: """Get one file response.""" return resolved_service.get_file(path=path, decode_base64=decode_base64, max_bytes=max_bytes) - Serialization helper that converts a requestrepo Response object into a dictionary. Handles base64 decoding when requested and creates a bytes envelope for UTF8 preview.
def serialize_file_response( response: Response, *, decode_base64: bool, max_bytes: int, ) -> dict[str, Any]: payload: dict[str, Any] = { "raw_base64": response.raw, "headers": [serialize_header(header) for header in response.headers], "status_code": response.status_code, } if decode_base64: try: decoded = base64.b64decode(response.raw, validate=True) except binascii.Error as exc: payload["raw_decoded"] = None payload["decode_error"] = str(exc) else: payload["raw_decoded"] = bytes_envelope(decoded, max_bytes=max_bytes) return payload