Model Context Protocol (MCP)是一个开源标准,让AI应用(如Kiro CLI)能够访问外部系统的数据或工具。
MCP servers大致可以分为本地MCP servers和远程MCP servers。本地MCP servers需要首先在本地安装,然后注册。远程MCP servers直接注册。
注册MCP servers
在Kiro CLI能够使用一个MCP server之前,首先需要注册该MCP server。可以注册MCP servers到MCP配置文件中,如~/.kiro/settings/mcp.json,也可以在Agent中直接注册MCP servers。
MCP配置文件根据路径不同,也分为Global和Workspace。修改MCP配置文件,可以直接编辑JSON文件,也可以使用kiro-cli mcp命令。
# Add new MCP server
kiro-cli mcp add \
--name "git" \
--scope global \
--command "mcp-server-git" \
--args "--stdio" \
--env "GIT_DIR=/path/to/repo" \
--disabled false
直接在Agent中注册MCP servers如下:
{
"name": "my-agent",
"allowedTools": ["@git"],
"mcpServers": {
"git": {
"command": "mcp-server-git",
"args": ["--stdio"],
"timeout": 120000
}
},
"includeMcpJson": false
}
注意:这里的includeMcpJson属性表示该Agent是否自动包含mcp.json中注册的MCP servers。
注册完成后,在Kiro Chat的对话中就可以使用**/mcp**命令看到已经注册的MCP servers。
使用MCP servers
注册后的MCP servers,就可以在Kiro Chat的对话中,根据用户的请求分析调用MCP servers提供的tools。当然,用户也可以直接调用MCP servers提供的tool,如**@git/git_log**直接调用mcp-server-git提供的git_log。