Skip to main content

A Model Context Protocol (MCP) service for executing Windows terminal commands asynchronously

Project description

winterm-mcp

更新日期: 2026-01-16
版本: 0.1.1

Windows Terminal MCP Service - 专门支持 Windows 终端的异步命令执行工具。

功能特性

  • PowerShell 支持: 直接执行 PowerShell 命令(默认)
  • Cmd 支持: 可选执行 cmd 命令
  • 异步执行: 后台执行命令,立即返回 token
  • 状态查询: 查询命令执行状态和结果
  • 超时控制: 可设置超时时间(1-3600秒)
  • 工作目录: 指定执行目录
  • 自动编码: 自动处理 PowerShell (UTF-8) 和 Cmd (GBK) 编码

安装

cd winterm_mcp_standalone
pip install -e .

使用方法

MCP 配置

在 MCP 客户端配置中添加:

{
  "mcpServers": {
    "winterm-mcp": {
      "command": "winterm-mcp"
    }
  }
}

工具接口

run_command

异步执行 Windows 终端命令。

参数:

  • command (string): 要执行的命令(必填,1-1000字符)
  • shell_type (string, optional): Shell 类型,powershellcmd,默认 powershell
  • timeout (integer, optional): 超时秒数(1-3600),默认 30
  • working_directory (string, optional): 工作目录(可选,默认当前目录)

返回:

{
  "token": "uuid-string",
  "status": "pending",
  "message": "submitted"
}

query_command_status

查询命令执行状态和结果。

参数:

  • token (string): 命令 token

返回:

{
  "token": "uuid-string",
  "status": "completed",
  "exit_code": 0,
  "stdout": "command output",
  "stderr": "",
  "execution_time": 0.123,
  "timeout_occurred": false
}

使用示例

PowerShell 命令

# 获取当前日期
run_command("Get-Date")

# 列出进程
run_command("Get-Process | Select-Object -First 5")

# 构建项目
run_command("dotnet build", timeout=60, working_directory="d:/project")

Cmd 命令

# 列出目录
run_command("dir", shell_type="cmd")

# Ping 测试
run_command("ping 127.0.0.1 -n 4", shell_type="cmd")

查询命令状态

# 提交命令
result = run_command("Get-Process")
token = result["token"]

# 查询状态
status = query_command_status(token)
if status["status"] == "completed":
    print(status["stdout"])

技术架构

  • 框架: FastMCP
  • 并发: 多线程异步执行
  • 编码: 自动处理 UTF-8 和 GBK
  • 平台: Windows

与 runcmd-mcp 的区别

特性 runcmd-mcp winterm-mcp
Shell 类型 仅 cmd PowerShell + Cmd
Windows 支持 部分 完整
编码处理 固定 自动适配
平台 跨平台 Windows 专用

许可证

MIT License

贡献

欢迎提交 Issue 和 Pull Request。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

winterm_mcp-0.1.1.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

winterm_mcp-0.1.1-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file winterm_mcp-0.1.1.tar.gz.

File metadata

  • Download URL: winterm_mcp-0.1.1.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for winterm_mcp-0.1.1.tar.gz
Algorithm Hash digest
SHA256 fa77263f657aa42397d9b922e84e01e9940a111fd25cb42942c226b63be6c0ac
MD5 926b041a3921c59351d4952a3e8b4641
BLAKE2b-256 09359ef517a9f48751c79823a4c8a0b6f71b575a777c3afcca21a7bbf4c0d681

See more details on using hashes here.

File details

Details for the file winterm_mcp-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: winterm_mcp-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for winterm_mcp-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 31662b20d3ce03d636fbdf7f0493fad2a67c2cd7cfd90e04d853c7c3c8abeb06
MD5 de296d75c46512fe5c1687b23c5efe30
BLAKE2b-256 0d3504f13ddda3661fba3cb75ff00582430a486642ea1096f9b094f0e140c038

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page