Kiro CLI MCP Server
Enables IDE agents like Cursor and Windsurf to orchestrate kiro-cli with advanced session management, process pooling for 10x faster responses, and multi-project workflow support through isolated contexts.
README
Kiro CLI MCP Server
A Model Context Protocol (MCP) server that enables IDE agents like Cursor and Windsurf to orchestrate kiro-cli with advanced session management, process pooling, and robust error handling.
Overview
Kiro CLI MCP Server bridges the gap between IDE agents and kiro-cli by providing a standardized MCP interface with enterprise-grade features:
- 10x Performance Improvement: Process pooling reduces response time from ~500ms to ~50ms
- Multi-Session Management: Isolated contexts for different projects/workflows
- Production-Ready Reliability: Comprehensive error handling, timeout management, and process cleanup
- Mock Mode: Development and testing without kiro-cli dependency
Features
Core Capabilities
- Chat Integration: Send messages to kiro-cli and receive AI responses
- Session Management: Create, switch, and manage multiple isolated sessions
- Command Execution: Execute kiro-cli commands (
/help,/mcp, etc.) - Custom Agents: Use and list available custom agents
- History Management: Store and retrieve conversation history per session
- Async Operations: Background task execution with progress polling
Performance & Reliability
- Process Pooling: Reuse warm kiro-cli processes for 10x faster responses
- Process Tree Cleanup: Prevent orphaned processes across platforms
- Automatic Fallback: Mock mode when kiro-cli unavailable
- Timeout Handling: Configurable timeouts with graceful cleanup
- Session Isolation: Per-project working directories and conversation state
Installation
Prerequisites
- Python 3.10+
- kiro-cli installed and available in PATH (for full functionality - uses mock mode if unavailable)
From Source (Current Method)
git clone https://github.com/your-org/kiro-cli-mcp.git
cd kiro-cli-mcp
pip install -e .
Via pip (After PyPI Publication)
# Will be available after publishing to PyPI
pip install kiro-cli-mcp
Via uvx (After PyPI Publication)
# Will be available after publishing to PyPI
uvx install kiro-cli-mcp
Configuration
IDE Integration
Add to your IDE's MCP configuration file:
Cursor/Claude Desktop (~/.config/claude-desktop/mcp.json):
{
"mcpServers": {
"kiro-cli-mcp": {
"command": "uvx",
"args": ["kiro-cli-mcp"],
"env": {
"KIRO_MCP_LOG_LEVEL": "INFO"
}
}
}
}
Windsurf (.windsurf/mcp.json):
{
"mcpServers": {
"kiro-cli-mcp": {
"command": "python",
"args": ["-m", "kiro_cli_mcp"],
"env": {
"KIRO_MCP_CLI_PATH": "/usr/local/bin/kiro-cli",
"KIRO_MCP_POOL_SIZE": "5"
},
"autoApprove": [
"kiro_session_list",
"kiro_agents_list",
"kiro_history"
]
}
}
}
Environment Variables
| Variable | Description | Default |
|---|---|---|
KIRO_MCP_CLI_PATH |
Path to kiro-cli executable | kiro-cli |
KIRO_MCP_COMMAND_TIMEOUT |
Command timeout (seconds) - IDE-optimized | 30 |
KIRO_MCP_MAX_SESSIONS |
Maximum concurrent sessions | 10 |
KIRO_MCP_SESSION_TIMEOUT |
Session idle timeout (seconds) | 300 |
KIRO_MCP_CLEANUP_INTERVAL |
Session cleanup check interval (seconds) | 30 |
KIRO_MCP_LOG_LEVEL |
Logging level | INFO |
KIRO_MCP_DEFAULT_MODEL |
Default AI model for kiro-cli | claude-opus-4.5 |
KIRO_MCP_DEFAULT_AGENT |
Default agent to use | kiro_default |
KIRO_MCP_LOG_RESPONSE |
Log full CLI responses for debugging | true |
KIRO_MCP_POOL_SIZE |
Process pool size | 5 |
KIRO_MCP_POOL_ENABLED |
Enable process pooling | true |
KIRO_MCP_POOL_IDLE_TIME |
Process idle time before recycling (seconds) | 300 |
KIRO_MCP_POOL_MAX_USES |
Max uses per process before recycling | 100 |
KIRO_MCP_MAX_ASYNC_TASKS |
Maximum concurrent async tasks | 100 |
KIRO_MCP_TASK_TTL |
Task result TTL (seconds) | 3600 |
Available MCP Tools
Session Management
kiro_session_create- Create new session with optional agent and working directorykiro_session_list- List all active sessionskiro_session_switch- Switch to specific sessionkiro_session_end- End a sessionkiro_session_clear- Clear session history fileskiro_session_save- Save session to file
Chat & Commands
kiro_chat- Send chat message and get AI responsekiro_command- Execute kiro-cli commands (/help,/mcp, etc.)kiro_agents_list- List available custom agents
History Management
kiro_history- Get conversation history for sessionkiro_history_clear- Clear conversation history
Async Operations
kiro_chat_async- Start background chat taskkiro_task_status- Poll task progress and resultskiro_task_cancel- Cancel running taskkiro_task_list- List active tasks
Monitoring
kiro_pool_stats- Get process pool performance statistics
Usage Examples
Basic Chat
# Create session for project
await mcp_client.call_tool("kiro_session_create", {
"working_directory": "/path/to/project",
"agent": "code-reviewer"
})
# Send message
response = await mcp_client.call_tool("kiro_chat", {
"message": "Analyze this codebase and suggest improvements"
})
Multi-Project Workflow
# Project A
session_a = await mcp_client.call_tool("kiro_session_create", {
"working_directory": "/projects/frontend",
"agent": "react-expert"
})
# Project B
session_b = await mcp_client.call_tool("kiro_session_create", {
"working_directory": "/projects/backend",
"agent": "python-expert"
})
# Switch between projects
await mcp_client.call_tool("kiro_session_switch", {
"session_id": session_a["session_id"]
})
Async Operations
# Start long-running task
task = await mcp_client.call_tool("kiro_chat_async", {
"message": "Generate comprehensive test suite"
})
# Poll for progress
while True:
status = await mcp_client.call_tool("kiro_task_status", {
"task_id": task["task_id"]
})
if status["status"] == "completed":
break
await asyncio.sleep(1)
Architecture
MCP Protocol Integration
- Server: Built on official MCP SDK (
mcp.server.Server) - Transport: JSON-RPC 2.0 over stdio
- Tools: 16 registered tools with schema validation
- Resources: Minimal resource handling for extensibility
Process Management
IDE Agent → MCP Server → Process Pool → kiro-cli instances
↓
Session Manager → Isolated contexts per project
Key Components
- SessionManager: Multi-session isolation and lifecycle management
- ProcessPool: Warm process reuse for 10x performance improvement
- CommandExecutor: Robust command execution with timeout handling
- StreamingTaskManager: Async task execution with progress polling
Performance Optimizations
- Process Pooling: Reuse warm kiro-cli processes
- Session Affinity: Route requests to appropriate process
- Intelligent Cleanup: Remove idle/unhealthy processes
- Mock Mode: Fast responses during development
Development
Setup
git clone https://github.com/your-org/kiro-cli-mcp.git
cd kiro-cli-mcp
pip install -e ".[dev]"
Testing
# Run all tests
pytest
# With coverage
pytest --cov=kiro_cli_mcp --cov-report=html
# Property-based tests
pytest tests/test_config.py -v
Code Quality
# Format code
ruff format .
# Lint
ruff check .
# Type checking
mypy src/
Running Server
# Development mode with debug logging
python -m kiro_cli_mcp --log-level DEBUG
# With custom config
python -m kiro_cli_mcp --config config.json
Contributing
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
Troubleshooting
kiro-cli Not Found
Server automatically enables mock mode if kiro-cli is unavailable:
# Check kiro-cli availability
which kiro-cli
# Set custom path
export KIRO_MCP_CLI_PATH=/custom/path/to/kiro-cli
# Verify server mode
python -m kiro_cli_mcp --log-level DEBUG
# Look for: "✅ kiro-cli is available" or "❌ kiro-cli not available: enabling mock mode"
Performance Issues
# Verify process pooling is enabled
python -m kiro_cli_mcp --log-level DEBUG
# Look for: "🔄 Using pooled process execution"
# Check pool statistics
# Use kiro_pool_stats tool to monitor performance
Session Management
# Increase session limits
export KIRO_MCP_MAX_SESSIONS=20
export KIRO_MCP_SESSION_TIMEOUT=7200 # 2 hours
# Clear stuck sessions
# Sessions auto-cleanup after timeout
Process Cleanup
If you encounter orphaned processes:
# Unix/Linux/macOS
pkill -f kiro-cli
# Windows
taskkill /F /IM kiro-cli.exe
# Check process groups (Unix)
ps -eo pid,pgid,cmd | grep kiro
License
MIT License - see LICENSE file for details.
Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: Wiki
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。