Kiro IDE MCP Server - 快速入门指南
您将获得什么
直接在 Kiro IDE 中用简单的英语提问:
- "Which model is consuming the most tokens?"
- "What's the average latency for Claude Haiku?"
- "Estimate my LLM costs for the last hour"
无需切换到 dashboard 或编写复杂的查询!
步骤 1:在 Kiro 中配置 MCP Server
选项 A:使用工作区配置(推荐)
-
创建 MCP 配置目录:
mkdir -p .kiro/settings -
复制 MCP 配置:
cp AI-OBS_DEMO/kiro-mcp-config.json .kiro/settings/mcp.json -
更新配置中的路径(如需要): 打开
.kiro/settings/mcp.json并验证cloudwatch_mcp_server.py的路径正确:{
"mcpServers": {
"ai-observability": {
"command": "python3",
"args": [
"/path/to/mcp-server/cloudwatch_mcp_server.py"
],
"env": {
"AWS_REGION": "your-aws-region"
},
"disabled": false,
"autoApprove": []
}
}
}
选项 B:使用用户级配置(全局)
-
创建用户配置目录:
mkdir -p ~/.kiro/settings -
复制配置:
cp AI-OBS_DEMO/kiro-mcp-config.json ~/.kiro/settings/mcp.json
步骤 2:验证 AWS 凭证
MCP server 需要 AWS 凭证来查询 CloudWatch:
# Check your AWS credentials are configured
aws sts get-caller-identity
# Should show:
# {
# "UserId": "...",
# "Account": "<your-account-id>",
# "Arn": "arn:aws:iam::<your-account-id>:user/<your-username>"
# }
如果尚未配置,设置 AWS 凭证:
aws configure
# Enter your AWS Access Key ID
# Enter your AWS Secret Access Key
# Default region: your-aws-region
# Default output format: json
步骤 3:测试 MCP Server(可选)
在 Kiro 中使用之前,验证 MCP server 是否工作:
python3 AI-OBS_DEMO/test-mcp-server.py
您应该看到类似以下的输出:
Testing CloudWatch MCP Server
==============================
1. Testing get_token_usage...
Success: {
"token_type": "input",
"time_range_hours": 1,
"models": [...]
}
2. Testing get_model_latency...
Success: {...}
步骤 4:重启 Kiro IDE
为了让 Kiro 加载 MCP 配置:
- 保存所有工作
- 完全退出 Kiro(Mac 上 Cmd+Q,或 文件 -> 退出)
- 重新打开 Kiro
- 打开您的工作区(包含
.kiro/settings/mcp.json的文件夹)
步骤 5:验证 MCP Server 已连接
- 打开 Kiro 功能面板(左侧边栏)
- 查找 "MCP Servers" 部分
- 您应该看到:
ai-observability带有绿色状态指示器 - 如果看到红色指示器:点击查看错误详情
连接问题故障排除
如果 server 显示为断开连接:
- 检查 MCP Server 视图,在 Kiro 的左侧面板中
- 点击"重新连接"(如果可用)
- 检查日志:在 MCP server 输出中查找错误消息
- 验证 Python 路 径:确保
python3在您的 PATH 中 - 检查文件权限:确保
cloudwatch_mcp_server.py可读
步骤 6:使用自然语言查询
在 Kiro 聊天中
- 打开 Kiro 聊天(Cmd+L 或点击聊天图标)
- 输入您的问题,使用简单的英语:
Which model is consuming the most tokens?
- Kiro 将自动:
- 识别这是一个可观测性 查询
- 调用 MCP server 的
get_token_usage工具 - 返回结构化结果
尝试的示例查询
1. Token 使用量
Which model is consuming the most tokens?
预期响应:
{
"token_type": "input",
"time_range_hours": 1,
"models": [
{
"model": "anthropic.claude-3-haiku-20240307-v1:0",
"total_tokens": 475
},
{
"model": "gpt-4o",
"total_tokens": 312
}
]
}
2. 延迟统计
What's the average latency for all models?
预期响应:
{
"time_range_hours": 1,
"models": [
{
"model": "anthropic.claude-3-sonnet-20240229-v1:0",
"avg_latency_ms": 2567.89
},
{
"model": "gpt-4o",
"avg_latency_ms": 2234.12
}
]
}