tools.py•4.03 kB
"""
Tool definitions for the MCP server.
"""
from models import Tool
def get_tool_definitions():
"""Return all tool definitions."""
return [
Tool(
name="fetch_webpage",
description="Securely fetch and parse web pages. Returns clean content in markdown/text/html, handles cookies and banners. NO JavaScript execution.",
input_schema={
"type": "object",
"properties": {
"url": {
"type": "string",
"description": "URL to fetch (http/https only)"
},
"format": {
"type": "string",
"enum": ["markdown", "text", "html"],
"description": "Output format",
"default": "markdown"
},
"include_links": {
"type": "boolean",
"description": "Include extracted links",
"default": True
},
"include_images": {
"type": "boolean",
"description": "Include image URLs",
"default": False
},
"remove_banners": {
"type": "boolean",
"description": "Attempt to remove cookie banners and popups",
"default": True
}
},
"required": ["url"],
},
),
Tool(
name="extract_links",
description="Extract and categorize all links from a webpage (internal, external, resources).",
input_schema={
"type": "object",
"properties": {
"url": {
"type": "string",
"description": "URL to analyze"
},
"filter": {
"type": "string",
"enum": ["all", "internal", "external", "resources"],
"description": "Filter link types",
"default": "all"
}
},
"required": ["url"],
},
),
Tool(
name="download_file",
description="Safely download files with size limits and type validation. Sanitizes filenames to prevent path traversal.",
input_schema={
"type": "object",
"properties": {
"url": {
"type": "string",
"description": "File URL"
},
"filename": {
"type": "string",
"description": "Optional filename (will be sanitized)"
}
},
"required": ["url"],
},
),
Tool(
name="get_page_metadata",
description="Extract structured metadata (title, description, Open Graph, Twitter Cards, schema.org).",
input_schema={
"type": "object",
"properties": {
"url": {
"type": "string",
"description": "URL to analyze"
}
},
"required": ["url"],
},
),
Tool(
name="check_url",
description="Check URL status without full download (HEAD request). Returns status code, headers, size.",
input_schema={
"type": "object",
"properties": {
"url": {
"type": "string",
"description": "URL to check"
}
},
"required": ["url"],
},
),
]