uni-kb

uni-kb

Enables parsing, indexing, and querying source code as structured knowledge, providing code exploration, spec generation, and migration tools via 20 MCP tools.

Category
访问服务器

README

uni-kb — Knowledge Base Library

Reusable data layer for codebase understanding. Parses source code into structured knowledge, indexes it for search, and serves it via MCP.

Can be used standalone by human developers or consumed by uni-dev agent system.

Architecture

Source Code
  │
  ▼
┌──────────────────────────────────────────┐
│  tree-sitter Parsers (plugin system)     │
│  Java/Spring · Node.js/Express/NestJS     │
└───────────────┬──────────────────────────┘
                ▼  structured JSON
┌──────────────────────────────────────────┐
│  Storage Layer                            │
│  ┌──────────┬──────────┬───────────────┐ │
│  │ SQLite   │ ChromaDB │ NetworkX      │ │
│  │ 8 tables │ 14 idx   │ Code Graph    │ │
│  └──────────┴──────────┴───────────────┘ │
└───────────────┬──────────────────────────┘
                ▼
┌──────────────────────────────────────────┐
│  Spec Generators (6)                      │
│  API Contract · Business Logic · Models   │
│  Auth Matrix · Config · Migration         │
└───────────────┬──────────────────────────┘
                ▼
┌──────────────────────────────────────────┐
│  MCP Server (20 tools, 5 categories)      │
└──────────────────────────────────────────┘

Phase 1: Parser Extension System

Goal: Abstract plugin interface + registry + Java parser

1.1 Base Plugin Interface (parsers/base.py)

class ParserPlugin(ABC):
    @abstractmethod
    def language(self) -> str: ...
    @abstractmethod
    def detect(self, file_path: str) -> bool: ...
    @abstractmethod
    def parse(self, file_path: str, source: str) -> ParseResult: ...

1.2 Plugin Registry (parsers/registry.py)

Discovers plugins via Python entry points (pyproject.toml [project.entry-points."uni_kb.parsers"]). Loads on demand.

1.3 Java Parser (parsers/java/)

Four sub-parsers using tree-sitter-java:

Parser Target Extracts
controller.py @RestController, @RequestMapping Endpoints, HTTP methods, paths, params, response types
service.py @Service, method bodies Business logic structure, dependencies
entity.py @Entity, @Column, @Table Entities, fields, types, constraints, relationships
mapper.py MyBatis XML Custom SQL queries, result maps

Output: ParseResult with standardized JSON matching SQLite schema.

Phase 2: Storage Layer

2.1 SQLite Store (store/sqlite_store.py)

8 tables initialized on uni-kb init --project ./:

Table Purpose
modules Top-level source modules
classes Classes / components
methods Methods / functions
api_endpoints REST endpoints
db_tables Database tables
db_columns Table columns
frontend_components Vue/Cocos components
auth_permissions Permission annotations

2.2 ChromaDB Indexes (store/chroma_indexes.py)

14 named collections with embedded mode (persisted in .uni-kb/chroma/):

# Index Content
1 code_java_controller Java controller source
2 code_java_service Java service source
3 code_java_entity Java entity source
4 code_java_mapper Mapper XML source
5 code_typescript_admin Vue admin source
6 code_typescript_game Cocos game source
7 specs_api Generated OpenAPI specs
8 specs_business_logic Generated method docs
9 specs_data_model Generated entity specs
10 specs_auth Permission matrix
11 specs_config Config catalog
12 db_schema Table DDL
13 project_docs Documentation
14 migration_checklists Per-module checklists

2.3 Code Graph (store/code_graph.py)

NetworkX directed graph.

Nodes (8 types): Module, Class, Method, APIEndpoint, DBTable, DBColumn, VueComponent, CocosComponent

Edges (11 + 3 migration): HAS_METHOD, CALLS, INJECTS, IMPLEMENTS, EXTENDS, ROUTES_TO, MAPS_TO, FK_TO, API_CALLER, PERMITS, IMPORTS + MIGRATES_TO, BLOCKED_BY, VERIFIED_AGAINST

Phase 3: Node.js Parser

1.4 Node.js Parser (parsers/nodejs/)

Four sub-parsers using tree-sitter-typescript:

Parser Target Extracts
route.py Express router.get() / NestJS @Get() Endpoints, HTTP methods, paths, middleware chains
service.py Service classes Business logic structure
model.py Sequelize / TypeORM models Entities, fields, types, relationships
middleware.py Auth middleware Permission chains, guards

Phase 4: Spec Generators + MCP

4.1 Generators (generators/)

6 generators, 4 exposed as direct MCP tools:

Generator Input Output MCP Tool
api_contract.py Controller/Route AST OpenAPI 3.0 YAML get_api_contract
business_logic.py Service AST Markdown pseudo-code get_business_logic_doc
data_model.py Entity + DB schema YAML model spec get_entity_spec
auth_matrix.py Permission annotations Permission matrix YAML get_permission_matrix
config_catalog.py YAML/.env files Config catalog YAML get_config_value
migration_checklist.py Module + dep graph Prioritized checklist MD get_migration_checklist

4.2 MCP Server (mcp_server.py)

20 tools in 5 categories:

Category Tools
Code Exploration search_code, get_method_body, get_class_structure, find_endpoints, find_usages
Spec Retrieval get_api_contract, get_business_logic_doc, verify_contract, compare_api_responses
Data Model get_entity_spec, get_db_schema, get_column_info, trace_fk_chain
Auth & Config get_permission_matrix, get_config_value, get_config_catalog
Operations get_migration_checklist, get_dependency_graph, get_migration_status, run_test_suite

Dependencies

chromadb
networkx
tree-sitter
tree-sitter-java
tree-sitter-typescript
sqlite-utils
pyyaml
mcp>=1.0.0

CLI Usage

# Initialize knowledge base for a project
uni-kb init --project /path/to/project

# Parse and index source code
uni-kb index --project /path/to/project

# Start MCP server
uni-kb serve --project /path/to/project --port 9020

推荐服务器

Baidu Map

Baidu Map

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

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

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

官方
精选
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

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

官方
精选
本地
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

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

官方
精选
本地
TypeScript
VeyraX

VeyraX

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

官方
精选
本地
Kagi MCP Server

Kagi MCP Server

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

官方
精选
Python
graphlit-mcp-server

graphlit-mcp-server

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

官方
精选
TypeScript
Exa MCP Server

Exa MCP Server

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

官方
精选
mcp-server-qdrant

mcp-server-qdrant

这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。

官方
精选
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选