Skip to main content
Glama
hofill
by hofill

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
NameRequiredDescriptionDefault
pathYes
decode_base64No
max_bytesNo

Implementation Reference

  • 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),
            ),
        }
  • 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

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/hofill/RequestRepo-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server