download_paper
Download cryptographic research papers from the IACR Cryptology ePrint Archive in PDF or TXT formats by specifying the paper ID and desired format.
Instructions
Download a paper in PDF or TXT format
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| format | No | ||
| paper_id | Yes |
Input Schema (JSON Schema)
{
"properties": {
"format": {
"default": "pdf",
"enum": [
"pdf",
"txt"
],
"type": "string"
},
"paper_id": {
"type": "string"
}
},
"required": [
"paper_id"
],
"type": "object"
}
Implementation Reference
- src/index.ts:251-273 (handler)The main handler function for the 'download_paper' tool. It validates input using DownloadPaperSchema, fetches the paper from eprint.iacr.org in the specified format (pdf or txt), encodes it as base64, and returns it as a file artifact.private async downloadPaper(args: unknown) { const validatedArgs = DownloadPaperSchema.parse(args); try { const response = await axios.get(`https://eprint.iacr.org/${validatedArgs.paper_id}.${validatedArgs.format}`, { responseType: 'arraybuffer' }); return { content: [{ type: 'file', name: `${validatedArgs.paper_id}.${validatedArgs.format}`, data: response.data.toString('base64') }] }; } catch (error) { console.error('Paper Download Error:', error); throw new McpError( ErrorCode.InternalError, `Paper download failed: ${error instanceof Error ? error.message : 'Unknown error'}` ); } }
- src/index.ts:30-33 (schema)Zod schema defining the input parameters for the download_paper tool: paper_id (required string), format (optional enum ['pdf', 'txt'] defaulting to 'pdf'). Used for validation in the handler.const DownloadPaperSchema = z.object({ paper_id: z.string(), format: z.enum(['pdf', 'txt']).optional().default('pdf') });
- src/index.ts:92-107 (registration)Tool registration in the ListTools response, providing the name 'download_paper', description, and inputSchema matching the Zod schema.{ name: 'download_paper', description: 'Download a paper in PDF or TXT format', inputSchema: { type: 'object', properties: { paper_id: { type: 'string' }, format: { type: 'string', enum: ['pdf', 'txt'], default: 'pdf' } }, required: ['paper_id'] } }
- src/index.ts:118-119 (registration)Dispatch logic in the CallTool request handler switch statement that routes 'download_paper' calls to the downloadPaper method.case 'download_paper': return this.downloadPaper(request.params.arguments);