🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@mtop-devtools/client

Package Overview
Dependencies
Maintainers
2
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mtop-devtools/client

Client SDK & CLI for Mtop DevTools — communicate with Chrome Extension via Unix Socket

npmnpm
Version
1.39.0
Version published
Weekly downloads
67
-79.26%
Maintainers
2
Weekly downloads
 
Created
Source

@mtop-devtools/client

本地客户端 SDK 与 CLI,通过 Unix Domain Socket 与 Chrome 扩展的 native host 通信,调用浏览器调试与操作能力。

提供两种用法:类型安全的具名方法(getRequestsproxyRequest 等),以及灵活的底层 invoke(action, payload)

安装

npm install @mtop-devtools/client
# 或
pnpm add @mtop-devtools/client

SDK 使用

import * as client from '@mtop-devtools/client';

// 具名方法(类型安全)
const requests = await client.getRequests({ count: 5 });
const result = await client.proxyRequest({
  url: 'https://api.example.com',
  method: 'GET',
  withCookies: true,
});

// 底层通用方法(灵活扩展)
const data = await client.invoke('proxy_request', { url: '...' });

CLI 使用

安装后提供 mtop-devtools 命令:

# 获取最近 5 个请求
mtop-devtools get_requests --payload '{"count":5}'

# 代理一个 HTTP 请求
mtop-devtools proxy_request --payload '{"url":"https://api.example.com","method":"GET"}'

# 截图并保存
mtop-devtools get_screenshot --output ./screenshot.png

# 从文件读取大体积参数(如 mock 数据)
mtop-devtools set_mock --payload-file ./mock-data.json

# 环境自检
mtop-devtools check

# 查看某个 action 的帮助
mtop-devtools <action> --help

通用选项:

选项说明
--payload <json>直接传入 JSON 参数
--payload-file <path>从文件读取 JSON 参数
--timeout <seconds>请求超时时间
--compact紧凑输出
--output <path>将结果写入文件(如截图)

支持的操作

分类Actions
API 调试get_requests get_logs get_events get_api_schema
Mock & 规则set_mock get_mocks add_rule
网络代理proxy_request send_mtop_request
标签页tab_open tab_close tab_list
页面操作page_click page_type page_scroll page_eval page_press page_wait page_navigate page_upload
页面感知page_snapshot get_screenshot get_selected_element page_frames
移动端模拟set_device_emulation
用户信息get_user_info
录制record_start record_stop record_get
TDBanktdbank_account

架构

@mtop-devtools/client (CLI / SDK)
  ↓ (Unix Socket)
@mtop-devtools/native-host
  ↓ (Native Messaging)
Chrome Extension / CDP

云端远程调用场景请使用 @mtop-devtools/cloud-client,其操作集与本包完全一致。

构建

pnpm build      # tsc 编译到 dist/,并赋予 cli.js 执行权限
pnpm dev        # tsc --watch
pnpm typecheck  # 仅类型检查

License

ISC

Keywords

mtop-devtools

FAQs

Package last updated on 09 Jul 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts