Kimi Project Intelligence MCP

Kimi Project Intelligence MCP

A Model Context Protocol server for Kimi-CLI that provides semantic project indexing, intelligent code retrieval, and dynamic skill routing to enhance code assistance. It supports incremental indexing, file watching, dependency graphs, git integration, code summarization, REST API, and web UI for managing project indexes.

Category
访问服务器

README

Kimi Project Intelligence MCP (Kimi-PIMCP) v0.2.0 🚀

A Model Context Protocol (MCP) server for Kimi-CLI that provides semantic indexing, intelligent context retrieval, and dynamic skill selection for enhanced code assistance.

✨ Features

Core Features

  • Semantic Indexing - Index projects using ML embeddings (sentence-transformers)
  • Intelligent Retrieval - Find relevant code with cosine similarity + MMR for diversity
  • Skill Routing - Automatically detect user intent and select optimal skills
  • Caveman Compression - Heuristic-based text compression for token optimization
  • MCP Protocol - Full compatibility with Kimi-CLI via stdio JSON-RPC

New in v0.2.0

  • Incremental Indexing - Only reindex changed files (10x faster reindexing)
  • Query Caching - LRU cache for frequently used queries
  • File Watcher - Auto-reindex when files change
  • Dependency Graph - Analyze import relationships between files
  • Git Integration - Index only modified files vs HEAD
  • Code Summarization - Auto-summarize code chunks
  • Similar Code Detection - Find duplicate/similar code blocks
  • REST API - HTTP API for external integrations
  • Web UI - Beautiful web interface for managing indexes

📁 Architecture

kimi-pimcp/
├── src/
│   ├── indexer.py           # Semantic indexing with embeddings (OPTIMIZED)
│   ├── retriever.py         # Context retrieval with MMR + caching
│   ├── compressor.py        # Caveman text compression with tiktoken
│   ├── server.py            # MCP stdio server (multi-project support)
│   ├── file_watcher.py      # File change monitoring
│   ├── dependency_graph.py  # Import/dependency analysis
│   ├── git_integration.py   # Git integration for incremental updates
│   ├── code_summarizer.py   # Code summarization and duplicate detection
│   ├── rest_api.py          # HTTP REST API
│   ├── web_ui.py            # Web interface
│   └── skills/
│       ├── base.py          # Base skill classes
│       ├── router.py        # Intent classification
│       └── prompts/         # System prompts
├── data/datasets/           # Training datasets
├── tests/                   # Unit tests
├── notebooks/               # Validation notebooks
└── docs/                    # Documentation

🚀 Installation

Linux/Mac

chmod +x install.sh
./install.sh

Windows

.\install.ps1

Manual Installation

# Clone the repository
git clone <repository-url>
cd kimi-pimcp

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Pre-download models
python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')"

💻 Usage

Running the MCP Server

# Start the MCP server
python src/server.py

# Or use the installed command
kimi-pimcp

The server communicates via stdin/stdout using JSON-RPC 2.0 protocol.

Running the REST API

# Start the REST API server
python src/rest_api.py --host 0.0.0.0 --port 8000

# With auto-reload (development)
python src/rest_api.py --reload

The API will be available at http://localhost:8000

Running the Web UI

# Start the web UI server
python src/web_ui.py

Then open http://localhost:8080 in your browser.

🛠️ Available Tools

Core Tools

1. Initialize Index

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "initialize_index",
    "arguments": {
      "project_path": "/path/to/project",
      "force_reindex": false
    }
  }
}

2. Query Context

{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "tools/call",
  "params": {
    "name": "query_context",
    "arguments": {
      "query": "authenticate user",
      "top_k": 5,
      "filter_ext": [".py", ".js"],
      "use_mmr": true
    }
  }
}

3. Select Skill

{
  "jsonrpc": "2.0",
  "id": 3,
  "method": "tools/call",
  "params": {
    "name": "select_skill",
    "arguments": {
      "query": "fix login bug"
    }
  }
}

4. Compress Output

{
  "jsonrpc": "2.0",
  "id": 4,
  "method": "tools/call",
  "params": {
    "name": "compress_output",
    "arguments": {
      "text": "Please help me fix this bug...",
      "level": "full"
    }
  }
}

New Tools in v0.2.0

5. Get Query History

{
  "jsonrpc": "2.0",
  "id": 5,
  "method": "tools/call",
  "params": {
    "name": "get_query_history",
    "arguments": {
      "limit": 10
    }
  }
}

6. Switch Project

{
  "jsonrpc": "2.0",
  "id": 6,
  "method": "tools/call",
  "params": {
    "name": "switch_project",
    "arguments": {
      "project_path": "/path/to/other/project"
    }
  }
}

7. Get Dependencies

{
  "jsonrpc": "2.0",
  "id": 7,
  "method": "tools/call",
  "params": {
    "name": "get_dependencies",
    "arguments": {
      "filepath": "/path/to/file.py"
    }
  }
}

8. Find Similar Code

{
  "jsonrpc": "2.0",
  "id": 8,
  "method": "tools/call",
  "params": {
    "name": "find_similar_code",
    "arguments": {
      "filepath": "/path/to/file.py"
    }
  }
}

9. Summarize Chunk

{
  "jsonrpc": "2.0",
  "id": 9,
  "method": "tools/call",
  "params": {
    "name": "summarize_chunk",
    "arguments": {
      "content": "def hello(): print('world')",
      "chunk_type": "function",
      "language": "python"
    }
  }
}

10. Export/Import Index

{
  "jsonrpc": "2.0",
  "id": 10,
  "method": "tools/call",
  "params": {
    "name": "export_index",
    "arguments": {
      "output_path": "/path/to/export"
    }
  }
}

🎯 Skills

Skill Description Use Cases
debugger Debug code issues Errors, exceptions, crashes
architect System design Architecture, patterns, scalability
explainer Explain code/concepts Documentation, understanding
tester Testing & QA Unit tests, integration tests
caveman Concise responses Token-optimized output

⚙️ Configuration

Edit config.yaml to customize:

models:
  embedding_model: "sentence-transformers/all-MiniLM-L6-v2"
  use_cross_encoder: true

indexer:
  supported_extensions: [".py", ".js", ".ts"]
  exclude_dirs: ["node_modules", ".git"]
  max_file_size_mb: 10

compressor:
  default_level: "auto"

performance:
  query_cache_size: 100
  model_cache_size: 2

📊 Performance Targets

Operation Target v0.1.0 v0.2.0
Indexing <100ms/file ~50ms ~30ms (incremental)
Query <200ms ~100ms ~50ms (cached)
Classification <10ms ~5ms ~3ms
Compression <5ms ~2ms ~1ms
Memory <500MB ~300MB ~250MB

🧪 Testing

# Run unit tests
python -m pytest tests/ -v

# Run with coverage
python -m pytest tests/ --cov=src --cov-report=html

# Run validation notebook
jupyter notebook notebooks/validation.ipynb

📚 REST API Endpoints

Endpoint Method Description
/health GET Health check
/index POST Index a project
/index/status GET Get indexing status
/query POST Search code
/compress POST Compress text
/skills/select POST Detect skill
/skills GET List skills
/stats GET Get all stats
/dependencies GET Get file dependencies
/dependencies/stats GET Dependency graph stats
/git/status GET Git status
/git/changes GET Git changes
/cache/clear POST Clear all caches

📖 API Reference

Indexer Module

from indexer import ProjectIndexer, get_indexer

indexer = get_indexer(project_path="/path/to/project")
stats = indexer.index_project("/path/to/project")
print(f"Indexed {stats['files_indexed']} files")
print(f"Skipped {stats['files_skipped']} unchanged files")

Retriever Module

from retriever import ContextRetriever, get_retriever

retriever = get_retriever()
retriever.load_index("/path/to/project")
results = retriever.query("authenticate user", top_k=5)

# Check cache stats
print(retriever.get_stats()['cache'])

File Watcher

from file_watcher import ProjectFileWatcher

def on_change(event):
    print(f"File {event.change_type.value}: {event.filepath}")

watcher = ProjectFileWatcher("/path/to/project", on_change)
watcher.start()

Dependency Graph

from dependency_graph import DependencyGraph

graph = DependencyGraph("/path/to/project")
graph.build()

# Get dependencies
deps = graph.get_dependencies("/path/to/file.py")
dependents = graph.get_dependents("/path/to/file.py")

# Find circular dependencies
cycles = graph.find_circular_dependencies()

Git Integration

from git_integration import GitIntegration

git = GitIntegration("/path/to/project")

# Get changed files since last commit
changes = git.get_changed_files_since("HEAD~1")
files_to_index, files_to_remove = git.get_files_to_index("HEAD~1")

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Add tests
  5. Submit a pull request

📄 License

MIT License - see LICENSE file for details.

🙏 Acknowledgments

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选