Skip to main content

Scrape - MCP Tool Specification

This document outlines the specification for tools within the Scrape module that are integrated with the Model Context Protocol (MCP).


Tool: scrape_extract_content​

1. Tool Purpose and Description​

Extracts structured content (title, headings, links, paragraphs, images) from a raw HTML string. Returns metadata and element counts.

2. Invocation Name​

scrape_extract_content

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
htmlstringYesRaw HTML string to extract content from"<html><body><h1>Hello</h1></body></html>"
base_urlstringNoBase URL for resolving relative links (default: "")"https://example.com"

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
statusstring"ok" on success, "error" on failure"ok"
titlestringPage title extracted from <title> or first <h1>"My Page"
headingsarray[object]List of {"level": int, "text": str} heading objects[{"level": 1, "text": "Hello"}]
paragraph_countintegerNumber of <p> elements found12
link_countintegerNumber of <a href> links found7
image_countintegerNumber of <img> elements found3
word_countintegerTotal word count across all text nodes450
content_hashstringHash of the extracted text content"a3f2b1..."
metaobjectExtracted <meta> tag key-value pairs{"description": "..."}
errorstringError message (only present when status == "error")"Failed to parse HTML"

5. Error Handling​

  • Returns {"status": "error", "error": "<message>"} if extraction fails
  • Does not raise exceptions — all errors are captured in the return value

6. Idempotency​

  • Idempotent: Yes — same HTML input always produces the same output

7. Usage Examples​

{
"tool_name": "scrape_extract_content",
"arguments": {
"html": "<html><head><title>Test</title></head><body><h1>Hello</h1><p>World</p></body></html>",
"base_url": "https://example.com"
}
}

Example response:

{
"status": "ok",
"title": "Test",
"headings": [{"level": 1, "text": "Hello"}],
"paragraph_count": 1,
"link_count": 0,
"image_count": 0,
"word_count": 2,
"content_hash": "...",
"meta": {}
}

8. Security Considerations​

  • No Network Calls: Operates entirely on the provided HTML string — no outbound requests
  • Input Size: Very large HTML strings may increase processing time

Tool: scrape_text_similarity​

1. Tool Purpose and Description​

Computes the Jaccard word-level similarity score between two text strings. Returns a float in [0.0, 1.0] where 1.0 means identical word sets and 0.0 means no words in common.

2. Invocation Name​

scrape_text_similarity

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
text_astringYesFirst text string"the quick brown fox"
text_bstringYesSecond text string"the quick red fox"

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
statusstring"ok" on success, "error" on failure"ok"
similarityfloatJaccard similarity score in range [0.0, 1.0]0.6
errorstringError message (only present when status == "error")"..."

5. Error Handling​

  • Returns {"status": "error", "error": "<message>"} if comparison fails
  • Both empty strings produces similarity: 0.0

6. Idempotency​

  • Idempotent: Yes

7. Usage Examples​

{
"tool_name": "scrape_text_similarity",
"arguments": {
"text_a": "the quick brown fox",
"text_b": "the quick red fox"
}
}

Example response:

{
"status": "ok",
"similarity": 0.6
}

8. Security Considerations​

  • No Network Calls: Pure text comparison, no I/O