debug_schema.pyā¢1.4 kB
#!/usr/bin/env python3
"""Debug script for crawl_with_schema tool."""
import asyncio
import json
from fastmcp import Client
from crawl4ai_mcp_server import mcp
async def debug_crawl_with_schema():
"""Debug the crawl_with_schema tool to see exact output."""
print("š Debugging crawl_with_schema tool...")
try:
async with Client(mcp) as client:
test_url = "https://httpbin.org/html"
test_schema = json.dumps({
"title": "h1",
"body": "p"
})
result = await client.call_tool("crawl_with_schema", {
"url": test_url,
"extraction_schema": test_schema
})
print("Raw result:", result)
if result and hasattr(result, 'content') and result.content:
content_item = result.content[0] if isinstance(result.content, list) else result.content
print("Content text:", content_item.text)
response = json.loads(content_item.text)
print("Parsed response:", json.dumps(response, indent=2))
print("Success field:", response.get("success"))
print("Extracted data:", response.get("extracted_data"))
except Exception as e:
print(f"Error: {str(e)}")
if __name__ == "__main__":
asyncio.run(debug_crawl_with_schema())