npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

http-modify-mcp

v1.0.4

Published

MCP Server for http-modify Chrome Extension — manage request interception rules via AI agents

Readme

http-modify-mcp

为 Network Request Modifier Chrome 扩展提供 MCP(Model Context Protocol)接口,让 Claude Desktop、Cursor 等 AI Agent 通过工具调用增删改查网络请求拦截规则。

工具列表

| 工具名 | 参数 | 说明 | | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ | | list_rules | category? (string) | 查询规则,按分类组织;传入 category 过滤 | | list_categories | — | 列出所有分类名称 | | add_rule | urlPattern, responseData, name?, statusCode?, category?, enabled?, isAdvanced?, template?, variants? | 新增规则;支持高级模式 | | update_rule | id, urlPattern?, name?, responseData?, statusCode?, category?, enabled?, isAdvanced?, template?, variants? | 更新规则;支持跨分类迁移与高级字段更新 | | delete_rule | id | 删除规则;分类删空后自动移除 | | toggle_rule | id | 切换规则启用/禁用状态 | | set_active_variant | ruleId, variantId | 切换高级规则的当前生效场景 |

所有工具均返回 JSON:{ success: boolean, data?: any, error?: string }

高级功能字段说明:

  • isAdvanced:是否启用动态响应模式。
  • template:响应模板字符串,支持变量占位符(如 {{date.now}}{{random.uuid}}{{url.param.userId}})。
  • variants:多场景配置数组;当配置了 variants 时,优先级高于 template。
  • set_active_variant:运行时切换当前生效场景,不需要重建规则。

使用前提

在使用本 MCP Server 前,需要先安装并启用 chrome-network-modifier(Network Request Modifier)Chrome 扩展。

原因:http-modify-mcp 只负责通过 MCP 工具管理规则数据,并通过 WebSocket 与浏览器扩展同步;真正执行请求拦截与响应替换的是 Chrome 扩展本体。

建议顺序:

  1. 安装并启用 chrome-network-modifier 扩展。
  2. 在扩展面板确认规则管理功能可用。
  3. 再在 Claude Desktop / Cursor / VS Code 中接入 http-modify-mcp

安装

# 通过 npx 直接使用(推荐)
npx http-modify-mcp

# 或全局安装
npm install -g http-modify-mcp

不要直接在终端运行,应由 MCP 客户端(Claude Desktop / Cursor / VS Code)自动管理进程。

与 AI 客户端集成

Claude Desktop

编辑 ~/Library/Application Support/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "http-modify": {
      "command": "npx",
      "args": ["-y", "http-modify-mcp"]
    }
  }
}

重启 Claude Desktop 生效。

Cursor

编辑 ~/.cursor/mcp.json(或 Cursor 设置 → MCP):

{
  "mcpServers": {
    "http-modify": {
      "command": "npx",
      "args": ["-y", "http-modify-mcp"]
    }
  }
}

VS Code

.vscode/settings.json 中添加:

{
  "mcp": {
    "servers": {
      "http-modify": {
        "command": "npx",
        "args": ["-y", "http-modify-mcp"]
      }
    }
  }
}

WebSocket 实时同步

MCP Server 启动时会自动开启 WebSocket 服务(默认端口 18080),Chrome 扩展通过 WebSocket 连接实现规则双向实时同步,无需安装额外组件。

可通过环境变量 HTTP_CATCH_WS_PORT 自定义端口。

数据存储

规则数据存储于 ~/.http-catch/rules.json,JSON 格式:

{
  "分类名": [
    {
      "id": "1700000000000",
      "urlPattern": "https://api.example.com/users*",
      "name": "users",
      "responseData": { "list": [], "total": 0 },
      "statusCode": 200,
      "category": "分类名",
      "enabled": true,
      "isAdvanced": true,
      "template": "{\"ts\": {{date.now}}}",
      "variants": [
        {
          "id": "v-1",
          "name": "成功",
          "responseData": { "code": 0, "data": [] },
          "statusCode": 200,
          "active": true
        },
        {
          "id": "v-2",
          "name": "服务异常",
          "responseData": { "code": 50001, "message": "error" },
          "statusCode": 500,
          "active": false
        }
      ],
      "createdAt": 1700000000000
    }
  ]
}

使用示例

以下是在 AI 对话中使用 MCP 工具的示例提示词:

  • 查看所有规则:"请列出当前所有网络拦截规则"
  • 添加基础规则:"帮我添加一条规则,拦截 https://api.example.com/users 接口,返回空列表 {"list":[]}"
  • 添加高级规则:"创建一条高级规则,开启 isAdvanced,并配置两个 variants(成功 / 失败)"
  • 切换生效场景:"把规则 xxx 切到 variant yyy"
  • 禁用规则:"请禁用 ID 为 xxx 的规则"
  • 批量管理:"把分类'测试环境'下的所有规则移到'生产环境'分类"

目录结构

mcp-server/
├── package.json
├── README.md          ← 本文件
├── bin/
│   └── cli.js         ← npx 入口
├── src/
│   ├── index.js       ← MCP Server 入口(stdio transport)
│   ├── storage.js     ← 本地 JSON 文件读写(原子写入)
│   ├── ws-bridge.js   ← WebSocket 桥接服务
│   └── tools/
│       ├── list_rules.js
│       ├── list_categories.js
│       ├── add_rule.js
│       ├── update_rule.js
│       ├── delete_rule.js
│       ├── toggle_rule.js
│       └── set_active_variant.js