Skip to main content
Glama

read_paper

Access the full content of arXiv papers in markdown format by providing the paper ID, enabling easy reading and integration into workflows.

Instructions

Read the full content of a stored paper in markdown format

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paper_idYesThe arXiv ID of the paper to read

Implementation Reference

  • The main handler function that executes the read_paper tool: checks if paper_id exists in storage, reads the markdown content, and returns it as JSON in TextContent.
    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)}", } ), ) ]
  • The Tool object defining the name, description, and input schema (requiring paper_id string) for the read_paper tool.
    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"], }, )
  • Helper function to list all stored paper IDs from the storage directory.
    def list_papers() -> list[str]: """List all stored paper IDs.""" return [p.stem for p in Path(settings.STORAGE_PATH).glob("*.md")]
  • Registers read_tool (schema) as part of the server's list of available tools via the MCP list_tools handler.
    @server.list_tools() async def list_tools() -> List[types.Tool]: """List available arXiv research tools.""" return [search_tool, download_tool, list_tool, read_tool]
  • Registers the handler dispatch for read_paper tool via the MCP call_tool handler, routing to handle_read_paper.
    @server.call_tool() async def call_tool(name: str, arguments: Dict[str, Any]) -> List[types.TextContent]: """Handle tool calls for arXiv research functionality.""" logger.debug(f"Calling tool {name} with arguments {arguments}") try: if name == "search_papers": return await handle_search(arguments) elif name == "download_paper": return await handle_download(arguments) elif name == "list_papers": return await handle_list_papers(arguments) elif name == "read_paper": return await handle_read_paper(arguments) else: return [types.TextContent(type="text", text=f"Error: Unknown tool {name}")] except Exception as e: logger.error(f"Tool error: {str(e)}") return [types.TextContent(type="text", text=f"Error: {str(e)}")]

Other Tools

Related Tools

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/wr-web/APR'

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