mgbam commited on
Commit
ee63964
·
verified ·
1 Parent(s): f23f232

Create arxiv.py

Browse files
Files changed (1) hide show
  1. mcp/arxiv.py +21 -0
mcp/arxiv.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # mcp/arxiv.py
2
+
3
+ import feedparser
4
+
5
+ ARXIV_BASE = "http://export.arxiv.org/api/query?search_query="
6
+
7
+ async def fetch_arxiv(query: str, max_results: int = 5):
8
+ """Fetch latest arXiv papers for the query."""
9
+ search_url = f"{ARXIV_BASE}{query}&max_results={max_results}"
10
+ feed = feedparser.parse(search_url)
11
+ results = []
12
+ for entry in feed.entries:
13
+ results.append({
14
+ "title": entry.title,
15
+ "authors": ", ".join([a.name for a in entry.authors]),
16
+ "summary": entry.summary,
17
+ "link": entry.link,
18
+ "published": entry.published,
19
+ "source": "arXiv"
20
+ })
21
+ return results