mgbam commited on
Commit
83ccb99
·
verified ·
1 Parent(s): 517de74

Update mcp/arxiv.py

Browse files
Files changed (1) hide show
  1. mcp/arxiv.py +3 -1
mcp/arxiv.py CHANGED
@@ -1,12 +1,14 @@
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:
 
1
  # mcp/arxiv.py
2
 
3
  import feedparser
4
+ from urllib.parse import quote_plus
5
 
6
  ARXIV_BASE = "http://export.arxiv.org/api/query?search_query="
7
 
8
  async def fetch_arxiv(query: str, max_results: int = 5):
9
  """Fetch latest arXiv papers for the query."""
10
+ encoded_query = quote_plus(query) # Ensures spaces become +, etc.
11
+ search_url = f"{ARXIV_BASE}{encoded_query}&max_results={max_results}"
12
  feed = feedparser.parse(search_url)
13
  results = []
14
  for entry in feed.entries: