get_arxiv_pdf_url
Extract direct PDF download links from arXiv paper URLs or IDs to access academic research documents.
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 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:352-365 (schema)The input schema and metadata definition for the 'get_arxiv_pdf_url' tool, registered in the ListTools 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:425-435 (registration)The registration block in the main CallToolRequestSchema handler that dispatches to 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:275-275 (helper)Usage of getArxivPdfUrl as a helper function within the parse_paper_content tool.const pdfUrl = getArxivPdfUrl(input);