Skip to main content
Glama
koopatroopa787

MCP PC Control Server

MCP PC 控制服务器

一个功能强大的模型上下文协议 (MCP) 服务器,提供全面的 PC 控制功能,包括文件操作、目录管理、命令执行、系统检查和进程管理。旨在让 AI 助手(Claude、GPT、Gemini 等)能够全面、高效地控制宿主机。

功能特性

文件操作

  • read_file - 使用正确的编码读取完整文件内容

  • read_file_lines - 从文件中读取特定行范围(对大文件高效)

  • write_file - 创建新文件或覆盖现有文件

  • append_to_file - 将内容追加到文件而不覆盖它

  • edit_file - 进行精确的文本编辑并输出差异 (diff)

  • copy_file - 将文件复制到新位置(保留源文件)

  • delete_file - 从文件系统中删除文件

  • move_file - 移动或重命名文件和目录

  • get_file_info - 获取详细的文件元数据(大小、时间戳、权限、可读性)

目录操作

  • create_directory - 创建目录(支持嵌套创建)

  • list_directory - 列出目录内容并提供详细信息

  • delete_directory - 递归删除目录及其内容

  • search_files - 递归搜索匹配名称模式的文件

内容搜索

  • search_in_files - 在文件中进行类似 grep 的文本内容搜索,支持可选的文件模式过滤和不区分大小写模式

系统操作

  • execute_command - 执行 Shell 命令,支持可选的工作目录和可配置的超时时间

  • get_system_info - 获取操作系统、CPU、内存、运行时间、主机名和网络接口详细信息

  • list_processes - 列出正在运行的进程,支持可选的名称过滤

  • get_environment - 读取环境变量(单个或全部)

安装

  1. 克隆或下载此仓库

  2. 安装依赖:

npm install
  1. 构建项目:

npm run build

使用方法

运行服务器

服务器通过 stdio 进行通信,旨在与 MCP 客户端配合使用:

npm start

配置 Claude Desktop

将此服务器添加到您的 Claude Desktop 配置文件中:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

Windows: %APPDATA%/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "pc-control": {
      "command": "node",
      "args": ["/absolute/path/to/first_mcp/build/index.js"]
    }
  }
}

/absolute/path/to/first_mcp 替换为该项目目录的实际绝对路径。

与其他 AI 客户端配置

任何兼容 MCP 的客户端(Claude、Cursor、Windsurf、Continue 等)都可以使用相同的 stdio 传输方式连接到此服务器。使用 node 指向构建好的 build/index.js

使用 npx 的示例(替代方案)

{
  "mcpServers": {
    "pc-control": {
      "command": "npx",
      "args": ["-y", "mcp-pc-control-server"]
    }
  }
}

可用工具

read_file

{ path: string }

read_file_lines

{
  path: string,
  start: number,  // 1-based, inclusive
  end?: number    // 1-based, inclusive (omit to read to end)
}

write_file

{ path: string, content: string }

append_to_file

{ path: string, content: string }

edit_file

{
  path: string,
  edits: [{ oldText: string, newText: string }]
}

copy_file

{ source: string, destination: string }

create_directory

{ path: string }

list_directory

{ path: string }

delete_file

{ path: string }

delete_directory

{ path: string }

move_file

{ source: string, destination: string }

get_file_info

{ path: string }

execute_command

{
  command: string,
  workingDirectory?: string,
  timeout?: number  // ms, default 30000
}

search_files

{ path: string, pattern: string }  // pattern supports * and **

search_in_files

{
  path: string,
  query: string,
  filePattern?: string,     // e.g. "*.ts"
  caseSensitive?: boolean   // default false
}

get_system_info

{}  // no arguments required

list_processes

{ filter?: string }  // optional substring filter on process name

get_environment

{ variable?: string }  // omit to get all env vars

安全注意事项

警告: 此服务器提供强大的文件系统和命令执行功能。

  • 文件访问: 可以读取、写入和删除进程拥有权限的任何文件

  • 命令执行: 可以执行任意 Shell 命令

  • 无沙箱: 操作未经过沙箱处理或限制

建议:

  • 仅与受信任的 MCP 客户端一起使用

  • 以最小必要权限运行

  • 谨慎使用 execute_commanddelete_directory 工具

  • 考虑在生产环境中使用时实施额外的访问控制

  • 在敏感环境中审查所有操作

开发

构建

npm run build

监视模式

npm run watch

项目结构

.
├── src/
│   └── index.ts          # Main server implementation
├── build/                # Compiled JavaScript (generated)
├── package.json
├── tsconfig.json
└── README.md

许可证

MIT

贡献

欢迎贡献!请随时提交问题或拉取请求。

故障排除

服务器未出现在 Claude Desktop 中

  1. 检查 claude_desktop_config.json 中的路径是否为绝对路径且正确

  2. 验证构建目录是否存在并包含 index.js

  3. 配置更改后重启 Claude Desktop

  4. 检查 Claude Desktop 日志以获取错误信息

权限错误

  • 确保服务器进程具有必要的文件系统权限

  • 在 Unix 系统上,使用 ls -la 检查文件/目录权限

  • 以您所需操作的适当用户权限运行

命令执行问题

  • 验证工作目录是否存在且可访问

  • 检查 Shell 命令是否适合您的操作系统

  • 为长时间运行的命令增加 timeout 参数

  • 某些命令可能需要特定的环境变量

Install Server
A
security – no known vulnerabilities
F
license - not found
-
quality - not tested

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/koopatroopa787/first_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server