Skip to main content
Glama
MCP PC Control Server

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 - 读取环境变量(单个或全部)

Related MCP server: Enhanced File Operations MCP Server

安装

  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
}
{ path: string, pattern: string }  // pattern supports * and **
{
  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_command 和 delete_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 参数

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

Available Tools

11 tools
create_directoryA

Create a new directory or ensure a directory exists. Can create multiple nested directories in one operation. If the directory already exists, this operation will succeed silently.

Inputs: path (required).

delete_directoryA

Permanently delete a directory and all of its contents, including all files and subdirectories. This is a recursive operation that cannot be undone. Use with extreme caution.

Inputs: path (required).

delete_fileA

Permanently delete a file from the file system. This operation cannot be undone. The file is immediately removed from the storage device.

Inputs: path (required).

edit_fileA

Make line-based edits to a text file. Provide original lines and their replacements. Returns a git-style diff showing the changes made. Each edit replaces exact line sequences with new content.

Inputs: path (required), edits (required).

execute_commandA

Execute shell commands on the system. SECURITY WARNING: This tool provides direct system access. Only use with trusted commands. Commands run with the same permissions as the MCP server process.

Inputs: command (required), workingDirectory.

get_file_infoA

Retrieve detailed metadata about a file or directory, including size, creation time, modification time, access time, type, and permissions. This does not read file contents.

Inputs: path (required).

list_directoryA

Get a detailed listing of all files and directories in a specified path. Results include names, types (file/directory), sizes, and modification times. Useful for understanding directory structure and finding files.

Inputs: path (required).

move_fileA

Move or rename files and directories. Can move files between directories and rename them in a single operation. If the destination exists, the operation will fail.

Inputs: source (required), destination (required).

read_fileA

Read the complete contents of a file from the file system. Handles various text encodings and returns the full file content. Use this to examine file contents before editing.

Inputs: path (required).

search_filesA

Recursively search for files matching a pattern in a directory. Supports wildcards (* and **) and returns matching file paths. Useful for finding files by name or extension.

Inputs: path (required), pattern (required).

write_fileA

Create a new file or completely overwrite an existing file with new content. Use with caution as it will overwrite existing files without warning. Handles text content with proper encoding.

Inputs: path (required), content (required).

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A4.3/5.0

    Scored across 11 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose with no ambiguity: create_directory vs. delete_directory, read_file vs. edit_file vs. write_file, list_directory vs. search_files, etc. The descriptions reinforce unique roles, such as get_file_info for metadata only and execute_command for shell operations, preventing misselection.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun pattern using snake_case, such as create_directory, delete_file, and execute_command. This predictable naming scheme makes it easy for agents to understand and use the tools without confusion from mixed conventions.

    Tool Count5/5

    With 11 tools, the server is well-scoped for PC control, covering essential file system operations (CRUD for files/directories), metadata retrieval, searching, and command execution. Each tool earns its place without being overwhelming or insufficient for the domain.

    Completeness5/5

    The tool set provides complete coverage for file system management: create, read, edit, write, delete, move, list, search, and get info for files and directories, plus execute_command for broader system control. There are no obvious gaps, enabling agents to handle full workflows without dead ends.

    Maintenance

    ActivityInactive
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      D
      quality
      D
      maintenance
      Enables AI models to perform file system operations (reading, creating, and listing files) on a local file system through a standardized Model Context Protocol interface.
      3
      ISC
    • F
      license
      Not graded
      quality
      C
      maintenance
      A comprehensive Model Context Protocol server that provides over 50 file and system management tools for AI models, including navigation, file operations, search, compression, and system information capabilities.
      -
    • A
      license
      A
      quality
      D
      maintenance
      A comprehensive Model Context Protocol server that enables AI assistants to interact with and manage Windows systems, providing capabilities for file system operations, process management, system information retrieval, registry operations, service management, network diagnostics, and performance monitoring.
      7
      16 npm
      6
      Apache 2.0