Manifold Engine MCP Server
Enables AI coding assistants to perform high-speed structural codebase analysis and dynamic context management by mapping repositories as byte-streams and detecting architectural chaos.
README
Manifold Engine MCP Server
A Model Context Protocol server that gives AI coding assistants high-speed, structural codebase analysis and dynamic context management. Instead of reading code token-by-token, it maps repositories structurally — treating source files as continuous byte-streams, computing structural signatures, and detecting architectural chaos in O(1) time.
Current Status: All Phase 0 critical bugs have been resolved, including FAISS semantic search deserialization,
ingest_reporelative path resolution, combined risk formula transparency, and distinct cluster naming heuristics. All 21 analysis tools are fully functional.
Core Capabilities
| Capability | Description |
|---|---|
| Structural Indexing | Scans every file into a Valkey-backed grid with compressed signatures and chaos profiles. Sub-millisecond retrieval. |
| Chaos Detection | Calculates a chaos_score per file. Predicts which files will become unmaintainable. |
| Dependency & Risk Analysis | Traces import graphs via AST parsing, measures blast radius, combines chaos × blast into a single risk score. |
| Working Memory | Inject persistent facts (project conventions, architecture rules) into a Dynamic Semantic Codebook for zero-shot learning. |
| Real-Time Sync | Filesystem watcher auto-ingests file saves in milliseconds, keeping the index current without manual re-scans. |
Installation
Prerequisites
- Python 3.10+
- Valkey (or Redis) running on
localhost:6379 - C++20 compiler (for building the native structural engine)
faiss-cpu(required for running thecluster_codebase_structuretool)
Setup
# 1. Start the Valkey backend
valkey-server
# 2. Install the manifold engine
pip install -e .
# 3. Configure your MCP client (Kilo Code, Claude Desktop, Cursor, etc.)
Add to your MCP client configuration:
{
"mcpServers": {
"manifold": {
"command": "path/to/virtualenv/bin/python",
"args": ["path/to/SEP-mcp/mcp_server.py"],
"cwd": "path/to/SEP-mcp"
}
}
}
Common Workflows & Use Cases
1. New Repository Analysis
When entering a new codebase, execute an initial mapping to immediately understand technical debt distribution.
# 1. Index the repository
ingest_repo (root_dir=".", clear_first=true, compute_chaos=true)
# 2. Verify ingestion was successful
get_index_stats
# 3. Quickly identify the most complex, chaotic files
batch_chaos_scan (pattern="*.py", max_files=30)
2. Refactoring Decisions & Sprint Planning
Use the structural risk metrics to objectively decide what code to rewrite.
# 1. Scan for files with BOTH high complexity and high import dependencies
scan_critical_files (pattern="*.py", max_files=10)
# 2. For candidates, predict how soon the file will become unmaintainable
predict_structural_ejection (path="target.py", horizon_days=30)
# 3. For visual confirmation, generate a 4-panel chaos dashboard
visualize_manifold_trajectory (path="target.py")
3. Finding Implementation Patterns
Rather than searching by text, search by structural signatures to find similar logic blocks or clones.
# 1. Get the mathematical signature of an existing file
get_file_signature (path="found_file.py")
# 2. Search for any other files that match this structure globally
search_by_structure (signature="c0.213_s0.000_e0.928", tolerance=0.05)
4. Continuous Flow
# Run the watcher inside the repo
start_watcher (watch_dir=".")
# The engine now automatically syncs and re-evaluates risk natively whenever files are saved.
Tool Reference (20 Tools)
All tools are documented with parameters, examples, and workflows in MCP_TOOL_GUIDE.md.
Indexing & Monitoring
| Tool | Purpose | Quick Command |
|---|---|---|
ingest_repo |
Full repository scan into Valkey with signatures and chaos profiles | ingest_repo root_dir="." clear_first=true compute_chaos=true |
get_index_stats |
Real-time index health: document count, memory, chaos averages | get_index_stats |
start_watcher |
Background filesystem observer — auto-ingests on file save/delete | start_watcher watch_dir="." |
File Discovery & Search
| Tool | Purpose | Quick Command |
|---|---|---|
list_indexed_files |
Browse indexed files by glob pattern | list_indexed_files pattern="*.py" max_results=200 |
get_file |
Read full file content from the Valkey index | get_file path="src/manifold/sidecar.py" |
search_code |
Keyword or regex search across all indexed files with context | search_code query="chaos_score" file_pattern="*.py" |
get_file_signature |
Structural fingerprint (c/s/e) for a file | get_file_signature path="mcp_server.py" |
search_by_structure |
Find files with similar structural signatures | search_by_structure signature="c0.213_s0.000_e0.928" tolerance=0.05 |
search_by_signature_sequence |
Find files containing a contiguous signature sequence | search_by_signature_sequence text="..." min_signatures=3 |
Chaos Analysis
| Tool | Purpose | Quick Command |
|---|---|---|
analyze_code_chaos |
Per-file chaos score, entropy, coherence, collapse risk | analyze_code_chaos path="mcp_server.py" |
batch_chaos_scan |
Rank all files by chaos score (highest risk first) | batch_chaos_scan pattern="*.py" max_files=50 |
predict_structural_ejection |
Forecast when a file becomes unmaintainable | predict_structural_ejection path="mcp_server.py" horizon_days=30 |
visualize_manifold_trajectory |
Generate a 4-panel dashboard of chaos dynamics | visualize_manifold_trajectory path="mcp_server.py" |
cluster_codebase_structure |
K-Means clustering of files by structural signatures | cluster_codebase_structure pattern="*.py" n_clusters=5 |
Dependency & Combined Risk
| Tool | Purpose | Quick Command |
|---|---|---|
analyze_blast_radius |
Import dependency tree and impact file count | analyze_blast_radius path="src/manifold/sidecar.py" |
compute_combined_risk |
Combined risk = 0.6×chaos + 0.4×blast | compute_combined_risk path="src/manifold/sidecar.py" |
scan_critical_files |
Repository-wide scan for highest combined risk | scan_critical_files pattern="*.py" max_files=20 |
Verification & Memory
| Tool | Purpose | Quick Command |
|---|---|---|
compute_signature |
Compress arbitrary text into manifold signatures | compute_signature text="def hello(): ..." |
verify_snippet |
Check if code structurally matches existing codebase patterns | verify_snippet snippet="..." coverage_threshold=0.5 scope="*.py" |
inject_fact |
Add persistent knowledge to the Dynamic Semantic Codebook | inject_fact fact_id="api_rules" fact_text="All endpoints use snake_case." |
remove_fact |
Remove a previously injected fact | remove_fact fact_id="api_rules" |
Empirical Validation
React 15.0 Case Study
The structural engine flagged the exact files (ReactReconcileTransaction.js, ReactInstanceHandles.js) that the React core team subsequently deleted and rewrote as React Fiber — without any semantic understanding of JavaScript.
→ Read the study
Langchain ROC Analysis
A blind forward-prediction study on langchain v0.0.300 proved that a chaos score threshold of 0.396 optimally predicts architectural ejection, achieving ~91% of the predictive power of expensive AST-parsing tools at O(1) speed.
→ Read the study
Memory Optimization
Zstandard compression reduced the cpython index from 3.4 GB to 28 MB (>99% reduction) with zero loss in retrieval accuracy.
Documentation
| Document | Purpose |
|---|---|
| MCP_TOOL_GUIDE.md | Comprehensive tool reference, workflows, best practices |
| reports/ | Validation studies and generated reports |
License
MIT — see LICENSE
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。