MCP CLI服务器🚀
一个强大的 模型上下文协议(MCP)服务器 它使AI助手能够通过灵活的配置驱动界面执行命令行工具。通过简单的JSON配置,将任何命令行实用程序转换为AI可访问的工具。
 ](https://nodejs.org/) 
✨ 特性
- 🔧 配置驱动:通过JSON配置文件定义命令
- 🛡️ Type-Safe:使用TypeScript构建,并使用Zod和AJV进行全面验证
- 📋 灵活的论点:默认情况下支持字符串、数字和布尔参数
- 🔍 调试支持:具有调试和详细模式的全面日志记录
- ⚡ 快速可靠:基于官方MCP SDK构建,具有强大的错误处理功能
- 🌐 交叉平台的:适用于Windows、macOS和Linux
🚀 快速开始
安装
# Install globally via npm
npm install -g mcp-cli基本用法
- 创建配置文件 (
config.json):
{
"version": "1.0",
"commands": [
{
"name": "echo",
"description": "Echo a message to the console",
"command": "echo",
"arguments": [
{
"name": "message",
"description": "The message to echo",
"type": "string",
"required": true
}
]
},
{
"name": "list-files",
"description": "List files in a directory",
"command": "dir",
"arguments": [
{
"name": "path",
"description": "The directory path to list",
"type": "string",
"required": false,
"defaultValue": "."
}
]
}
]
}- 运行MCP服务器:
# Using config file
mcp-cli --config-file ./config.json
# Using inline JSON config
mcp-cli --config '{"version":"1.0","commands":[...]}'
# With environment variable (config file path)
set MCP_CLI_CONFIG_PATH=./config.json
mcp-cli
# With environment variable (raw JSON config)
set MCP_CLI_CONFIG_JSON={"version":"1.0","commands":[{"name":"echo","description":"Echo a message","command":"echo","arguments":[{"name":"message","description":"The message to echo","type":"string","required":true}]}]}
mcp-cli
# Streaming config via pipe (Windows)
type config.json | mcp-cli
# Streaming config via pipe (Unix/Linux/macOS)
cat config.json | mcp-cli- 连接您的AI助手 连接到MCP服务器并开始执行命令!
📖 配置参考
配置文件结构
{
"version": "1.0",
"commands": [
{
"name": "command-name",
"description": "Description of what this command does",
"command": "actual-cli-command",
"arguments": [
{
"name": "arg-name",
"description": "Argument description",
"type": "string|number|boolean",
"required": true|false,
"defaultValue": "optional-default"
}
]
}
]
}命令参数
| 属性 | 类型 | 必填 | 描述 | ||
|---|---|---|---|---|---|
name | string | ✅ | 参数名称 | ||
description | string | ✅ | 人类可读的描述 | ||
type | "string" | "number" | "boolean" | ✅ | 参数数据类型 |
required | boolean | ✅ | 该论点是否具有强制性 | ||
defaultValue | string | number | boolean | ❌ | 默认值(如果未提供) |
🤝 贡献
有兴趣贡献吗?查看我们的 贡献指南 用于开发设置、构建说明和指南。
� 许可证
Git命令
{
"version": "1.0",
"commands": [
{
"name": "git-status",
"description": "Check Git repository status",
"command": "git status",
"arguments": []
},
{
"name": "git-commit",
"description": "Commit changes with a message",
"command": "git commit",
"arguments": [
{
"name": "message",
"description": "Commit message",
"type": "string",
"required": true
},
{
"name": "all",
"description": "Stage all changes",
"type": "boolean",
"required": false,
"defaultValue": false
}
]
}
]
}系统信息
{
"version": "1.0",
"commands": [
{
"name": "system-info",
"description": "Display system information",
"command": "systeminfo",
"arguments": []
},
{
"name": "disk-usage",
"description": "Show disk usage",
"command": "dir",
"arguments": [
{
"name": "drive",
"description": "Drive letter to check",
"type": "string",
"required": false,
"defaultValue": "C:\\"
}
]
}
]
}🤝 贡献
有兴趣贡献吗?查看我们的 贡献指南 用于开发设置、构建说明和指南。
📄 许可证
此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。
🙏 致谢
- 与 模型上下文协议SDK
- 由...驱动 拉什堆栈 工具
- 验证由提供 萨德 和 阿联酋
📚 相关项目
______________________________________________________________________
由以下材料制成❤️ 对于AI社区
