Skip to main content
Glama
DrissionPageMCP

DrissionPageMCP

by wxhzhwxhzh

DrissionPage MCP Server -- 骚神出品

基于DrissionPage和FastMCP的浏览器自动化MCP服务器,提供丰富的浏览器操作API供AI调用。

项目简介

logo

DrissionPage MCP 是一个基于 DrissionPage 和 FastMCP 的浏览器自动化MCP server服务器,它提供了一系列强大的浏览器操作 API,让您能够轻松通过AI实现网页自动化操作。

主要特性

  • 支持浏览器的打开、关闭和连接管理

  • 提供丰富的页面元素操作方法

  • 支持 JavaScript 代码执行

  • 支持 CDP 协议操作

  • 提供便捷的文件下载功能

  • 支持键盘按键模拟

  • 支持页面截图功能

  • 增加 网页后台监听数据包的功能

  • 增加自动上传下载文件功能

Python要求

  • Python >= 3.9

  • pip(最新版本)

  • uv (最新版本)

浏览器要求

  • Chrome 浏览器(推荐 90 及以上版本)

必需的Python包

  • drissionpage >= 4.1.0.18

  • fastmcp >= 2.4.0

  • uv

Related MCP server: DrissionPage MCP Server

安装说明

安装到Cursor编辑器

安装说明 安装说明

安装到vscode编辑器

安装说明 安装说明 安装说明

请将以下配置代码粘贴到编辑器的mcpServers设置中(请填写你自己电脑上 main.py 文件的绝对路径):

{
  "mcpServers": {
    "DrissionPageMCP": {
      "type": "stdio",
      "command": "uv",
      "args": ["--directory", "D:\\test10\\DrissionPageMCP", "run", "main.py"]
    }
  }
}

新增mcp配置 ,填写下面的配置:

"DrissionPageMCP": {
      "type": "stdio",
      "command": "uv",
      "args": ["--directory", "D:\\test10\\DrissionPageMCP", "run", "main.py"]
    } 

注意事项:

  • 请根据实际路径修改args中的路径

  • Windows中路径中的反斜杠需要转义(使用\\)

  • 确保uv命令在系统PATH中可用

  • 《MCP安装参考教程》

调试命令

调试

npx -y @modelcontextprotocol/inspector uv run D:\\test10\\DrissionPageMCP\\main.py

或者

mcp dev  D:\\test10\\DrissionPageMCP\\main.py

更新日志

v0.1.3

增加 自动上传下载文件功能

v0.1.2

增加 网页后台监听数据包的功能

v0.1.0

  • 初始版本发布

  • 实现基本的浏览器控制功能

  • 提供元素操作 API

Available Tools

29 tools
click_by_containing_textA

根据包含指定文本的方式点击网页元素。

参数: content: 要查找的文本内容。 index: 当匹配到多个元素时指定要点击的索引,默认不指定。

返回: 点击结果说明,或错误提示。

Inputs: content (required), index.

click_by_xpathA

通过xpath点击当前标签页中某个元素,最好先获取页面dom信息,再决定Xpath的写法

Inputs: xpath (required).

connect_or_open_browserB

用DrissionPage 打开或接管已打开的浏览器,参数通过字典传递。 必要参数: config (dict): 可选键包括 、debug_port、browser_path、headless 返回: dict: 浏览器信息

Inputs: config.

download_fileC

控制浏览器下载文件到指定路径

Args: url (str): 文件的URL地址 path (str): 文件保存的路径 rename (str): 重命名文件名

Returns: str: 下载结果信息

Inputs: url (required), path (required), rename (required).

dragA

将元素拖动到指定偏移位置

Args: xpath: 要拖动的元素xpath路径 offset_x: x轴偏移量(像素) offset_y: y轴偏移量(像素) duration: 拖动持续时间(毫秒),默认为1000

Returns: dict: 包含偏移量和持续时间的字典,格式为{"offset_x": int, "offset_y": int, "duration": int} 或 str: 当元素不存在时返回错误信息

Raises: 无显式抛出异常,但内部可能因元素不存在而返回错误信息

Inputs: xpath (required), offset_x (required), offset_y (required), duration.

getA

在当前标签页打开一个网址

Inputs: url (required).

get_body_textB

获取当前标签页的body的文本内容

Inputs: no named parameters.

get_cdp_event_dataB

获取CDP事件回调函数收集到的数据

Inputs: no named parameters.

get_current_tab_infoA

获取当前标签页的信息,包括url, title, id

Inputs: no named parameters.

get_current_tab_screenshotA

获取当前标签页的网页截图

Returns: bytes: 截图的二进制数据

Inputs: no named parameters.

get_current_tab_screenshot_as_fileB

获取当前标签页的屏幕截图并保存为文件

Args: path (str): 截图保存路径,默认为当前目录

Returns: str: 截图的文件路径

Inputs: name, path.

get_DrissionPage_code_guideC

获取 DrissionPage 代码指南

Inputs: no named parameters.

getInputElementsInfoA

获取当前标签页的所有可进行输入操作的元素,对元素进行输入操作前优先使用这个方法

Inputs: no named parameters.

get_response_listener_dataB

获取监听到的数据,返回数据列表

Inputs: no named parameters.

getSimplifiedDomTreeD

Inputs: no named parameters.

get_url_with_response_listenerB

开启一个新的标签页,设置监听,访问tab_url, tab_url: 被监听的标签页的url mimeType: 需要监听的接收的数据包的mimeType类型 url_include: 需要监听的接收的数据包的url包含的关键字 refresh: 是否刷新页面,

Inputs: tab_url (required), mimeType (required), url_include.

get_versionC

获取版本号

Inputs: no named parameters.

input_by_xapthA

通过xpath给当前标签页中某个元素输入内容,最好先判断元素是否存在

Args: xpath (str): 元素的XPath表达式 input_value (str): 要输入的内容 clear_first (bool): 是否先清除已有内容,默认为True

Returns: Any: 输入操作的结果,如果元素不存在则返回错误信息

Inputs: xpath (required), input_value (required), clear_first.

listen_cdp_eventA

设置监听CDP事件

应该先运行cdp 命令 激活对应的域,比如 Network.enable

Inputs: event_name (required).

move_toA

鼠标移动悬停到指定xpath的元素上

Inputs: xpath (required).

new_tabC

用DrissionPage 控制的浏览器,打开新标签页并 打开一个网址

Inputs: url (required).

response_listener_stopC

关闭监听网页发送的数据包

Inputs: clear_data.

run_cdpB

在当前标签页中运行谷歌CDP协议代码并获取结果

Args:

cmd: CDP协议命令
**cmd_args: CDP命令参数

Returns: Any: CDP命令执行结果

Note: 举例1说明 run_cdp('Page.stopLoading') 举例2说明 run_cdp('Page.navigate', url='https://example.com')

Inputs: cmd (required), cmd_args (required).

run_jsA

在当前标签页中运行JavaScript代码并返回执行结果 查找网页元素,获取元素信息,操作网页元素优先使用这个方法

Args: js_code (str): 要执行的JavaScript代码

Returns: Any: JavaScript代码执行结果

Note: 想要获取执行的js代码的返回值,可以在js_code中使用return语句。 想要获取异步函数的返回值,可以参考下面代码 return (async (url) => { const response = await fetch(url); const data = await response.json();
return data; })("https://www.baidu.com/");

Inputs: js_code (required).

save_dict_to_sqliteA

将字典或JSON字符串保存到SQLite数据库中。

参数: data (dict or list of dict or str): 字典、列表字典,或JSON字符串。 db_path (str): SQLite 数据库文件路径。 table_name (str): 要创建的表名。

Inputs: data (required), db_path, table_name.

send_enterA

向当前页面发送 enter 回车键

Inputs: no named parameters.

send_keyC

向当前标签页发送特殊按键

Inputs: key (required).

upload_fileA

点击当网页上的 元素触发上传文件的操作,上传file_path文件到当前网页

Args:
file_path (str): 要上传的文件路径

Returns: str: 上传结果信息,如果元素不存在则返回错误信息

Inputs: file_path (required).

waitD

等待a秒

Inputs: a (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    C2.6/5.0

    Scored across 29 tools

    Disambiguation4/5

    Most tools target distinct actions like navigation, clicking, input, screenshots, and network listening. A few pairs (send_enter/send_key, screenshot/screenshot_as_file) are closely related, but descriptions make them distinguishable.

    Naming Consistency3/5

    The naming is predominantly snake_case verb phrases, but getInputElementsInfo and getSimplifiedDomTree break the convention, and input_by_xapth contains a typo. Overall it remains readable and mostly predictable.

    Tool Count2/5

    With 29 tools, the server feels over-scoped, especially with redundant screenshot/listener functions and an unrelated save_dict_to_sqlite. The count exceeds the comfortable range and could be reduced by consolidating similar tools.

    Completeness4/5

    Core browser automation workflows are covered: navigation, tabs, element interaction, JS/CDP, file transfer, screenshots, and network listening. Gaps like closing tabs or cookie management are workaroundable via run_js or run_cdp.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      D
      maintenance
      An MCP server providing robust browser automation tools for AI assistants, including page navigation, element interaction, and screenshot capabilities. It leverages the DrissionPage library to enable standardized DOM analysis, network monitoring, and complex web task automation.
      17
      MIT
    • A
      license
      C
      quality
      B
      maintenance
      A professional browser automation server that enables MCP clients to perform structured web navigation, element interaction, and data extraction using the DrissionPage framework. It features 14 deterministic tools optimized for LLMs to automate web workflows efficiently without relying on vision-based models.
      69
      152 PyPI
      482
      Apache 2.0
    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to control and interact with a Chrome browser via MCP, providing tools for navigation, screenshots, clicking, form filling, content extraction, and tab management.
      1
      -
    • F
      license
      B
      quality
      B
      maintenance
      Enables MCP clients to drive browser automation for web navigation, element interaction, and multi-account isolation via DrissionPage 5.0.
      56
      -