Nymbo commited on
Commit
8ef3df1
·
verified ·
1 Parent(s): a38cce7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +87 -6
app.py CHANGED
@@ -260,10 +260,51 @@ def Fetch_Webpage( # <-- MCP tool #1 (Fetch)
260
  max_links: int = 20,
261
  ) -> str:
262
  """
263
- Fetch a web page and return a compact Markdown summary that includes title, key
264
  metadata, readable main text, and outbound links.
265
 
266
- (Layman's terms: summarize a page with clean text + useful details.)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
267
  """
268
  if not url or not url.strip():
269
  return "Please enter a valid URL."
@@ -335,10 +376,35 @@ def Search_DuckDuckGo( # <-- MCP tool #2 (DDG Search)
335
  title_chars: int = 80,
336
  ) -> str:
337
  """
338
- Run a DuckDuckGo search and return ultra-compact JSONL lines with short keys to
339
  minimize tokens.
340
 
341
- (Layman's terms: the tiniest useful search output possible.)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
342
  """
343
  if not query or not query.strip():
344
  return ""
@@ -384,8 +450,23 @@ def Search_DuckDuckGo( # <-- MCP tool #2 (DDG Search)
384
 
385
  def Execute_Python(code: str) -> str:
386
  """
387
- Execute Python code and return the stdout or error message.
388
- Mirrors the standalone code interpreter behavior.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
389
  """
390
  if code is None:
391
  return "No code provided."
 
260
  max_links: int = 20,
261
  ) -> str:
262
  """
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 (str):
271
+ The absolute URL to fetch. Must return HTML. Example:
272
+ "https://example.com/article".
273
+ verbosity (str, optional):
274
+ Controls how much body text to include. One of:
275
+ - "Brief" (about 800–1200 chars)
276
+ - "Standard" (about 3000 chars)
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:
298
+ - Title (H1)
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."
 
376
  title_chars: int = 80,
377
  ) -> str:
378
  """
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 (str):
387
+ The search query. Examples: "langchain streaming" or
388
+ "vector database site:docs.pinecone.io".
389
+ max_results (int, optional):
390
+ Maximum number of results to return. Range: 1–20. Default: 5.
391
+ include_snippets (bool, optional):
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 ""
 
450
 
451
  def Execute_Python(code: str) -> str:
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 (str):
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."