Update app.py
Browse files
app.py
CHANGED
|
@@ -263,35 +263,14 @@ def Fetch_Webpage( # <-- MCP tool #1 (Fetch)
|
|
| 263 |
Fetch a web page and return a compact Markdown summary containing title, key
|
| 264 |
metadata, readable main text, and outbound links.
|
| 265 |
|
| 266 |
-
This function powers the MCP tool "Fetch_Webpage". Descriptions below are
|
| 267 |
-
provided explicitly for MCP clients that surface parameter help.
|
| 268 |
-
|
| 269 |
Args:
|
| 270 |
-
url (
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
- "Full" (no practical cap apart from max_chars)
|
| 278 |
-
Default: "Standard".
|
| 279 |
-
include_metadata (bool, optional):
|
| 280 |
-
If True, include a Metadata section with description, site name,
|
| 281 |
-
canonical URL, language, and fetched URL. Default: True.
|
| 282 |
-
include_text (bool, optional):
|
| 283 |
-
If True, include the readable main text extracted with Readability.
|
| 284 |
-
Default: True.
|
| 285 |
-
include_links (bool, optional):
|
| 286 |
-
If True, include outbound links discovered in the readable section
|
| 287 |
-
of the page. Default: True.
|
| 288 |
-
max_chars (int, optional):
|
| 289 |
-
Hard maximum number of characters for the body text, applied after
|
| 290 |
-
the verbosity preset. Use 0 or a negative value to disable the cap
|
| 291 |
-
(the verbosity preset will still apply). Default: 3000.
|
| 292 |
-
max_links (int, optional):
|
| 293 |
-
Maximum number of links to include. Set 0 to omit links even if
|
| 294 |
-
include_links=True. Default: 20.
|
| 295 |
|
| 296 |
Returns:
|
| 297 |
str: Markdown that may contain the following sections:
|
|
@@ -299,12 +278,6 @@ def Fetch_Webpage( # <-- MCP tool #1 (Fetch)
|
|
| 299 |
- Metadata (optional)
|
| 300 |
- Text (optional, may be trimmed)
|
| 301 |
- Links (optional, deduped and absolute)
|
| 302 |
-
|
| 303 |
-
Notes:
|
| 304 |
-
- Only HTML content types are supported. Non-HTML responses return a
|
| 305 |
-
short message indicating the unsupported content type.
|
| 306 |
-
- Link text is shortened to keep tokens small; URLs are absolute and
|
| 307 |
-
fragments are removed.
|
| 308 |
"""
|
| 309 |
if not url or not url.strip():
|
| 310 |
return "Please enter a valid URL."
|
|
@@ -379,32 +352,17 @@ def Search_DuckDuckGo( # <-- MCP tool #2 (DDG Search)
|
|
| 379 |
Run a DuckDuckGo search and return ultra-compact JSONL with short keys to
|
| 380 |
minimize tokens.
|
| 381 |
|
| 382 |
-
This function powers the MCP tool "Search_DuckDuckGo". Each line in the
|
| 383 |
-
output is a JSON object using short keys to reduce token usage.
|
| 384 |
-
|
| 385 |
Args:
|
| 386 |
-
query (
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
If True, includes a short snippet for each result (key "s"). This
|
| 393 |
-
increases tokens. Default: False.
|
| 394 |
-
max_snippet_chars (int, optional):
|
| 395 |
-
Character cap applied to each snippet when include_snippets=True.
|
| 396 |
-
Default: 80.
|
| 397 |
-
dedupe_domains (bool, optional):
|
| 398 |
-
If True, only the first result from each domain is kept. Default: True.
|
| 399 |
-
title_chars (int, optional):
|
| 400 |
-
Character cap applied to titles. Default: 80.
|
| 401 |
|
| 402 |
Returns:
|
| 403 |
str: Newline-delimited JSON (JSONL). Each line has:
|
| 404 |
{"t": "title", "u": "url"[, "s": "snippet"]}
|
| 405 |
-
|
| 406 |
-
Error Handling:
|
| 407 |
-
On search errors, returns a single JSON object with an "error" key.
|
| 408 |
"""
|
| 409 |
if not query or not query.strip():
|
| 410 |
return ""
|
|
@@ -452,21 +410,12 @@ def Execute_Python(code: Annotated[str, "Python source code to run; stdout is ca
|
|
| 452 |
"""
|
| 453 |
Execute arbitrary Python code and return captured stdout or an error message.
|
| 454 |
|
| 455 |
-
This function powers the MCP tool "Execute_Python" and mirrors the
|
| 456 |
-
standalone code interpreter behavior used in the UI tab.
|
| 457 |
-
|
| 458 |
Args:
|
| 459 |
-
code
|
| 460 |
-
The Python source code to run. The code executes in a single call
|
| 461 |
-
with a fresh global scope. Prints are captured and returned.
|
| 462 |
|
| 463 |
Returns:
|
| 464 |
str: Combined stdout produced by the code, or the exception text if
|
| 465 |
execution failed.
|
| 466 |
-
|
| 467 |
-
Security:
|
| 468 |
-
The code executes within the current Python process. Do not run
|
| 469 |
-
untrusted code in environments where it could access sensitive data.
|
| 470 |
"""
|
| 471 |
if code is None:
|
| 472 |
return "No code provided."
|
|
|
|
| 263 |
Fetch a web page and return a compact Markdown summary containing title, key
|
| 264 |
metadata, readable main text, and outbound links.
|
| 265 |
|
|
|
|
|
|
|
|
|
|
| 266 |
Args:
|
| 267 |
+
url: The absolute URL to fetch (must return HTML).
|
| 268 |
+
verbosity: Controls body length: one of 'Brief', 'Standard', or 'Full'.
|
| 269 |
+
include_metadata: Include a Metadata section (description, site name, canonical, lang, fetched URL).
|
| 270 |
+
include_text: Include the readable main text extracted with Readability.
|
| 271 |
+
include_links: Include outbound links discovered in the readable section.
|
| 272 |
+
max_chars: Hard cap for body characters after the verbosity preset. Use 0 to disable the cap.
|
| 273 |
+
max_links: Maximum number of links to include from the readable content. Set 0 to omit links.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 274 |
|
| 275 |
Returns:
|
| 276 |
str: Markdown that may contain the following sections:
|
|
|
|
| 278 |
- Metadata (optional)
|
| 279 |
- Text (optional, may be trimmed)
|
| 280 |
- Links (optional, deduped and absolute)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 281 |
"""
|
| 282 |
if not url or not url.strip():
|
| 283 |
return "Please enter a valid URL."
|
|
|
|
| 352 |
Run a DuckDuckGo search and return ultra-compact JSONL with short keys to
|
| 353 |
minimize tokens.
|
| 354 |
|
|
|
|
|
|
|
|
|
|
| 355 |
Args:
|
| 356 |
+
query: The search query (supports operators like site:, quotes, OR).
|
| 357 |
+
max_results: Number of results to return (1–20).
|
| 358 |
+
include_snippets: Include a short snippet for each result (adds tokens).
|
| 359 |
+
max_snippet_chars: Character cap applied to each snippet when included.
|
| 360 |
+
dedupe_domains: If true, only the first result from each domain is kept.
|
| 361 |
+
title_chars: Character cap applied to titles.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 362 |
|
| 363 |
Returns:
|
| 364 |
str: Newline-delimited JSON (JSONL). Each line has:
|
| 365 |
{"t": "title", "u": "url"[, "s": "snippet"]}
|
|
|
|
|
|
|
|
|
|
| 366 |
"""
|
| 367 |
if not query or not query.strip():
|
| 368 |
return ""
|
|
|
|
| 410 |
"""
|
| 411 |
Execute arbitrary Python code and return captured stdout or an error message.
|
| 412 |
|
|
|
|
|
|
|
|
|
|
| 413 |
Args:
|
| 414 |
+
code: Python source code to run; stdout is captured and returned.
|
|
|
|
|
|
|
| 415 |
|
| 416 |
Returns:
|
| 417 |
str: Combined stdout produced by the code, or the exception text if
|
| 418 |
execution failed.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 419 |
"""
|
| 420 |
if code is None:
|
| 421 |
return "No code provided."
|