Download mcp/arxiv.py from mgbam/MCP_Res: direct link, hf CLI and curl.
- Browser
- Download file 677 Bytes
-
https://huggingface.co/spaces/mgbam/MCP_Res/resolve/3cb1988088965b28563c0d8c32d2d904b3a93485/mcp/arxiv.py
- Command line
-
hf download hf://spaces/mgbam/MCP_Res@3cb1988088965b28563c0d8c32d2d904b3a93485/mcp/arxiv.py
-
curl -L -o arxiv.py https://huggingface.co/spaces/mgbam/MCP_Res/resolve/3cb1988088965b28563c0d8c32d2d904b3a93485/mcp/arxiv.py
677 Bytes
| # mcp/arxiv.py | |
| import feedparser | |
| from urllib.parse import quote_plus | |
| ARXIV_BASE = "http://export.arxiv.org/api/query?search_query=" | |
| async def fetch_arxiv(query: str, max_results: int = 5) -> list[dict]: | |
| url = f"{ARXIV_BASE}{quote_plus(query)}&max_results={max_results}" | |
| feed = feedparser.parse(url) | |
| out = [] | |
| for e in feed.entries: | |
| out.append({ | |
| "title": e.get("title",""), | |
| "authors": ", ".join([a.name for a in getattr(e,"authors",[])]), | |
| "summary": e.get("summary",""), | |
| "link": e.get("link",""), | |
| "published": getattr(e,"published",""), | |
| "source": "arXiv" | |
| }) | |
| return out | |