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

computer_mcp

v1.0.8

Published

MCP Streamable HTTP Server with file and command execution tools

Readme

Computer MCP Server

一个基于 Model Context Protocol (MCP) 的 Streamable HTTP 服务器,提供命令执行、文件读写编辑、搜索与补丁能力。

功能特性

  • bash - 运行系统命令并实时返回输出
  • read - 读取文件或目录,支持分页
  • write - 创建或覆盖文本文件
  • edit - 按 oldString/newString 修改文本文件
  • grep - 按正则搜索文件内容
  • glob - 按 glob 模式查找文件
  • apply_patch - 应用补丁(支持 wrapped patch 和 unified diff)
  • 实时通知 - 命令执行过程中发送 MCP 通知消息
  • Streamable HTTP - 使用 HTTP 流式传输协议

安装

npm install

启动服务器

# 生产模式
npm start

# 开发模式(自动重启)
npm run dev

服务器默认运行在端口 3000,可以通过环境变量 PORT 修改:

PORT=8080 npm start

端点

  • MCP 端点: POST http://localhost:3000/mcp
  • 健康检查: GET http://localhost:3000/health

工具说明

1. bash - 执行命令

执行系统命令并返回结果。执行过程中会发送多条通知消息。

参数:

  • command (必需): 要执行的命令
  • args (可选): 命令参数数组
  • cwd (可选): 工作目录
  • timeout (可选): 超时时间(毫秒,默认 30000)

示例:

{
  "command": "ls",
  "args": ["-la"],
  "cwd": "/home/user"
}

返回:

{
  "exitCode": 0,
  "stdout": "...",
  "stderr": "...",
  "success": true
}

2. read - 读取文件/目录

读取文本文件或目录内容,支持 offset / limit 分页。

参数:

  • filePath (必需): 文件或目录路径
  • offset (可选): 起始行号/条目序号(从 1 开始)
  • limit (可选): 最多读取行数/条目数(默认 2000)

示例:

{
  "filePath": "/path/to/file.txt",
  "offset": 1,
  "limit": 200
}

3. write - 写入文件

写入内容到文本文件,如果文件已存在会被覆盖(自动创建父目录)。

参数:

  • filePath (必需): 文件路径
  • content (必需): 要写入的内容

示例:

{
  "filePath": "/path/to/file.txt",
  "content": "Hello, World!"
}

4. edit - 修改文件

修改文本文件的内容,按 oldString/newString 替换。

参数:

  • filePath (必需): 文件路径
  • oldString (必需): 要替换的原文
  • newString (必需): 替换后的文本
  • replaceAll (可选): 是否替换全部匹配(默认 false)

示例:

{
  "filePath": "/path/to/file.txt",
  "oldString": "old text",
  "newString": "new text",
  "replaceAll": true
}

5. grep - 内容搜索

按正则搜索文件内容。

参数:

  • pattern (必需): 正则模式
  • path (可选): 搜索根路径(默认当前目录)
  • include (可选): 文件过滤模式(如 *.js

6. glob - 文件匹配

按 glob 模式列出文件。

参数:

  • pattern (必需): glob 模式(如 **/*.js
  • path (可选): 搜索目录(默认当前目录)

7. apply_patch - 应用补丁

应用补丁文本。支持两种格式:

  • Wrapped patch(*** Begin Patch ... *** End Patch
  • Unified diff(--- / +++ / @@

参数:

  • patchText (必需): 完整补丁文本

通知消息

在执行命令时,服务器会发送多条 MCP 通知消息:

  • info: 命令开始执行、执行完成
  • debug: 标准输出内容
  • warning: 标准错误输出、超时警告
  • error: 执行错误

Docker 部署

# 构建镜像
./dockerBuild.sh

# 运行容器
docker run -d -p 3000:3000 computer-mcp-server

测试

使用 curl 测试健康检查:

curl http://localhost:3000/health

测试 MCP 端点需要发送符合 MCP 协议的 JSON-RPC 请求。

技术栈

  • Node.js
  • Express.js
  • @modelcontextprotocol/sdk
  • ES Modules

许可证

ISC