MCP_Res / mcp /arxiv.py
mgbam's picture
Create arxiv.py
ee63964 verified
raw
history blame
659 Bytes
# mcp/arxiv.py
import feedparser
ARXIV_BASE = "http://export.arxiv.org/api/query?search_query="
async def fetch_arxiv(query: str, max_results: int = 5):
"""Fetch latest arXiv papers for the query."""
search_url = f"{ARXIV_BASE}{query}&max_results={max_results}"
feed = feedparser.parse(search_url)
results = []
for entry in feed.entries:
results.append({
"title": entry.title,
"authors": ", ".join([a.name for a in entry.authors]),
"summary": entry.summary,
"link": entry.link,
"published": entry.published,
"source": "arXiv"
})
return results