Jarvis MCP 服务器是一个基于模型上下文协议(MCP)的实现,它提供了强大的 AI 助手功能,同时集成了丰富的系统工具,为用户与 AI 模型的交互提供了标准化的解决方案。
Jarvis MCP 服务器通过模型上下文协议(MCP)实现与 AI 模型的无缝集成,提供了一种标准化的方式来与 AI 助手进行交互,并有效管理上下文。该服务器采用 Go 语言构建,具有高性能和高可靠性的特点。
git clone (https://github.com/can-acar/jarvis)
cd jarvis
go mod download
go build -o jarvis main.go
./jarvis
服务器将启动,并通过标准输入输出使用 MCP 协议进行通信。
服务器使用 config.yaml
文件进行配置:
# 安全设置
blockedCommands:
- rm
- shutdown
# 命令执行的默认 shell
defaultShell: bash
# 文件操作允许的目录
allowedDirectories:
- /tmp
- /var/log
# 文件操作限制
fileReadLineLimit: 1000
fileWriteLineLimit: 50
# 遥测
telemetryEnabled: false
服务器提供以下 MCP 工具:
get - config
- 获取当前服务器配置set - config
- 更新服务器配置值execute - command
- 在安全控制下执行 shell 命令get - command - history
- 获取命令执行历史read - file
- 支持分页读取文件内容write - file
- 向文件写入内容list - directory
- 列出目录内容create - directory
- 创建新目录delete - file
- 删除文件和目录move - file
- 移动/重命名文件和目录file - info
- 获取文件元数据和信息edit - file
- 执行复杂的文本编辑操作search - replace
- 在文件中搜索和替换文本batch - edit
- 对文件应用多个编辑操作fetch - url
- 从网页 URL 抓取内容download - file
- 从远程源下载文件jarvis/
├── main.go # 主服务器入口点
├── config.yaml # 服务器配置
├── go.mod # Go 模块定义
├── go.sum # Go 模块校验和
├── handlers/ # MCP 工具处理程序
│ ├── config_handler.go # 配置管理
│ ├── terminal_handler.go # 终端操作
│ ├── filesystem_handler.go # 文件系统操作
│ ├── textediting_handler.go # 文本编辑工具
│ └── fetch_handler.go # HTTP 抓取操作
└── internal/ # 内部包
├── common/ # 共享实用程序
├── config/ # 配置管理
├── terminal/ # 终端实用程序
├── filesystem/ # 文件系统实用程序
├── textedit/ # 文本编辑实用程序
├── fetch/ # 抓取实用程序
└── types/ # 类型定义
# 构建项目
go build -o jarvis main.go
# 运行测试
go test ./...
# 运行并开启详细日志
go run main.go
# 为不同平台构建
GOOS=windows GOARCH=amd64 go build -o jarvis.exe main.go
GOOS=linux GOARCH=amd64 go build -o jarvis-linux main.go
要添加新的 MCP 工具,请按以下步骤操作:
func HandleNewTool(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
// 实现代码
return mcp.NewToolResultText("Result"), nil
}
func RegisterNewTools(s *server.MCPServer) {
s.AddTool("new - tool", "Description", map[string]interface{}{
"type": "object",
"properties": map[string]interface{}{
"param": map[string]interface{}{
"type": "string",
"description": "Parameter description",
},
},
"required": []string{"param"},
}, handlers.HandleNewTool)
}
main.go
中调用注册函数。git checkout -b feature - name
go fmt ./...
go test ./...
git commit -m 'Add feature'
git push origin feature - name
本项目采用 MIT 许可证,请参阅 LICENSE 文件获取详细信息。
若您需要支持或有疑问,可以: