File size: 677 Bytes
169858b
f62a8d2
169858b
aae312e
169858b
 
 
 
 
 
 
 
 
 
 
 
 
 
ee63964
169858b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 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