read_paper
Access and read the complete content of arXiv research papers in markdown format using their unique paper ID.
Instructions
Read the full content of a stored paper in markdown format
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| paper_id | Yes | The arXiv ID of the paper to read |
Implementation Reference
- The main handler function that executes the read_paper tool: validates paper existence, reads markdown content from storage, and returns JSON-wrapped result.async def handle_read_paper(arguments: Dict[str, Any]) -> List[types.TextContent]: """Handle requests to read a paper's content.""" try: paper_ids = list_papers() paper_id = arguments["paper_id"] # Check if paper exists if paper_id not in paper_ids: return [ types.TextContent( type="text", text=json.dumps( { "status": "error", "message": f"Paper {paper_id} not found in storage. You may need to download it first using download_paper.", } ), ) ] # Get paper content content = Path(settings.STORAGE_PATH, f"{paper_id}.md").read_text( encoding="utf-8" ) return [ types.TextContent( type="text", text=json.dumps( { "status": "success", "paper_id": paper_id, "content": content, } ), ) ] except Exception as e: return [ types.TextContent( type="text", text=json.dumps( { "status": "error", "message": f"Error reading paper: {str(e)}", } ), ) ]
- Defines the input schema for the read_paper tool, specifying the required 'paper_id' parameter.read_tool = types.Tool( name="read_paper", description="Read the full content of a stored paper in markdown format", inputSchema={ "type": "object", "properties": { "paper_id": { "type": "string", "description": "The arXiv ID of the paper to read", } }, "required": ["paper_id"], }, )
- src/arxiv_mcp_server/server.py:41-44 (registration)Registers the read_paper tool (as read_tool) in the MCP server's list_tools() method.@server.list_tools() async def list_tools() -> List[types.Tool]: """List available arXiv research tools.""" return [search_tool, download_tool, list_tool, read_tool]
- src/arxiv_mcp_server/server.py:58-59 (registration)Dispatches calls to the 'read_paper' tool to the handle_read_paper handler in the MCP server's call_tool() method.elif name == "read_paper": return await handle_read_paper(arguments)
- Helper function to list all stored paper IDs, used by the handler to check existence.def list_papers() -> list[str]: """List all stored paper IDs.""" return [p.stem for p in Path(settings.STORAGE_PATH).glob("*.md")]