MCP Web Browser Server

by random-robbie
Verified

local-only server

The server can only run on the client’s local machine because it depends on local resources.

Integrations

  • Enables execution of JavaScript code on web pages through the execute_javascript method, allowing interaction with dynamic web content.

MCP 웹 브라우저 서버

Playwright가 제공하는 MCP(Model Context Protocol)를 위한 고급 웹 브라우징 서버로, 유연하고 안전한 API를 통해 헤드리스 브라우저 상호작용을 지원합니다.

🌐 특징

  • 헤드리스 웹 브라우징 : SSL 인증서 검증 우회를 통해 모든 웹사이트 탐색
  • 전체 페이지 콘텐츠 추출 : 동적으로 로드된 JavaScript를 포함한 전체 HTML 콘텐츠를 검색합니다.
  • 다중 탭 지원 : 여러 브라우저 탭을 만들고, 관리하고, 전환합니다.
  • 고급 웹 상호작용 도구 :
    • 텍스트 콘텐츠 추출
    • 페이지 요소 클릭
    • 양식 필드에 텍스트 입력
    • 스크린샷 캡처
    • 필터링 기능을 사용하여 페이지 링크 추출
    • 어느 방향으로든 페이지를 스크롤하세요
    • 페이지에서 JavaScript 실행
    • 페이지 새로 고침
    • 탐색이 완료될 때까지 기다리세요
  • 리소스 관리 : 비활성 후 사용되지 않는 리소스를 자동으로 정리합니다.
  • 향상된 페이지 정보 : 현재 페이지에 대한 자세한 메타데이터를 가져옵니다.

🚀 빠른 시작

필수 조건

  • 파이썬 3.10+
  • MCP SDK
  • 극작가

설치

지엑스피1

Claude Desktop 구성

claude_desktop_config.json 에 다음을 추가하세요:

{ "mcpServers": { "web-browser": { "command": "python", "args": [ "/path/to/your/server.py" ] } } }

💡 사용 예시

기본 웹 탐색

# Browse to a website page_content = browse_to("https://example.com") # Extract page text text_content = extract_text_content() # Extract text from a specific element title_text = extract_text_content("h1.title")

웹 상호작용

# Navigate to a page browse_to("https://example.com/login") # Input text into a form input_text("#username", "your_username") input_text("#password", "your_password") # Click a login button click_element("#login-button")

스크린샷 캡처

# Capture full page screenshot full_page_screenshot = get_page_screenshots(full_page=True) # Capture specific element screenshot element_screenshot = get_page_screenshots(selector="#main-content")

링크 추출

# Get all links on the page page_links = get_page_links() # Get links matching a pattern filtered_links = get_page_links(filter_pattern="contact")

멀티탭 브라우징

# Create a new tab tab_id = create_new_tab("https://example.com") # Create another tab another_tab_id = create_new_tab("https://example.org") # List all open tabs tabs = list_tabs() # Switch between tabs switch_tab(tab_id) # Close a tab close_tab(another_tab_id)

고급 상호작용

# Scroll the page scroll_page(direction="down", amount="page") # Execute JavaScript on the page result = execute_javascript("return document.title") # Get detailed page information page_info = get_page_info() # Refresh the current page refresh_page() # Wait for navigation to complete wait_for_navigation(timeout_ms=5000)

🛡️ 보안 기능

  • SSL 인증서 유효성 검사 우회
  • 안전한 브라우저 컨텍스트 관리
  • 사용자 정의 사용자 에이전트 구성
  • 오류 처리 및 포괄적인 로깅
  • 구성 가능한 시간 초과 설정
  • CSP 바이패스 제어
  • 쿠키 도용 방지

🔧 문제 해결

일반적인 문제

  • SSL 인증서 오류 : 자동으로 우회됨
  • 느린 페이지 로드 : browse_to() 메서드에서 시간 초과 조정
  • 요소를 찾을 수 없음 : 선택기를 주의 깊게 확인하세요
  • 브라우저 리소스 사용량 : 비활성 기간 후 자동 정리

벌채 반출

모든 중요한 이벤트는 자세한 정보와 함께 기록되어 디버깅이 쉽습니다.

📋 도구 매개변수

browse_to(url: str, context: Optional[Any] = None)

  • url : 이동할 웹사이트
  • context : 선택적 컨텍스트 객체(현재 사용되지 않음)

extract_text_content(selector: Optional[str] = None, context: Optional[Any] = None)

  • selector : 특정 콘텐츠를 추출하는 선택적 CSS 선택기
  • context : 선택적 컨텍스트 객체(현재 사용되지 않음)

click_element(selector: str, context: Optional[Any] = None)

  • selector : 클릭할 요소의 CSS 선택자
  • context : 선택적 컨텍스트 객체(현재 사용되지 않음)

get_page_screenshots(full_page: bool = False, selector: Optional[str] = None, context: Optional[Any] = None)

  • full_page : 전체 페이지 스크린샷 캡처
  • selector : 스크린샷을 찍을 선택 요소
  • context : 선택적 컨텍스트 객체(현재 사용되지 않음)
  • filter_pattern : 링크를 필터링하기 위한 선택적 텍스트 패턴
  • context : 선택적 컨텍스트 객체(현재 사용되지 않음)

input_text(selector: str, text: str, context: Optional[Any] = None)

  • selector : 입력 요소의 CSS 선택자
  • text : 입력할 텍스트
  • context : 선택적 컨텍스트 객체(현재 사용되지 않음)

create_new_tab(url: Optional[str] = None, context: Optional[Any] = None)

  • url : 새 탭에서 이동할 선택적 URL
  • context : 선택적 컨텍스트 객체(현재 사용되지 않음)

switch_tab(tab_id: str, context: Optional[Any] = None)

  • tab_id : 전환할 탭의 ID
  • context : 선택적 컨텍스트 객체(현재 사용되지 않음)

list_tabs(context: Optional[Any] = None)

  • context : 선택적 컨텍스트 객체(현재 사용되지 않음)

close_tab(tab_id: Optional[str] = None, context: Optional[Any] = None)

  • tab_id : 닫을 탭의 선택적 ID(기본값은 현재 탭)
  • context : 선택적 컨텍스트 객체(현재 사용되지 않음)

refresh_page(context: Optional[Any] = None)

  • context : 선택적 컨텍스트 객체(현재 사용되지 않음)

get_page_info(context: Optional[Any] = None)

  • context : 선택적 컨텍스트 객체(현재 사용되지 않음)

scroll_page(direction: str = "down", amount: str = "page", context: Optional[Any] = None)

  • direction : 스크롤 방향('위', '아래', '왼쪽', '오른쪽')
  • amount : 스크롤할 양('페이지', '절반' 또는 숫자)
  • context : 선택적 컨텍스트 객체(현재 사용되지 않음)

wait_for_navigation(timeout_ms: int = 10000, context: Optional[Any] = None)

  • timeout_ms : 대기할 최대 시간(밀리초)
  • context : 선택적 컨텍스트 객체(현재 사용되지 않음)

execute_javascript(script: str, context: Optional[Any] = None)

  • script : 실행할 JavaScript 코드
  • context : 선택적 컨텍스트 객체(현재 사용되지 않음)

🤝 기여하기

기여를 환영합니다! 풀 리퀘스트를 제출해 주세요.

개발 설정

# Clone the repository git clone https://github.com/random-robbie/mcp-web-browser.git # Create virtual environment python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate` # Install dependencies pip install -e .[dev]

📄 라이센스

MIT 라이센스

🔗 관련 프로젝트

💬 지원

문제가 있거나 질문이 있으시면 GitHub에서 문제를 열어 주세요.

You must be authenticated.

A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

보안 API를 통해 헤드리스 브라우저 상호작용을 가능하게 하는 고급 웹 브라우징 서버로, 탐색, 콘텐츠 추출, 요소 상호작용, 스크린샷 캡처와 같은 기능을 제공합니다.

  1. 🌐 Features
    1. 🚀 Quick Start
      1. Prerequisites
      2. Installation
      3. Configuration for Claude Desktop
    2. 💡 Usage Examples
      1. Basic Web Navigation
      2. Web Interaction
      3. Screenshot Capture
      4. Link Extraction
      5. Multi-Tab Browsing
      6. Advanced Interactions
    3. 🛡️ Security Features
      1. 🔧 Troubleshooting
        1. Common Issues
        2. Logging
      2. 📋 Tool Parameters
        1. browse_to(url: str, context: Optional[Any] = None)
        2. extract_text_content(selector: Optional[str] = None, context: Optional[Any] = None)
        3. click_element(selector: str, context: Optional[Any] = None)
        4. get_page_screenshots(full_page: bool = False, selector: Optional[str] = None, context: Optional[Any] = None)
        5. get_page_links(filter_pattern: Optional[str] = None, context: Optional[Any] = None)
        6. input_text(selector: str, text: str, context: Optional[Any] = None)
        7. create_new_tab(url: Optional[str] = None, context: Optional[Any] = None)
        8. switch_tab(tab_id: str, context: Optional[Any] = None)
        9. list_tabs(context: Optional[Any] = None)
        10. close_tab(tab_id: Optional[str] = None, context: Optional[Any] = None)
        11. refresh_page(context: Optional[Any] = None)
        12. get_page_info(context: Optional[Any] = None)
        13. scroll_page(direction: str = "down", amount: str = "page", context: Optional[Any] = None)
        14. wait_for_navigation(timeout_ms: int = 10000, context: Optional[Any] = None)
        15. execute_javascript(script: str, context: Optional[Any] = None)
      3. 🤝 Contributing
        1. Development Setup
      4. 📄 License
        1. 🔗 Related Projects
          1. 💬 Support
            ID: lwqlaw6k6d