PyPen MCP

PyPen MCP

Enables LLM-powered browser automation and security testing with features like browser management, network monitoring, DOM manipulation, and captcha handling.

Category
访问服务器

README

PyPen MCP

Model Context Protocol server for browser-based penetration testing using PyDoll.

Overview

PyPen MCP provides a comprehensive set of tools for LLM-powered browser automation and security testing. It leverages PyDoll's Chrome DevTools Protocol integration for reliable, webdriver-free browser control.

Features

Browser Management

  • Launch/close browser instances with configurable options
  • Navigation control (navigate, back, forward, refresh)
  • Headless mode, proxy support, custom user agents
  • Incognito mode and resource blocking

Network Operations

  • Monitoring: Capture all HTTP traffic, analyze requests/responses
  • Interception: Block, modify, or mock requests in real-time
  • Authenticated Requests: Make API calls that inherit browser session/cookies

DOM Manipulation

  • Find elements by CSS selector, XPath, or attributes
  • Click, type, scroll, and interact with elements
  • Extract page source, element text, and HTML
  • Human-like scrolling with physics simulation

JavaScript Execution

  • Execute arbitrary JavaScript in browser context
  • Access localStorage and sessionStorage
  • Extract global variables, forms, and links

Session Management

  • Cookie manipulation (get, set, delete, clear)
  • Import/export cookies in multiple formats
  • Session-aware HTTP requests

Captcha Handling

  • Turnstile Bypass: Automatic Cloudflare Turnstile interaction
  • Human Intervention: Request human help for unsolvable captchas (ReCAPTCHA v2, hCaptcha)
  • Detection: Identify captcha types on the page

Debugging

  • Screenshots (full page or elements)
  • Viewport control
  • Performance metrics
  • Element highlighting

Installation

pip install pypen-mcp

Or install from source:

git clone https://github.com/your-repo/pypen-mcp
cd pypen-mcp
pip install -e .

Configuration

Add to your MCP client configuration:

{
  "mcpServers": {
    "pypen": {
      "command": "pypen-mcp"
    }
  }
}

For development:

{
  "mcpServers": {
    "pypen": {
      "command": "/path/to/pypen-mcp/.venv/bin/pypen-mcp"
    }
  }
}

Usage Examples

Basic Browser Automation

# Launch browser
browser_launch(headless=True)

# Navigate to target
browser_navigate(url="https://example.com")

# Extract page content
dom_get_source()

# Find and interact with elements
dom_find_element(css_selector="#username")
dom_type(selector="#username", text="admin")
dom_click(selector="button[type=submit]")

# Take screenshot for documentation
debug_screenshot(path="/tmp/screenshot.png")

# Close when done
browser_close()

Network Monitoring

# Enable traffic capture
network_enable_monitoring()

# Navigate and capture
browser_navigate(url="https://api.example.com")

# Get captured requests
network_get_logs(filter_url="/api/")

# Get response body for specific request
network_get_response_body(request_id="abc123")

# Disable when done
network_disable_monitoring()

Request Interception

# Set up interception rules
network_setup_handler(
    block_patterns=["analytics", "tracking", "ads"],
    modify_headers={"Authorization": "Bearer token123"},
    mock_responses={"/api/config": {"status": 200, "body": {"debug": true}}}
)

# Navigate with interception active
browser_navigate(url="https://example.com")

Session-Based Requests

# Login via UI (handles complex auth)
browser_navigate(url="https://app.com/login")
dom_type(selector="#email", text="user@example.com")
dom_type(selector="#password", text="password123")
dom_click(selector="button[type=submit]")

# Make authenticated API calls
session_make_request(
    url="https://app.com/api/user/profile",
    method="GET"
)

Captcha Handling

# Enable automatic Turnstile bypass
captcha_enable_turnstile_bypass(time_to_wait_captcha=10.0)

# Navigate to protected site
browser_navigate(url="https://protected-site.com")

# Wait for captcha processing
# ... automation continues ...

# For unsolvable captchas, request human help
captcha_detect_type()  # Check what's on page
captcha_request_human_intervention(
    captcha_type="recaptcha_v2",
    message="Please solve the ReCAPTCHA to continue"
)

# Wait for human to solve
captcha_wait_for_resolution(request_id="abc123", timeout=300)

Tool Reference

Browser Tools

Tool Description
browser_launch Launch browser with options (headless, proxy, etc.)
browser_close Close the browser instance
browser_navigate Navigate to a URL
browser_go_back Navigate back in history
browser_go_forward Navigate forward in history
browser_refresh Refresh current page
browser_get_info Get current URL and title

Network Tools

Tool Description
network_enable_monitoring Start capturing HTTP traffic
network_disable_monitoring Stop traffic capture
network_get_logs Get captured requests (with optional filter)
network_get_response_body Get response body for a request
network_enable_interception Enable request interception
network_disable_interception Disable interception
network_setup_handler Configure auto interception rules

DOM Tools

Tool Description
dom_find_element Find element by selector
dom_find_elements Find multiple elements
dom_get_text Get element text content
dom_get_html Get element HTML
dom_click Click an element
dom_type Type text into input
dom_scroll Scroll the page
dom_get_source Get full page HTML
dom_wait_for Wait for element to appear

JavaScript Tools

Tool Description
js_execute Execute JavaScript code
js_get_console_logs Get console logs
js_get_global_vars Extract global variables
js_get_local_storage Get localStorage data
js_get_session_storage Get sessionStorage data
js_set_local_storage Set localStorage value
js_get_forms Get all forms with inputs
js_get_links Get all links on page

Session Tools

Tool Description
session_get_cookies Get all cookies
session_get_cookie Get specific cookie
session_set_cookie Set a cookie
session_delete_cookie Delete a cookie
session_clear_cookies Clear all cookies
session_export_cookies Export cookies (json/netscape/header)
session_import_cookies Import cookies from JSON
session_make_request Make session-authenticated HTTP request

Captcha Tools

Tool Description
captcha_enable_turnstile_bypass Enable auto Turnstile handling
captcha_disable_turnstile_bypass Disable Turnstile handling
captcha_detect_type Detect captcha type on page
captcha_handle_auto Auto-handle detected captcha
captcha_request_human_intervention Request human help
captcha_get_pending_interventions Get unresolved requests
captcha_resolve_intervention Mark intervention as resolved
captcha_wait_for_resolution Wait for human to solve

Debug Tools

Tool Description
debug_screenshot Take page screenshot
debug_get_viewport Get viewport size
debug_set_viewport Set viewport size
debug_get_performance Get performance metrics
debug_highlight Highlight matching elements

Important Notes

Browser Session Persistence

  • The browser session persists until explicitly closed with browser_close
  • All operations (DOM, JS, network) use the same active session
  • Cookies and session state are maintained across navigations

Captcha Success Factors

Turnstile bypass success depends on:

  1. IP Reputation: Use residential proxies with good reputation
  2. Browser Fingerprint: Configure realistic browser options
  3. Behavioral Patterns: Add realistic delays and interactions

Human Intervention Workflow

  1. Detect captcha: captcha_detect_type()
  2. Try auto-handling: captcha_handle_auto()
  3. If fails, request help: captcha_request_human_intervention()
  4. Wait for resolution: captcha_wait_for_resolution()
  5. Continue automation

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选