WebScraping.AI MCP 서버
웹 데이터 추출 기능을 위해 WebScraping.AI 와 통합되는 MCP(Model Context Protocol) 서버 구현입니다.
특징
- 웹 페이지 콘텐츠에 대한 질문 답변
- 웹 페이지에서 구조화된 데이터 추출
- JavaScript 렌더링을 통한 HTML 콘텐츠 검색
- 웹 페이지에서 일반 텍스트 추출
- CSS 선택기 기반 콘텐츠 추출
- 국가 선택이 가능한 다양한 프록시 유형(데이터 센터, 주거용)
- 헤드리스 Chrome/Chromium을 사용한 JavaScript 렌더링
- 속도 제한을 통한 동시 요청 관리
- 대상 페이지에서 사용자 정의 JavaScript 실행
- 장치 에뮬레이션(데스크톱, 모바일, 태블릿)
- 계정 사용 모니터링
설치
npx로 실행
지엑스피1
수동 설치
# Clone the repository
git clone https://github.com/webscraping-ai/webscraping-ai-mcp-server.git
cd webscraping-ai-mcp-server
# Install dependencies
npm install
# Run
npm start
커서에서 구성
참고: Cursor 버전 0.45.6+가 필요합니다.
WebScraping.AI MCP 서버는 Cursor에서 두 가지 방법으로 구성할 수 있습니다.
- 프로젝트별 구성 (팀 프로젝트에 권장): 프로젝트 디렉토리에
.cursor/mcp.json
파일을 만듭니다.{
"servers": {
"webscraping-ai": {
"type": "command",
"command": "npx -y webscraping-ai-mcp",
"env": {
"WEBSCRAPING_AI_API_KEY": "your-api-key",
"WEBSCRAPING_AI_CONCURRENCY_LIMIT": "5"
}
}
}
}
- 전역 구성 (모든 프로젝트에서 개인적으로 사용): 위와 동일한 구성 형식으로 홈 디렉토리에
~/.cursor/mcp.json
파일을 만듭니다.
Windows를 사용 중이고 문제가 발생하는 경우 명령으로 cmd /c "set WEBSCRAPING_AI_API_KEY=your-api-key && npx -y webscraping-ai-mcp"
사용해 보세요.
이 구성을 사용하면 웹 스크래핑 작업과 관련된 경우 WebScraping.AI 도구가 Cursor의 AI 에이전트에서 자동으로 사용 가능하게 됩니다.
Claude Desktop에서 실행
claude_desktop_config.json
에 다음을 추가하세요:
{
"mcpServers": {
"mcp-server-webscraping-ai": {
"command": "npx",
"args": ["-y", "webscraping-ai-mcp"],
"env": {
"WEBSCRAPING_AI_API_KEY": "YOUR_API_KEY_HERE",
"WEBSCRAPING_AI_CONCURRENCY_LIMIT": "5"
}
}
}
}
구성
환경 변수
필수의
WEBSCRAPING_AI_API_KEY
: WebScraping.AI API 키
선택적 구성
WEBSCRAPING_AI_CONCURRENCY_LIMIT
: 동시 요청 최대 수(기본값: 5
)WEBSCRAPING_AI_DEFAULT_PROXY_TYPE
: 사용할 프록시 유형(기본값: residential
)WEBSCRAPING_AI_DEFAULT_JS_RENDERING
: JavaScript 렌더링을 활성화/비활성화합니다(기본값: true
)WEBSCRAPING_AI_DEFAULT_TIMEOUT
: 웹 페이지 검색 최대 시간(ms) (기본값: 15000
, 최대값: 30000
)WEBSCRAPING_AI_DEFAULT_JS_TIMEOUT
: 최대 JavaScript 렌더링 시간(ms) (기본값: 2000
)
구성 예제
표준 사용의 경우:
# Required
export WEBSCRAPING_AI_API_KEY=your-api-key
# Optional - customize behavior (default values)
export WEBSCRAPING_AI_CONCURRENCY_LIMIT=5
export WEBSCRAPING_AI_DEFAULT_PROXY_TYPE=residential # datacenter or residential
export WEBSCRAPING_AI_DEFAULT_JS_RENDERING=true
export WEBSCRAPING_AI_DEFAULT_TIMEOUT=15000
export WEBSCRAPING_AI_DEFAULT_JS_TIMEOUT=2000
사용 가능한 도구
1. 질문 도구( webscraping_ai_question
)
웹 페이지 콘텐츠에 대한 질문을 해보세요.
{
"name": "webscraping_ai_question",
"arguments": {
"url": "https://example.com",
"question": "What is the main topic of this page?",
"timeout": 30000,
"js": true,
"js_timeout": 2000,
"wait_for": ".content-loaded",
"proxy": "datacenter",
"country": "us"
}
}
응답 예시:
{
"content": [
{
"type": "text",
"text": "The main topic of this page is examples and documentation for HTML and web standards."
}
],
"isError": false
}
2. 필드 도구( webscraping_ai_fields
)
지침에 따라 웹 페이지에서 구조화된 데이터를 추출합니다.
{
"name": "webscraping_ai_fields",
"arguments": {
"url": "https://example.com/product",
"fields": {
"title": "Extract the product title",
"price": "Extract the product price",
"description": "Extract the product description"
},
"js": true,
"timeout": 30000
}
}
응답 예시:
{
"content": [
{
"type": "text",
"text": {
"title": "Example Product",
"price": "$99.99",
"description": "This is an example product description."
}
}
],
"isError": false
}
3. HTML 도구( webscraping_ai_html
)
JavaScript 렌더링을 통해 웹 페이지의 전체 HTML을 얻습니다.
{
"name": "webscraping_ai_html",
"arguments": {
"url": "https://example.com",
"js": true,
"timeout": 30000,
"wait_for": "#content-loaded"
}
}
응답 예시:
{
"content": [
{
"type": "text",
"text": "<html>...[full HTML content]...</html>"
}
],
"isError": false
}
4. 텍스트 도구( webscraping_ai_text
)
웹 페이지에서 보이는 텍스트 콘텐츠를 추출합니다.
{
"name": "webscraping_ai_text",
"arguments": {
"url": "https://example.com",
"js": true,
"timeout": 30000
}
}
응답 예시:
{
"content": [
{
"type": "text",
"text": "Example Domain\nThis domain is for use in illustrative examples in documents..."
}
],
"isError": false
}
5. 선택된 도구( webscraping_ai_selected
)
CSS 선택기를 사용하여 특정 요소에서 콘텐츠를 추출합니다.
{
"name": "webscraping_ai_selected",
"arguments": {
"url": "https://example.com",
"selector": "div.main-content",
"js": true,
"timeout": 30000
}
}
응답 예시:
{
"content": [
{
"type": "text",
"text": "<div class=\"main-content\">This is the main content of the page.</div>"
}
],
"isError": false
}
6. 선택된 다중 도구( webscraping_ai_selected_multiple
)
CSS 선택기를 사용하여 여러 요소에서 콘텐츠를 추출합니다.
{
"name": "webscraping_ai_selected_multiple",
"arguments": {
"url": "https://example.com",
"selectors": ["div.header", "div.product-list", "div.footer"],
"js": true,
"timeout": 30000
}
}
응답 예시:
{
"content": [
{
"type": "text",
"text": [
"<div class=\"header\">Header content</div>",
"<div class=\"product-list\">Product list content</div>",
"<div class=\"footer\">Footer content</div>"
]
}
],
"isError": false
}
7. 계정 도구( webscraping_ai_account
)
WebScraping.AI 계정에 대한 정보를 얻으세요.
{
"name": "webscraping_ai_account",
"arguments": {}
}
응답 예시:
{
"content": [
{
"type": "text",
"text": {
"requests": 5000,
"remaining": 4500,
"limit": 10000,
"resets_at": "2023-12-31T23:59:59Z"
}
}
],
"isError": false
}
모든 도구에 대한 공통 옵션
다음 옵션은 모든 스크래핑 도구에서 사용할 수 있습니다.
timeout
: 웹 페이지 검색에 걸리는 최대 시간(ms) (기본값 15000, 최대값 30000)js
: 헤드리스 브라우저를 사용하여 온페이지 JavaScript를 실행합니다(기본값은 true)js_timeout
: 최대 JavaScript 렌더링 시간(ms) (기본값 2000)wait_for
: 페이지 콘텐츠를 반환하기 전에 기다릴 CSS 선택기proxy
: 프록시 유형, 데이터 센터 또는 주거용(기본값은 주거용)country
: 사용할 프록시 국가(기본값: 미국). 지원 국가: us, gb, de, it, fr, ca, es, ru, jp, kr, incustom_proxy
: " http://user:password@host:port " 형식의 사용자 고유 프록시 URLdevice
: 장치 에뮬레이션 유형입니다. 지원되는 값: 데스크톱, 모바일, 태블릿error_on_404
: 대상 페이지에서 404 HTTP 상태에 대한 오류를 반환합니다(기본값은 false)error_on_redirect
: 대상 페이지에서 리디렉션 시 오류를 반환합니다(기본값은 false)js_script
: 대상 페이지에서 실행할 사용자 정의 JavaScript 코드
오류 처리
서버는 강력한 오류 처리 기능을 제공합니다.
- 일시적인 오류에 대한 자동 재시도
- 백오프를 통한 속도 제한 처리
- 자세한 오류 메시지
- 네트워크 복원력
오류 응답 예:
{
"content": [
{
"type": "text",
"text": "API Error: 429 Too Many Requests"
}
],
"isError": true
}
LLM과의 통합
이 서버는 모델 컨텍스트 프로토콜(Model Context Protocol)을 구현하여 모든 MCP 지원 LLM 플랫폼과 호환됩니다. 웹 스크래핑 작업에 이러한 도구를 사용하도록 LLM을 구성할 수 있습니다.
예: MCP를 사용하여 Claude 구성
const { Claude } = require('@anthropic-ai/sdk');
const { Client } = require('@modelcontextprotocol/sdk/client/index.js');
const { StdioClientTransport } = require('@modelcontextprotocol/sdk/client/stdio.js');
const claude = new Claude({
apiKey: process.env.ANTHROPIC_API_KEY
});
const transport = new StdioClientTransport({
command: 'npx',
args: ['-y', 'webscraping-ai-mcp'],
env: {
WEBSCRAPING_AI_API_KEY: 'your-api-key'
}
});
const client = new Client({
name: 'claude-client',
version: '1.0.0'
});
await client.connect(transport);
// Now you can use Claude with WebScraping.AI tools
const tools = await client.listTools();
const response = await claude.complete({
prompt: 'What is the main topic of example.com?',
tools: tools
});
개발
# Clone the repository
git clone https://github.com/webscraping-ai/webscraping-ai-mcp-server.git
cd webscraping-ai-mcp-server
# Install dependencies
npm install
# Run tests
npm test
# Add your .env file
cp .env.example .env
# Start the inspector
npx @modelcontextprotocol/inspector node src/index.js
기여하다
- 저장소를 포크하세요
- 기능 브랜치를 생성하세요
- 테스트 실행:
npm test
- 풀 리퀘스트 제출
특허
MIT 라이센스 - 자세한 내용은 라이센스 파일을 참조하세요.