使用说明
MCP-CLI
带有MCP(模型上下文协议)服务器插件系统的通用CLI框架。
安装
# Install CLI (includes proxy plugin)
npm install -g @kvirund/mcp-cli
# Install additional plugins
npm install -g @kvirund/mcp-cli-plugin-browser
npm install -g @kvirund/mcp-cli-plugin-nasa-apod
npm install -g @kvirund/mcp-cli-plugin-url-downloader
结构
packages/
core/ - Core CLI framework with plugin system
plugin-browser/ - Browser automation via Chrome DevTools Protocol
plugin-proxy/ - Proxy plugin for connecting external MCP servers
plugin-nasa-apod/ - NASA APOD integration
plugin-url-downloader/ - URL downloading utilities
需求
- Node.js>=18.0.0
用法
交互模式
# Start interactive CLI
mcp-cli
# With specific plugins
mcp-cli -p @kvirund/mcp-cli-plugin-browser
服务器模式
# Start as stdio server (for Claude Desktop, etc.)
mcp-cli serve
# Start as SSE server
mcp-cli serve --mode sse --port 3000
命令
| 命令 | 别名 | 描述 |
|---|---|---|
help [topic] |
?, h |
显示命令或插件的帮助 |
plugins [action] [name] |
plugin, pl |
管理插件(列表、启用、禁用) |
tools [action] [plugin] [tool] |
tool |
管理插件工具(列表、启用、禁用) |
logs [action|count] |
log |
查看/流式传输MCP工具调用日志 |
serve [port] |
mcp |
启动MCP SSE服务器 |
stop |
停止MCP SSE服务器 | |
clear |
cls |
清除屏幕 |
exit |
quit, q |
退出CLI |
MCP服务器
MCP SSE服务器可以通过以下方式启动 serve 命令。默认端口为3000。
终点:
- 上海证券交易所
http://localhost:3000/sse - 健康:
http://localhost:3000/health
配置
配置文件: ~/.mcp-cli/config.json
{
"mcp": {
"port": 3000
},
"plugins": {
"browser": {
"package": "@kvirund/mcp-cli-plugin-browser"
},
"nasa": {
"package": "@kvirund/mcp-cli-plugin-nasa-apod",
"config": {
"apiKey": "your-nasa-api-key"
}
},
"filesystem": {
"package": "@kvirund/mcp-cli-plugin-proxy",
"config": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path"],
"autoConnect": true
},
"disabledTools": ["write_file"]
}
}
}
配置选项
| 选项 | 默认值 | 描述 |
|---|---|---|
mcp.port |
3000 |
MCP SSE服务器的默认端口 |
plugins |
{} |
插件词典(关键字=插件名称) |
插件条目格式
| 字段 | 必填 | 描述 |
|---|---|---|
package |
是 | 要加载的npm包名称 |
config |
否 | 插件特定配置 |
disabledTools |
否 | 要禁用的工具名称列表 |
插件
模块化插件架构。每个插件都可以提供命令和MCP工具。
可用插件
- @kvirund/mcp-cli插件浏览器 -通过Chrome DevTools协议实现浏览器自动化
- @kvirund/mcp-cli插件代理 -连接外部MCP服务器(stdio/SSE)
- @kvirund/mcp-cli插件nasa apod -美国国家航空航天局当天的天文图片
- @kvirund/mcp-cli插件url下载器 -用于获取URL的HTTP客户端
代理插件
代理插件允许连接到外部MCP服务器并公开其工具:
{
"plugins": {
"github": {
"package": "@kvirund/mcp-cli-plugin-proxy",
"config": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": { "GITHUB_TOKEN": "..." },
"autoConnect": true
}
},
"remote-server": {
"package": "@kvirund/mcp-cli-plugin-proxy",
"config": {
"url": "http://localhost:4000/sse"
}
}
}
}
代理插件命令:
connect-连接到MCP服务器disconnect-断开与服务器的连接restart-重新启动连接status-显示连接状态和工具
工具管理
可以禁用单个插件工具,而无需禁用整个插件:
# List all tools
tools list
# List tools for specific plugin
tools list browser
# Disable a tool
tools disable browser screenshot
# Enable a tool
tools enable browser screenshot
工具调用记录
查看和流式传输MCP工具调用:
# Show last 20 log entries
logs
# Show last 50 entries
logs 50
# Enable real-time log streaming
logs on
# Disable log streaming
logs off
# Clear log history
logs clear
在配置中配置默认流状态:
{
"logging": {
"streamByDefault": true
}
}
发展
# Install dependencies
npm install
# Build all packages
npm run build
# Run tests
npm test
# Run tests with coverage
npm run test:coverage
许可证
麻省理工学院
