Skip to main content
Glama
Frida Agent MCP

Frida Agent MCP

by 1193776794

Frida Agent MCP

AI 驱动的 Android 动态分析工具。通过 MCP (Model Context Protocol) 让 AI 直接操控 Frida,实现自动化逆向分析。

AI (Claude) → MCP Server → Frida CLI → zygisk-gadget (手机) → 结果返回

前提条件

  • Python >= 3.10

  • Android 手机已 root,安装 Magisk

  • 安装 zygisk-gadget Magisk 模块(固定端口 14725)

  • ADB 已连接手机

Related MCP server: ya-frida-mcp

安装

pip install .

安装后运行一键配置(注册 MCP + 安装 Skills):

frida-mcp-setup

或手动配置,在 ~/.claude.json 中添加:

{
  "mcpServers": {
    "frida-agent": {
      "command": "frida-mcp"
    }
  }
}

MCP Tools

工具

说明

connect

建立 ADB 端口转发,连接 zygisk-gadget

list_apps

列出设备上的第三方应用

execute

注入 Frida JS 脚本到前台应用(支持 script 内联 / script_file 文件路径)

spawn_and_inject

杀死 → 重启 → 注入,一步完成(适用于需要启动时 hook 的场景)

get_messages

获取注入脚本的输出(支持分页、自动文件回退)

logcat

查看 Android 日志,排查崩溃原因

launch_app

启动指定应用

kill_app

强制停止指定应用

reconnect

重新建立连接(崩溃后恢复)

detach

断开当前注入会话

Skills(Claude Code 技能)

安装后可在 Claude Code 中使用:

  • /reverse-analyze — 逆向分析与动态 Hook,结合 IDA 静态分析 + Frida 动态验证

  • /trace-vm — VM 保护函数分析,指导人工 trace 并由 AI 分析结果

使用示例

基本 Hook 流程

用户: hook 淘宝的 Cipher.doFinal 看看加密参数

AI 自动执行:
1. connect()                    — 建立连接
2. spawn_and_inject(            — 启动并注入
     "com.taobao.taobao",
     "Java.perform(function() { ... })"
   )
3. 提示用户触发操作              — "请点击登录按钮"
4. get_messages()               — 获取 hook 结果
5. 分析并展示加密参数和返回值

结合 IDA 静态分析

用户: /reverse-analyze 分析 libsgmain.so 中 0x1234 处的函数

AI 自动执行:
1. IDA MCP 反编译目标函数,分析参数和返回值类型
2. 生成 Frida Hook 脚本
3. spawn_and_inject 注入
4. 交叉验证静态分析和动态结果

工作原理

本工具使用 Frida CLI 而非 frida-python API,通过 frida -H 127.0.0.1:14725 -F -l script.js -o output.txt 注入脚本:

  • 脚本中的 send() 调用自动转换为 console.log(JSON.stringify())

  • 所有脚本自动包裹 try-catch 防止注入崩溃

  • 输出通过 -o 标志写入文件,get_messages 时停止 frida 进程以刷新文件

项目结构

src/frida_mcp/
├── server.py       # MCP Server 入口,10 个工具注册
├── connection.py   # Frida CLI 连接管理,进程生命周期
├── executor.py     # 脚本预处理(send 转换、try-catch 包裹)
├── messages.py     # 消息分页、大数据自动文件回退
├── logcat.py       # Android logcat 封装
├── setup.py        # 一键安装配置
└── skills/         # Claude Code 技能模板

License

MIT

Available Tools

10 tools
connectA

Connect to the Frida gadget on the device. Performs adb port forwarding (tcp:14725) and connects to the zygisk-gadget. Call this before any other operation.

Inputs: no named parameters. Returns: result

detachA

Detach from the current session and unload any injected scripts.

Inputs: no named parameters. Returns: result

executeA

Inject a Frida JavaScript script into the frontmost application. The script is automatically wrapped with try-catch for safety. Returns immediately after injection - use get_messages() to retrieve results after the user has triggered the target functionality.

Args: script: Frida JavaScript code to inject. Use send() to return data. script_file: Path to a .js file to inject. Use this for large scripts instead of script parameter.

Inputs: script, script_file. Returns: result

get_messagesB

Get messages collected from the injected script's send() calls. Call this after the user has triggered the target functionality.

Args: limit: Maximum number of messages to return (default 50). offset: Skip first N messages for pagination. save_to_file: If True, save all messages to a JSON file and return the path.

Inputs: limit, offset, save_to_file.

kill_appB

Force stop an Android app by package name.

Args: package: The app package name (e.g. com.example.app).

Inputs: package (required). Returns: result

launch_appB

Launch an Android app by package name.

Args: package: The app package name (e.g. com.example.app).

Inputs: package (required). Returns: result

list_appsA

List running applications on the connected device. Returns application identifier, name, and PID.

Inputs: no named parameters. Returns: result

logcatA

Get Android logcat output. Useful for debugging crashes after script injection.

Args: filter: Optional filter string (case-insensitive match on each line). lines: Number of recent lines to fetch (default 100). clear: If True, clear logcat buffer before fetching.

Inputs: filter, lines, clear. Returns: result

reconnectA

Reconnect to the gadget after an app crash. Detaches current session, re-establishes adb forwarding, and reconnects. After reconnect, restart the target app and call execute() again.

Inputs: no named parameters. Returns: result

spawn_and_injectA

Kill app, relaunch, connect, and inject script in one step. Use this when you need to hook early initialization (e.g. onCreate, static initializers). Equivalent to: kill_app -> launch_app -> connect -> execute.

Args: package: The app package name (e.g. com.taobao.taobao). script: Frida JavaScript code to inject at startup. Use send() to return data. script_file: Path to a .js file to inject. Use this for large scripts.

Inputs: package (required), script, script_file. Returns: result

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 10 tools

    Disambiguation4/5

    Most tools have distinct purposes, but there is some potential overlap between 'execute' and 'spawn_and_inject', as both inject scripts, with the latter being a convenience wrapper. The descriptions clarify the differences, so confusion is minimal.

    Naming Consistency4/5

    Tool names follow a consistent verb-based pattern (e.g., connect, detach, execute, get_messages), with minor deviations like 'logcat' (a noun) and 'spawn_and_inject' (compound verb). Overall, naming is readable and mostly uniform.

    Tool Count5/5

    With 10 tools, the count is well-suited for the server's purpose of Android app instrumentation with Frida. It covers essential operations like connection management, script injection, app control, and debugging without being overwhelming.

    Completeness5/5

    The tool set provides comprehensive coverage for the domain, including session management (connect, detach, reconnect), script injection (execute, spawn_and_inject), result retrieval (get_messages), app control (kill_app, launch_app, list_apps), and debugging (logcat). No obvious gaps are present.

    Maintenance

    ActivityNo data
    ResponsivenessSyncing

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      Not graded
      maintenance
      Enables AI systems to interact with mobile and desktop applications through Frida's dynamic instrumentation capabilities. Provides process management, device control, JavaScript REPL execution, and script injection for runtime analysis and reverse engineering.
      14
      2
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      A comprehensive MCP server for Frida dynamic instrumentation, enabling AI agents to manage devices, processes, scripts, memory, and ADB operations.
      39
      37
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      An MCP server that enables AI models to perform Android dynamic analysis using Frida, including spawning and attaching to applications, listing apps, and injecting scripts.
      123
      -
    • F
      license
      A
      quality
      C
      maintenance
      Automates Android app analysis using Frida via AI commands, connecting a rooted Android phone to a computer and running dynamic analysis scripts without manual command execution.
      10
      19
      -

    Appeared in Searches