academia-mcp 1.10.3__py3-none-any.whl → 1.10.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,6 +11,7 @@ from academia_mcp.utils import sanitize_output
11
11
  EXA_CONTENTS_URL = "https://api.exa.ai/contents"
12
12
  TAVILY_EXTRACT_URL = "https://api.tavily.com/extract"
13
13
  AVAILABLE_PROVIDERS = ("basic", "exa", "tavily")
14
+ ERROR_MESSAGE = "Failed to get content from the page. Try to use another provider."
14
15
 
15
16
 
16
17
  def _exa_visit_webpage(url: str) -> str:
@@ -21,7 +22,10 @@ def _exa_visit_webpage(url: str) -> str:
21
22
  "text": True,
22
23
  }
23
24
  response = post_with_retries(EXA_CONTENTS_URL, payload=payload, api_key=key)
24
- return sanitize_output(json.dumps(response.json()["results"][0]))
25
+ results = response.json()["results"]
26
+ if not results:
27
+ return json.dumps({"id": url, "error": ERROR_MESSAGE})
28
+ return sanitize_output(json.dumps(results[0]))
25
29
 
26
30
 
27
31
  def _tavily_visit_webpage(url: str) -> str:
@@ -31,14 +35,18 @@ def _tavily_visit_webpage(url: str) -> str:
31
35
  "urls": [url],
32
36
  }
33
37
  response = post_with_retries(TAVILY_EXTRACT_URL, payload=payload, api_key=key)
34
- return sanitize_output(json.dumps(response.json()["results"][0]["raw_content"]))
38
+ results = response.json()["results"]
39
+ if not results:
40
+ return json.dumps({"id": url, "error": ERROR_MESSAGE})
41
+ return sanitize_output(json.dumps(results[0]["raw_content"]))
35
42
 
36
43
 
37
44
  def visit_webpage(url: str, provider: Optional[str] = "basic") -> str:
38
45
  """
39
46
  Visit a webpage and return the content.
40
47
 
41
- Returns a JSON object serialized to a string. The structure is: {"url": "...", "text": "..."}
48
+ Returns a JSON object serialized to a string. The structure is: {"id": "...", "text": "..."}.
49
+ If there are errors, the structure is: {"id": "...", "error": "..."}.
42
50
  Use `json.loads` to deserialize the result if you want to get specific fields.
43
51
  Try to use both "tavily" and "basic" providers. They might work differently for the same URL.
44
52
 
@@ -58,7 +66,10 @@ def visit_webpage(url: str, provider: Optional[str] = "basic") -> str:
58
66
  provider = "basic"
59
67
 
60
68
  assert provider == "basic"
61
- response = get_with_retries(url)
69
+ try:
70
+ response = get_with_retries(url)
71
+ except Exception as e:
72
+ return json.dumps({"id": url, "error": str(e)})
62
73
  content_type = response.headers.get("content-type", "").lower()
63
74
  if not content_type or (not content_type.startswith("text/") and "html" not in content_type):
64
75
  if settings.EXA_API_KEY:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: academia-mcp
3
- Version: 1.10.3
3
+ Version: 1.10.4
4
4
  Summary: MCP server that provides different tools to search for scientific publications
5
5
  Author-email: Ilya Gusev <phoenixilya@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/IlyaGusev/academia_mcp
@@ -22,11 +22,11 @@ academia_mcp/tools/review.py,sha256=Va0lFJJKuk-NvWhKS3UZ-Dnuk7CyuDQ4S1nd70D-ffE,
22
22
  academia_mcp/tools/s2.py,sha256=QX7-pbetab3Xt_1tvVPU6o5D_NAe9y6jcTGRBK1vwtY,6200
23
23
  academia_mcp/tools/show_image.py,sha256=jiJlQ53dbZ0T61OBhCT3IKVvBl9NHc6jHgWLfg5BxiE,3856
24
24
  academia_mcp/tools/speech_to_text.py,sha256=YZzMqdvunzXkpcadP_mYhm6cs4qH1Y_42SfY-7eX4O4,1601
25
- academia_mcp/tools/visit_webpage.py,sha256=K4L8V5KB5b4mHZBWee3OBp1C9ZFI_ge-tZ3HZXxLZwA,2742
25
+ academia_mcp/tools/visit_webpage.py,sha256=5qpVRqAhpxY1Cj3Z9XKXfrpo4ujl5rzTg2UKP0-gkL8,3206
26
26
  academia_mcp/tools/web_search.py,sha256=0gKE3gtLBhdQ6G1eSgYLs1LIuo__PHwsYx5I5mTn254,6408
27
- academia_mcp-1.10.3.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
28
- academia_mcp-1.10.3.dist-info/METADATA,sha256=-MGPktQMI9OjYLCGnMvGN9kZUQN8qGeGBFA1L8dWeZ4,6311
29
- academia_mcp-1.10.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
30
- academia_mcp-1.10.3.dist-info/entry_points.txt,sha256=gxkiKJ74w2FwJpSECpjA3XtCfI5ZfrM6N8cqnwsq4yY,51
31
- academia_mcp-1.10.3.dist-info/top_level.txt,sha256=CzGpRFsRRJRqWEb1e3SUlcfGqRzOxevZGaJWrtGF8W0,13
32
- academia_mcp-1.10.3.dist-info/RECORD,,
27
+ academia_mcp-1.10.4.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
28
+ academia_mcp-1.10.4.dist-info/METADATA,sha256=xuW7O6KvZ4q6LFZ-FMiSOf77dYKIjuYG_ySglOQxQvU,6311
29
+ academia_mcp-1.10.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
30
+ academia_mcp-1.10.4.dist-info/entry_points.txt,sha256=gxkiKJ74w2FwJpSECpjA3XtCfI5ZfrM6N8cqnwsq4yY,51
31
+ academia_mcp-1.10.4.dist-info/top_level.txt,sha256=CzGpRFsRRJRqWEb1e3SUlcfGqRzOxevZGaJWrtGF8W0,13
32
+ academia_mcp-1.10.4.dist-info/RECORD,,