get_arxiv_pdf_url
Retrieve direct PDF download links for arXiv research papers by providing the paper URL or arXiv ID, enabling quick access to scientific literature.
Instructions
获取 arXiv PDF 下载链接
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input | Yes | arXiv 论文URL(如:http://arxiv.org/abs/2403.15137v1)或 arXiv ID(如:2403.15137v1) |
Implementation Reference
- src/index.ts:163-182 (handler)The core handler function that takes an arXiv paper URL or ID and returns the corresponding PDF download URL.function getArxivPdfUrl(input: string): string { try { let arxivId: string; let pdfUrl: string; if (input.startsWith('http://') || input.startsWith('https://')) { const urlParts = input.split('/'); arxivId = urlParts[urlParts.length - 1]; pdfUrl = input.replace('/abs/', '/pdf/') + '.pdf'; } else { arxivId = input; pdfUrl = `http://arxiv.org/pdf/${arxivId}.pdf`; } return pdfUrl; } catch (error) { console.error("获取 PDF 链接时出错:", error); throw new Error(`获取PDF链接失败: ${error instanceof Error ? error.message : String(error)}`); } }
- src/index.ts:425-435 (registration)The dispatch case in the CallToolRequestSchema handler that invokes the getArxivPdfUrl function and formats the response.case "get_arxiv_pdf_url": { const { input } = args as { input: string }; const pdfUrl = getArxivPdfUrl(input); return { content: [{ type: "text", text: `PDF 下载链接: ${pdfUrl}` }] }; }
- src/index.ts:353-364 (schema)The tool schema definition including name, description, and input schema, registered in the ListToolsRequestSchema handler.name: "get_arxiv_pdf_url", description: "获取 arXiv PDF 下载链接", inputSchema: { type: "object", properties: { input: { type: "string", description: "arXiv 论文URL(如:http://arxiv.org/abs/2403.15137v1)或 arXiv ID(如:2403.15137v1)" } }, required: ["input"] }
- src/index.ts:352-365 (registration)Full tool registration object in the tools list for ListToolsRequest.{ name: "get_arxiv_pdf_url", description: "获取 arXiv PDF 下载链接", inputSchema: { type: "object", properties: { input: { type: "string", description: "arXiv 论文URL(如:http://arxiv.org/abs/2403.15137v1)或 arXiv ID(如:2403.15137v1)" } }, required: ["input"] } },