navmcp

navmcp

A browser automation MCP server that enables web page interaction, content extraction, and academic search via Selenium and FastMCP.

Category
访问服务器

README

navmcp --- A purely Python-based browser automation tool using MCP


Table of Contents

A Model Context Protocol (MCP) server that provides browser automation tools over SSE (Server-Sent Events). Built with FastMCP and Selenium, this server enables MCP-capable clients to interact with web pages, extract content, perform automated browser tasks, and access academic search engines.

Features

  • SSE Transport: MCP server over SSE (Server-Sent Events) via FastMCP

  • Browser Automation: Selenium-powered Chrome automation with headless support

  • Comprehensive Toolset (15 tools):

    • fetch_url: Navigate to a URL using a real browser and retrieve the final page content, title, and metadata (handles redirects, bot protection, errors).
    • find_elements: Parse the current or specified web page and extract detailed information about elements using CSS selectors or XPath (text, attributes, HTML, visibility).
    • click_element: Find and click a page element (button, link, form, etc.), optionally waiting for post-click changes; returns updated page state and metadata.
    • run_js_interaction: Execute custom JavaScript in the browser context, with argument support and JSON-serializable results; ideal for advanced DOM interactions.
    • download_pdfs: Download PDF files from web pages using multiple strategies (auto-detect, custom selector, or JavaScript-triggered); returns file info and metadata.
    • web_search: Perform general web searches using Google or Bing; returns structured results (title, URL, snippet) and metadata.
    • paper_search: Search academic literature across Google Scholar, PubMed, IEEE, arXiv, medRxiv, and bioRxiv; returns structured results and metadata.
    • convert_to_markdown: Convert HTML content, web pages, or PDFs to Markdown format using MarkItDown; supports URLs and raw HTML.
    • convert_file_to_markdown: Convert a local HTML or PDF file to Markdown and write to output; supports extracting specific HTML elements by ID.
    • save_file: Save raw content to a file at the specified path (supports large files, returns metadata).
    • fetch_and_save_url: Fetch content from a URL (using browser automation) and save it directly to a file.
    • start_browser: Start the Selenium browser session (if not already running).
    • stop_browser: Stop the Selenium browser session (not the server).
    • restart_browser: Restart the Selenium browser session (not the server).
    • shutdown_server: Gracefully shut down the MCP server process (safe for automation workflows).
  • Academic Focus: Specialized search capabilities for research papers and scholarly content

  • Security: URL validation, domain allowlists, and private IP blocking

  • Robust Error Handling: Comprehensive error handling and retry logic

  • Smart Driver Management: Selenium Manager with webdriver-manager fallback

Quick Start

Installation

  1. Install from PyPI:
pip install navmcp
  1. Configure environment (optional):
copy .env.example .env
# Edit .env with your preferences
  1. Start the server:
# Default (SSE transport, headless)
python -m navmcp start --transport sse --headless --port 3333

# To use HTTP transport (REST API, not SSE):
python -m navmcp start --transport http --headless --port 3333

# To use stdio transport (for CLI or advanced integration):
python -m navmcp start --transport stdio

Headless/GUI Mode

To run the browser in headless mode (default):

python -m navmcp start --headless --transport sse --port 3333

To run the browser with GUI (not headless):

python -m navmcp start --no-headless --transport sse --port 3333

Note: Headless mode is now only controlled by command parameters (--headless or --no-headless). The BROWSER_HEADLESS environment variable is no longer used.

  1. Verify it's running:
# Health check (for HTTP/SSE transports)
curl http://127.0.0.1:3333/health

# SSE endpoint check (for SSE transport)
curl http://127.0.0.1:3333/sse

Alternative Start Methods

# Using fastmcp SSE directly (if your fastmcp version supports it)
py -m fastmcp sse navmcp.app:app --host 127.0.0.1 --port 3333

# Using the __main__ module (defaults to SSE transport)
python -m navmcp start --transport sse

Transport Options

  • --transport sse (default): Server-Sent Events (recommended for most clients)
  • --transport http: HTTP REST API (no SSE streaming)
  • --transport stdio: Standard input/output (for CLI or advanced integration)

Note: For stdio transport, --host and --port are ignored.

Chrome Version Detection

If the optional chrome-version package is installed, navmcp will automatically detect your installed Chrome version and use the correct driver version for undetected-chromedriver. If not installed, it falls back to a default version. To enable auto-detection:

pip install chrome-version

Tip: This is only needed if you use stealth/undetected Chrome automation and want to avoid version mismatches.

Client Configuration

MCP Client Configuration

For Cline, Continue, VS Code Copilot Chat, and CodeGeeX, refer to the mcp.json file in this repository for the recommended MCP server configuration.

  • VS Code Copilot Chat: Copy or adapt the configuration from mcp.json to your workspace/.vscode/.

  • Cline / Continue: Use the configuration in cline_mcp_settings.json for your cline_mcp_settings.json. Or configure MCP server through the cline interface.

  • CodeGeeX: Use the details from mcp.json for your MCP server setup (location varies by version).

This ensures that all clients use the same configuration and remain up-to-date.

Configuration

Configuration Options

You can configure the server using either a .env file or by setting environment variables directly before starting the server.
Most options can also be set as environment variables in your shell.

# Example .env file or environment variables:
MCP_PORT=3333
MCP_HOST=127.0.0.1
DOWNLOAD_DIR=.data\downloads
PAGE_LOAD_TIMEOUT_S=30
SCRIPT_TIMEOUT_S=30
MCP_ALLOWED_HOSTS=
MCP_CORS_ORIGINS=http://127.0.0.1,http://localhost

Note: The BROWSER_HEADLESS environment variable is deprecated and no longer used. Use command-line parameters to control headless mode.

For advanced usage, check whether your server start command supports passing these options as command-line arguments.

Browser Configuration

The server automatically:

  • Uses Chrome with Selenium Manager (Selenium ≥4.6) for driver management
  • Falls back to webdriver-manager on Windows if needed
  • Configures headless mode for CI and server environments
  • Sets up automatic PDF downloads without prompts
  • Creates download directories as needed

Security Features

  • URL Validation: Blocks invalid, file://, data:, and javascript: URLs
  • Private IP Blocking: Prevents access to local/private IP ranges by default
  • Domain Allowlists: Optional restriction to specific hosts using MCP_ALLOWED_HOSTS
  • Rate Limiting: Built-in protections against abuse

MCP Tool Schema

All MCP tools now use explicit Annotated parameters with Pydantic Field annotations for proper schema exposure and validation.

Troubleshooting

Server Issues

  • Server won't start: Check if port 3333 is available, verify your Python environment, and ensure all dependencies in requirements.txt are installed.
  • Browser errors: Make sure Chrome is installed and up-to-date. Selenium Manager (Selenium ≥4.6) should auto-manage drivers, but on Windows, webdriver-manager is used as fallback.
  • Download issues: Ensure .data/downloads directory exists and is writable. If you encounter permission errors, run your shell as an administrator.
  • Structured output errors: If tool results are not returned as JSON, check your return type annotations and output schemas.
  • Async errors: For asynchronous tools, ensure you are not blocking the event loop with synchronous code. Use anyio.to_thread.run_sync for CPU-bound tasks.

Client Integration

  • Tools not showing: Confirm the server is running and accessible at http://127.0.0.1:3333/. Use /health and /sse endpoints to verify.
  • CORS errors: Add your client's origin to MCP_CORS_ORIGINS in your .env file or environment configuration.
  • Timeout errors: Increase timeout values in your environment configuration if requests are slow or failing.
  • Schema validation errors: Ensure your client sends parameters matching the tool's schema (see tool docs or /sse endpoint).

Common Commands

# Check server health
curl http://127.0.0.1:3333/health

# Check SSE endpoint (tools/list requires MCP client)
curl http://127.0.0.1:3333/sse

# Run all tests
pytest tests/

For more help, see the FastMCP documentation and Selenium driver docs.

Requirements

  • Python: ≥3.10
  • Chrome: Must be installed (or automatically managed by Selenium Manager)
  • Dependencies: See requirements.txt
  • Operating System: Windows (PowerShell commands), adaptable to other OSes

License

This project is licensed under the terms of the MIT License. See LICENSE for details.

Author & Contact

Useful Links

Developer Documentation

See DEV_README.md for development, contribution, and changelog information.

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选