| Crates.io | snm-brightdata-client |
| lib.rs | snm-brightdata-client |
| version | 0.4.0 |
| created_at | 2025-07-20 16:40:18.299833+00 |
| updated_at | 2025-09-08 12:50:19.002358+00 |
| description | Bright Data Wrapper Client Highly compacted Data implemented in Rust with Actix Web |
| homepage | |
| repository | https://github.com/snmmaurya/snm-brightdata-client |
| max_upload_size | |
| id | 1761225 |
| size | 855,330 |
A powerful Rust crate providing MCP-compatible integration with BrightData's web scraping and data extraction services. Built with Actix Web for high-performance web scraping, search, data extraction, and screenshot capabilities.
Add to your Cargo.toml:
[dependencies]
snm-brightdata-client = "0.1.0"
# BrightData Configuration
export BRIGHTDATA_API_TOKEN="your_api_token"
export BRIGHTDATA_BASE_URL="https://api.brightdata.com"
export WEB_UNLOCKER_ZONE="your_zone_name"
export BROWSER_ZONE="your_browser_zone"
# Proxy Credentials (optional)
export BRIGHTDATA_PROXY_USERNAME="your_username"
export BRIGHTDATA_PROXY_PASSWORD="your_password"
# Server Configuration
export MCP_AUTH_TOKEN="your_secure_token"
export PORT="8080"
use snm_brightdata_client::{BrightDataClient, BrightDataConfig};
use snm_brightdata_client::tool::{ToolResolver, Tool};
use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Initialize client
let config = BrightDataConfig::from_env()?;
let client = BrightDataClient::new(config);
// Use tools directly
let resolver = ToolResolver::default();
let search_tool = resolver.resolve("search_web").unwrap();
let result = search_tool.execute(json!({
"query": "Rust programming language",
"engine": "google"
})).await?;
println!("Search results: {:#?}", result);
Ok(())
}
# Search the web
snm_cli search "Bitcoin price today" --engine google
# Scrape a website
snm_cli scrape https://example.com --format markdown
# Extract data
snm_cli extract https://example.com --format json
# Take screenshot
snm_cli screenshot https://example.com --width 1920 --height 1080
# Start the server
cargo run --bin snm_server
# Health check
curl http://localhost:8080/health
# List available tools
curl http://localhost:8080/tools
# Use tools via API
curl -X POST http://localhost:8080/invoke \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{
"tool": "search_web",
"parameters": {
"query": "Rust web scraping",
"engine": "google"
}
}'
search_web)Search across multiple search engines with BrightData's unblocking capabilities.
{
"tool": "search_web",
"parameters": {
"query": "your search query",
"engine": "google" // google, bing, yandex, duckduckgo
}
}
scrape_website)Extract content from any website, bypassing anti-bot protections.
{
"tool": "scrape_website",
"parameters": {
"url": "https://example.com",
"format": "markdown" // raw, markdown
}
}
extract_data)Intelligent data extraction from webpages.
{
"tool": "extract_data",
"parameters": {
"url": "https://example.com"
}
}
take_screenshot)Capture high-quality screenshots of websites.
{
"tool": "take_screenshot",
"parameters": {
"url": "https://example.com"
}
}
This crate is fully compatible with the Model Context Protocol (MCP), making it easy to integrate with AI systems like Claude.
{
"type": "url",
"url": "https://your-server.com/sse",
"name": "brightdata-mcp",
"authorization_token": "your_token",
"tool_configuration": {
"enabled": true,
"allowed_tools": ["search_web", "scrape_website", "extract_data", "take_screenshot"]
}
}
curl https://api.anthropic.com/v1/messages \
-H "Content-Type: application/json" \
-H "X-API-Key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "anthropic-beta: mcp-client-2025-04-04" \
-d '{
"model": "claude-sonnet-4-20250514",
"max_tokens": 2000,
"messages": [
{
"role": "user",
"content": "Search for the latest news about Rust programming language"
}
],
"mcp_servers": [
{
"type": "url",
"url": "https://your-server.com/sse",
"name": "brightdata-mcp",
"authorization_token": "your_token"
}
]
}'
| Endpoint | Method | Description |
|---|---|---|
/health |
GET | Health check |
/tools |
GET | List available tools |
/invoke |
POST | Direct tool invocation |
/sse |
POST | Server-Sent Events streaming |
/mcp |
POST | MCP JSON-RPC protocol |
All tools return MCP-compatible responses:
{
"content": [
{
"type": "text",
"text": "Response content here"
}
],
"is_error": false,
"raw_value": {
// Original response data
}
}
# Build library
cargo build
# Build with all features
cargo build --all-features
# Run tests
cargo test
# Run with debug logging
RUST_LOG=debug cargo run --bin snm_server
Check out the examples/ directory for:
Use as an MCP server to enhance Claude with web scraping capabilities.
Integrate into your Rust applications for:
This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ by SNM Maurya