swe-knowledge-base
v1.1.3
Published
MCP server for software engineering knowledge base and retrieval
Maintainers
Readme
SWE Knowledge Base MCP Server
A production-quality Model Context Protocol (MCP) server that acts as a software engineering knowledge base and retrieval system. It indexes high-quality software projects and allows AI assistants to search for best practices, architecture patterns, code examples, documentation, and project knowledge.
Features
- Multi-language support: C, C++, C#, Rust, Python, JavaScript, TypeScript, Go, Java, Markdown
- Semantic + keyword search: Fuzzy matching powered by Fuse.js with BM25-inspired ranking
- Incremental indexing: Fast re-indexing by tracking file modifications
- Architecture detection: Automatically detects design patterns (MVC, Repository, Factory, Singleton, Observer, Strategy, etc.)
- Best practices extraction: Detects naming conventions, error handling, thread safety, testing strategies, and more
- Symbol indexing: Indexes functions, classes, interfaces, structs, enums, and other symbols
- Documentation search: Searches READMEs, docstrings, JSDoc, and markdown documentation
- Caching: File-based and in-memory caching for fast repeated queries
- Configurable: Customizable via JSON config file
- LLM-optimized output: Results are formatted for easy consumption by AI assistants
MCP Tools
| Tool | Description |
|------|-------------|
| search_code | Search across source code with fuzzy and keyword matching |
| search_docs | Search documentation, READMEs, and markdown files |
| search_examples | Find code examples prioritizing documented code |
| search_architecture | Find architecture and design patterns |
| search_best_practices | Find coding best practices and conventions |
| search_symbols | Find functions, classes, methods by name |
| list_projects | List all indexed projects |
| reindex_project | Re-index a specific project |
| reindex_all | Re-index all projects |
Installation
Prerequisites
- Node.js >= 18
- npm
Steps
Ensure the server is at
C:\Users\Agami\Documents\Cline\MCP\swe-knowledge-baseInstall dependencies (if not already done):
cd C:\Users\Agami\Documents\Cline\MCP\swe-knowledge-base
npm install
npm run build- Add to your MCP settings (see Configuration section below).
Configuration
MCP Client Configuration
Add this to your MCP settings file (cline_mcp_settings.json):
{
"mcpServers": {
"swe-knowledge-base": {
"command": "node",
"args": ["C:\\Users\\Agami\\Documents\\Cline\\MCP\\swe-knowledge-base\\build\\index.js"],
"env": {}
}
}
}Server Configuration
The server reads configuration from config/config.json. If not present, a default config is created:
{
"projectDir": "./projects",
"indexDir": "./index",
"cacheDir": "./cache",
"logDir": "./logs",
"embeddingModel": "bm25",
"indexRefreshIntervalMs": 300000,
"maxFileSize": 1048576,
"maxFilesPerProject": 10000,
"ignorePatterns": [
"node_modules/**",
".git/**",
"dist/**",
"build/**",
"target/**",
"__pycache__/**"
],
"searchMaxResults": 20,
"searchFuzzyThreshold": 0.3,
"cacheEnabled": true,
"cacheTtlMs": 1800000,
"parallelProcessing": true,
"logLevel": "info"
}Environment Variables
| Variable | Description |
|----------|-------------|
| SWE_KB_BASE_DIR | Override the base directory for all paths |
Directory Structure
swe-knowledge-base/
├── projects/ # Place your software projects here
├── index/ # Persisted index data
├── cache/ # Search result cache
├── config/ # Configuration files
├── logs/ # Server logs
├── src/ # TypeScript source code
│ ├── index.ts # Main MCP server
│ ├── config/ # Configuration management
│ ├── logger/ # Logging system
│ ├── cache/ # Caching system
│ ├── scanner/ # Project file scanner
│ ├── parser/ # Code parser (multi-language)
│ ├── indexer/ # Indexing pipeline + architecture + best practices
│ ├── search/ # Search engine (Fuse.js)
│ └── types/ # TypeScript type definitions
├── build/ # Compiled JavaScript output
├── package.json
└── tsconfig.jsonUsage
Adding Projects
- Copy or symlink your software projects into the
projects/directory:
swe-knowledge-base/
└── projects/
├── my-react-app/
├── my-rust-lib/
└── my-python-api/- Each project should be a standalone directory with source code.
Indexing
Indexing happens automatically when the server starts and no index exists. You can also trigger it manually:
- Reindex all projects: Ask the AI assistant to use
reindex_all - Reindex one project: Ask the AI assistant to use
reindex_projectwith the project name
The index auto-refreshes periodically (configurable via indexRefreshIntervalMs).
Example Workflows
Find how error handling is done across projects:
"Search for error handling best practices"
Find a specific function:
"Search for symbols named
createServer"
Find architecture patterns:
"Search for dependency injection patterns"
Find code examples:
"Find examples of how to implement a REST API handler"
Search documentation:
"Search docs for rate limiting configuration"
List what's indexed:
"List all indexed projects"
Architecture
Indexing Pipeline
- Scanner discovers projects and files in
projects/ - Parser extracts symbols, imports, comments, and documentation
- Indexer builds the search index (incremental, based on file modification times)
- Architecture Detector identifies design patterns and architectural styles
- Best Practices Extractor analyzes coding conventions and practices
Search Engine
- Fuse.js provides fuzzy search with configurable thresholds
- Inverted indexes for fast symbol lookups
- BM25-inspired ranking combines multiple scoring factors
- Result caching with configurable TTL
Supported Languages
| Language | Symbols | Imports | Comments | Documentation | |----------|---------|---------|----------|---------------| | Python | Classes, functions, methods | import/from...import | # comments | Docstrings | | JavaScript/TypeScript | Classes, functions, interfaces, types, enums | import/require | //, /** / | JSDoc | | Go | Functions, methods, structs, interfaces | import | // | Comments | | Rust | Functions, structs, enums, traits | use | //, /// | Doc comments | | Java | Classes, methods, interfaces | import | //, /* / | JSDoc | | C/C++ | Functions, structs, classes, enums | #include | //, / / | Comments | | C# | Classes, methods, interfaces, namespaces | using | //, /* */ | XML docs | | Markdown | Headers/sections | - | - | Full content |
Development
# Build
npm run build
# Watch mode
npm run watch
# Run MCP inspector
npm run inspectorLicense
MIT
