USAGE_EXAMPLES.mdā¢2.13 kB
# Crawl4AI MCP Server - Usage Examples
## Overview
The Crawl4AI MCP server provides three core tools for web scraping and analysis. These examples demonstrate how to use each tool through the MCP Inspector interface.
## Tools Available
### 1. server_status
**Purpose**: Get server health and capabilities information
**Parameters**: None
**Example Response**:
```json
{
"server_name": "Crawl4AI-MCP-Server",
"version": "1.0.0",
"status": "operational",
"capabilities": ["web_crawling", "content_extraction", "screenshot_capture", "schema_based_extraction"]
}
```
### 2. get_page_structure
**Purpose**: Extract webpage content for analysis ("eyes" function)
**Parameters**:
- `url` (string): The webpage URL to analyze
- `format` (string): Output format - "html" or "markdown" (default: "html")
**Example Usage**:
```json
{
"url": "https://example.com",
"format": "html"
}
```
### 3. crawl_with_schema
**Purpose**: Precision data extraction using CSS selectors ("hands" function)
**Parameters**:
- `url` (string): The webpage URL to extract data from
- `extraction_schema` (string): JSON string defining field names and CSS selectors
**Example Schema**:
```json
{
"title": "h1",
"description": "p.description",
"price": ".price-value",
"author": ".author-name",
"tags": ".tag"
}
```
**Example Usage in MCP Inspector**:
- URL: `https://example.com/product`
- Schema: `{"title": "h1", "price": ".price", "description": "p"}`
### 4. take_screenshot
**Purpose**: Capture visual representation of webpage
**Parameters**:
- `url` (string): The webpage URL to screenshot
**Example Usage**:
```json
{
"url": "https://example.com"
}
```
## Testing with MCP Inspector
1. **Start the Server**:
```bash
cd /path/to/crawl4ai-mcp
source venv/bin/activate
fastmcp dev crawl4ai_mcp_server.py
```
2. **Access Inspector**: Open the provided URL (usually http://localhost:6274)
3. **Test Each Tool**: Use the interactive interface to call tools with example parameters
## Error Handling
All tools include comprehensive error handling and return structured JSON responses with success/error status.