KIA - Kaizen Intelligent Agent
Transforms Claude into a production-grade pair programmer by orchestrating best-in-class APIs (Morph, Chroma, DSPy) for iterative code evolution to 95%+ quality, semantic codebase search, package discovery across 3,000+ libraries, and pattern learning.
README
KIA - Kaizen Intelligent Agent π
Ultra-efficient 4-tool MCP server for production-grade pair programming
Smart orchestration of best-in-class APIs: Morph + Chroma + GEPA (DSPy)
Zero reinvention Β· Maximum leverage Β· 95%+ code quality in seconds
π― What is KIA?
KIA transforms Claude into a production-grade pair programmer by intelligently orchestrating the best code APIs available todayβinstead of reimplementing them.
The Problem: Most MCP servers reimplement basic primitives (search, merge, etc.) with poor performance.
KIA's Solution: Orchestrate world-class APIs with workflow-centric tools.
| Problem | KIA Solution | Powered By | Performance |
|---|---|---|---|
| 70% Code Quality | Iterative evolution to 95%+ | GEPA (DSPy) + Morph fast-apply | ~6-12s |
| Local Code Search | Natural language search | Morph semantic search | ~1000ms |
| Package Discovery | Search 3,000+ packages | Chroma Package Search | ~1200ms |
| No Learning | Pattern extraction & reuse | KIA pattern library | instant |
π οΈ Core Tools (4 Workflow-Centric)
1. evolve_code - Production-Ready Code Evolution
Solves the 70% problem through intelligent, iterative improvement.
How it works:
- GEPA (DSPy) generates multi-step reasoning trace + improvement plan
- Morph fast-apply (10,500 tok/sec) applies each edit instantly
- Quality validation across 5 dimensions (correctness, performance, security, readability, maintainability)
- Iterates until 95%+ quality reached
- Auto-learns successful patterns for future use
Example:
# Input: 70% quality
def authenticate(username, password):
user = db.query(f"SELECT * FROM users WHERE username='{username}'")
if user and user.password == password:
return True
return False
# After evolve_code: 97% quality
# - SQL injection fixed with parameterized queries
# - Secure password hashing (SHA-256)
# - Constant-time comparison (timing attack protection)
# - Type hints and validation
# - Comprehensive docstrings
# Total time: ~8 seconds
Powered by:
- GEPA: State-of-the-art DSPy program evolution (github.com/gepa-ai/gepa)
- Morph: 10,500 tok/sec fast-apply (morphllm.com)
2. search_local_codebase - Natural Language Code Search
Search your project with plain English using Morph's two-stage semantic search.
Example:
User: "Search my codebase for JWT authentication logic"
KIA: [Morph two-stage retrieval: vector + GPU reranking]
[Returns ranked results with relevance scores in ~1000ms]
Features:
- Natural language queries
- Two-stage retrieval (vector + rerank)
- Results in ~1000ms
- File paths + line numbers + relevance scores
Requirements:
- Code in a git repository
- Repository pushed to Morph (one-time setup)
3. search_packages - Discover Best Practices
Search 3,000+ public packages to learn from real implementations.
Example:
User: "Find rate limiting implementations from popular Python packages"
KIA: [Chroma searches: flask, fastapi, django, etc.]
[Returns code examples + documentation links]
Supported:
- Python (PyPI)
- JavaScript/TypeScript (npm)
- Go (Go modules)
- Ruby (RubyGems)
- Java (Maven)
- And more...
Powered by:
- Chroma: 3,000+ indexed packages (trychroma.com/package-search)
4. learn_pattern - Collective Intelligence
Extract successful patterns from code evolutions and reuse them.
Example:
# Pattern extracted from evolution:
# Name: "Type Safety + Validation"
# Confidence: 0.95
# Tags: ["type_hints", "validation", "security"]
# Before
def process(x):
return x * 2
# After
def process(x: int) -> int:
if not isinstance(x, int):
raise TypeError("Expected int")
return x * 2
# KIA learns this pattern and applies it to future evolutions automatically
π Prompts (9 Reusable Templates)
Prompts provide structured guidance for common workflows. Use these first to get the most out of KIA!
| Prompt | Parameters | Best For |
|---|---|---|
quick_start |
None | First-time users, status check |
kia_usage_guide |
None | Complete documentation reference |
evolve_code_workflow |
code, goal, focus_areas |
Step-by-step evolution guidance |
security_audit_prompt |
code, language |
Security-focused code review |
refactor_legacy_code |
code, original_language, modernize_to |
Modernizing old codebases |
performance_optimization |
code, bottleneck_description |
Speed and efficiency improvements |
add_type_safety |
code |
Adding type hints and validation |
debug_assistance |
code, error_message, expected_behavior, actual_behavior |
Troubleshooting bugs |
compare_implementations |
topic, packages |
Learning from multiple libraries |
Example: Using Prompts
User: "Use the security_audit_prompt for this code:
def login(user, pwd):
cur.execute(f"SELECT * FROM users WHERE name='{user}'")
return cur.fetchone()[1] == pwd
"
KIA: [Returns structured security audit workflow]
- Checklist of vulnerabilities to check
- Recommended tool usage sequence
- Common security fixes to apply
- Step-by-step remediation guide
π Resources (10 Data Endpoints)
Resources provide read-only access to server state, configuration, and documentation.
| Resource URI | Description |
|---|---|
kia://stats/overview |
Server statistics and performance metrics |
kia://patterns/library |
All learned patterns in the library |
kia://patterns/{pattern_id} |
Specific pattern details (template) |
kia://evolution/history |
Recent code evolution history |
kia://api/status |
API configuration and health status |
kia://tools/catalog |
Complete tool documentation with examples |
kia://prompts/catalog |
All available prompts with descriptions |
kia://quality/{language} |
Language-specific quality guidelines (template) |
kia://tips/evolution |
Evolution best practices |
kia://tips/search |
Search optimization tips |
Example: Reading Resources
User: "What's my KIA server status?"
[Read resource: kia://api/status]
{
"apis": {
"morph": {"configured": true, "performance": "10,500 tok/sec"},
"chroma": {"configured": true, "packages_indexed": "3,000+"},
"gepa_openrouter": {"configured": true, "model": "llama-3.1-70b"}
},
"overall_readiness": {"full_capability": true}
}
User: "Show me Python quality guidelines"
[Read resource: kia://quality/python]
{
"type_hints": "Use typing module: List, Dict, Optional, Union",
"docstrings": "Google or NumPy style with Args, Returns, Raises",
"security": "parameterized queries, secrets module, input validation",
"tools": ["mypy", "ruff", "black", "pytest"]
}
π Quick Setup
Prerequisites
- Python 3.9+
- Git
1. Clone Repository
git clone https://github.com/Ash-Blanc/kia-mcp-server.git
cd kia-mcp-server
2. Install Dependencies
pip install -r requirements.txt
Or with uv (recommended):
pip install uv
uv pip install -r requirements.txt
3. Get API Keys
Morph API (code merging + semantic search):
- Sign up: morphllm.com/dashboard
- Export key:
export MORPH_API_KEY="sk-..."
Chroma Package Search (package discovery):
- Sign up: trychroma.com/package-search
- Export key:
export CHROMA_API_KEY="ck-..."
OpenRouter (GEPA/DSPy LLM backend):
- Sign up: openrouter.ai
- Export key:
export OPENROUTER_API_KEY="sk-or-..."
4. Test Locally
python server.py
# β "π KIA MCP Server starting..."
# β " Morph API: β
Available"
# β " Chroma API: β
Available"
# β " GEPA (OpenRouter): β
Available"
π§ IDE Integration
Claude Desktop (macOS/Windows)
Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"mcpServers": {
"kia": {
"command": "python",
"args": ["/absolute/path/to/kia-mcp-server/server.py"],
"env": {
"MORPH_API_KEY": "sk-...",
"CHROMA_API_KEY": "ck-...",
"OPENROUTER_API_KEY": "sk-or-..."
}
}
}
}
Restart Claude Desktop β KIA appears in your tool list β
Cursor / VS Code / Zed
Use FastMCP CLI for easy installation:
pip install fastmcp
fastmcp install cursor # or vscode, zed
Or manually add to MCP settings with the same config format above.
π Usage Examples
Recommended Workflow
- Start with
quick_startprompt - Check server status and see examples - Use task-specific prompts - Get structured guidance for your task
- Call tools with guidance - Execute with context from prompts
- Check resources - Monitor stats, review patterns
Example 1: Evolve Legacy Code
User: "Use evolve_code on this function:
def login(user, pwd):
cur.execute(f"SELECT * FROM users WHERE name='{user}'")
row = cur.fetchone()
return row and row[1] == pwd
Make it secure, typed, tested, production-ready."
KIA:
[GEPA generates multi-step plan]
β Step 1: Fix SQL injection
β Step 2: Add password hashing
β Step 3: Add type hints
β Step 4: Add validation
β Step 5: Add tests
[Morph applies each step at 10,500 tok/sec]
[Quality: 70% β 97%]
[Time: ~8 seconds]
Result: Production-ready code with:
β
Parameterized SQL queries
β
Secure password hashing
β
Constant-time comparison
β
Full type annotations
β
Input validation
β
Comprehensive docstrings
β
Unit tests
Example 2: Search Local Codebase
User: "Search my codebase for error handling patterns"
KIA:
[Morph semantic search: ~1000ms]
Results:
1. src/api/error_handler.py:45-67 (relevance: 0.94)
- Custom exception hierarchy
2. src/utils/validators.py:23-38 (relevance: 0.87)
- Input validation with custom errors
3. src/middleware/error_middleware.py:12-45 (relevance: 0.82)
- Global error handler with logging
Example 3: Search Packages
User: "Find JWT authentication implementations from popular Python packages"
KIA:
[Chroma searches PyPI packages]
Found in:
1. flask-jwt-extended (v4.5.2)
- JWT token generation/validation
- Refresh token support
- File: jwt_manager.py:89-145
2. django-rest-framework-simplejwt (v5.2.2)
- JWT authentication backend
- Token blacklisting
- File: authentication.py:23-78
3. fastapi-jwt-auth (v0.9.0)
- Dependency injection pattern
- Async JWT validation
- File: auth_jwt.py:112-167
Example 4: Learn Pattern
User: "This evolution was successful - learn from it:
Before:
def fetch_data(url):
return requests.get(url).json()
After:
def fetch_data(url: str, timeout: int = 30) -> dict:
try:
response = requests.get(url, timeout=timeout)
response.raise_for_status()
return response.json()
except requests.RequestException as e:
logger.error(f"Failed to fetch {url}: {e}")
raise
Improvement: Added error handling, timeouts, logging"
KIA:
[Extracts pattern: "Robust HTTP Requests"]
[Stores in pattern library]
[Tags: error_handling, timeouts, logging, http]
[Confidence: 0.92]
β
Pattern learned! Will apply to similar code in future evolutions.
Example 5: Use Prompts for Structured Workflows
User: "I need to optimize this slow function"
[Get prompt: performance_optimization with code and bottleneck_description]
KIA Returns:
# Performance Optimization Workflow
## Code to Optimize:
[your code]
## Performance Analysis Checklist:
- Algorithm Complexity: O(nΒ²) β O(n log n)?
- Caching opportunities
- Async I/O potential
- Batch operations
## Recommended Tool Usage:
1. search_packages(query="caching memoization", packages=["cachetools"])
2. evolve_code(code=..., quality_threshold=0.95)
3. search_local_codebase(query="similar performance patterns")
## Quick Wins:
- Replace list.append() with comprehensions
- Use set() for membership testing
- Add @lru_cache to pure functions
ποΈ Architecture Philosophy
Why External APIs?
Anti-pattern: Reimplementing semantic search, code merging, etc.
KIA's approach: Orchestrate best-in-class APIs.
βββββββββββββββββββββββββββββββββββββββββββββββ
β KIA MCP SERVER (Orchestrator) β
β β
β 4 workflow-centric tools: β
β β’ evolve_code β
β β’ search_local_codebase β
β β’ search_packages β
β β’ learn_pattern β
β β
βββββββββββββββββββββββββββββββββββββββββββββββ
β β β
ββββββββββββ ββββββββββββ ββββββββββββ
β GEPA β β Morph β β Chroma β
β (DSPy) β β 10,500 β β 3,000+ β
βEvolution β β tok/sec β βPackages β
ββββββββββββ ββββββββββββ ββββββββββββ
Benefits:
- Performance: Morph's 10,500 tok/sec vs. our ~100 tok/sec
- Quality: GEPA's multi-step reasoning vs. simple prompts
- Scale: Chroma's 3,000+ packages vs. our handful
- Maintenance: They handle updates, improvements, scaling
- Cost: Shared infrastructure vs. running our own
What KIA Adds:
- β Smart orchestration (evolution workflow)
- β Pattern learning (collective intelligence)
- β Developer experience (workflow-centric tools)
- β MCP protocol integration
π Stats & Monitoring
Check KIA's performance via resources:
Read kia://stats/overview:
{
"total_evolutions": 42,
"successful_evolutions": 39,
"success_rate": 0.93,
"patterns_learned": 15,
"gepa_evolutions": 38,
"morph_merges": 127,
"chroma_searches": 8,
"morph_searches": 12
}
Read kia://evolution/history:
{
"evolution_history": {
"total_evolutions": 42,
"recent_evolutions": [...],
"summary": {
"average_iterations": 7.3,
"average_improvement": 0.24,
"gepa_usage_rate": 0.91
}
}
}
π§ͺ Testing
Run the test suite:
python test_usability.py
Tests validate:
- β All 4 core tools functional
- β API integrations working
- β Quality metrics calculation
- β Pattern learning system
π§ Troubleshooting
"Morph API not configured"
# Check if key is set
echo $MORPH_API_KEY
# If empty, set it
export MORPH_API_KEY="your-key-here"
# Restart KIA
python server.py
"Chroma Package Search requires API key"
export CHROMA_API_KEY="your-key-here"
python server.py
"GEPA not available"
export OPENROUTER_API_KEY="your-key-here"
python server.py
Evolution not improving quality
Possible causes:
- Code is already high quality
- No clear improvement path
- API rate limits
Solutions:
- Check API quotas
- Review quality metrics
- Try with different code
πΊοΈ Roadmap
Current (v0.3.0) β
- β GEPA (DSPy) integration for code evolution
- β Morph fast-apply + semantic search
- β Chroma Package Search integration
- β Pattern learning system
- β FastMCP 2.13+ framework
Next (v0.4.0)
- [ ] Persistent pattern storage (disk-based)
- [ ] Pattern embeddings + semantic matching
- [ ] Multi-file evolution support
- [ ] Real-time quality visualization
- [ ] Self-evolution workflow (server evolves itself)
Future (v1.0.0)
- [ ] Team collaboration features
- [ ] Custom pattern libraries
- [ ] Analytics dashboard
- [ ] CI/CD integration
- [ ] VS Code extension
π€ Contributing
We welcome contributions! Priority areas:
- GEPA/DSPy improvements - Better reasoning chains
- Pattern matching - Semantic pattern search
- Documentation - More examples and guides
- Test coverage - Expand test suite
- API integrations - New code/search APIs
Development Setup
git clone https://github.com/Ash-Blanc/kia-mcp-server.git
cd kia-mcp-server
pip install -r requirements.txt
python test_usability.py
π References
Powered by:
- GEPA (DSPy Evolution) - State-of-the-art program evolution
- Morph - Fast code merging & semantic search
- Chroma - Package search API
- FastMCP - MCP framework
- OpenRouter - LLM API gateway
Inspired by:
- Addy Osmani's "70% Problem"
- Zed's Agentic Engineering
- Developer pain points from HN/Reddit research
π License
MIT License - See LICENSE file
π’ Credits
KIA by Kaizen Labs
"Continuous improvement is better than delayed perfection." π
π Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: support@kaizenlabs.dev (coming soon)
Built with β€οΈ by developers, for developers
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.