get_file
Retrieve file content from Pagure repositories by specifying project, filename, branch, and namespace parameters to access specific files.
Instructions
Get file content from a Pagure repository.
Args: project: Project name filename: File path (e.g., 'python3.spec', 'sources') branch: Branch name (default: rawhide) namespace: Project namespace (default: rpms)
Returns: File content as string
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project | Yes | ||
| filename | Yes | ||
| branch | No | rawhide | |
| namespace | No | rpms |
Implementation Reference
- src/pagure/server.py:91-112 (handler)The MCP tool registration and handler function for get_file.
@mcp.tool() async def get_file( project: str, filename: str, branch: str = "rawhide", namespace: str = "rpms", ) -> str: """Get file content from a Pagure repository. Args: project: Project name filename: File path (e.g., 'python3.spec', 'sources') branch: Branch name (default: rawhide) namespace: Project namespace (default: rpms) Returns: File content as string """ client = get_client() content = await client.get_file(project, filename, branch, namespace) return content - src/pagure/client.py:119-142 (handler)The actual implementation of the get_file logic that performs the HTTP request to the Pagure API.
async def get_file( self, project: str, filename: str, branch: str = "rawhide", namespace: str = "rpms", ) -> str: """Get file content from repository. Args: project: Project name filename: File path branch: Branch name namespace: Project namespace Returns: File content as string """ response = await self.client.get( f"{self.base_url}/{namespace}/{project}/raw/{branch}/f/{filename}", headers=self._get_headers(), ) response.raise_for_status() return response.text