spec-assistant
Enables natural language queries on technical specifications and automated code compliance checks using local RAG with vector search, integrated via MCP.
README
🤖 Spec Assistant — MCP-Powered RAG
A local, fully functional developer assistant that brings spec-driven development directly into your IDE. Ask natural language questions about your technical specifications and perform automated code compliance checks directly from VS Code, Claude Desktop or any MCP-compatible client.
Architecture
Developer Question / Code Snippet
│
▼
MCP Server (stdio transport)
┌─────────────────────────────┐
│ get_spec(query) │ ◄── Custom tools exposed to client
│ list_specs() │
│ validate_code(code, spec) │
└────────────┬────────────────┘
│
┌───────▼────────┐
│ RAG Pipeline │
│ │
│ 1. Embed query│──► sentence-transformers (local, all-MiniLM-L6-v2)
│ 2. Retrieve │──► ChromaDB (local vector DB, cosine metric)
│ 3. Build prompt│
│ 4. Call LLM │──► Ollama llama3.2 (local) or OpenAI
└────────────────┘
│
┌───────▼────────┐
│ specs/ folder │ ◄── Your Markdown (.md) or Text (.txt) files
└────────────────┘
Quick Start
1. Prerequisites
- Python 3.11+ installed on your system.
- Ollama installed and running locally.
- Pull the default local model using:
ollama pull llama3.2
2. Install Dependencies
Clone this repository, navigate to the directory, and install dependencies:
pip install -r requirements.txt
[!NOTE] The initial setup might take a moment to resolve as it downloads the local embedding model (
all-MiniLM-L6-v2~90MB) on first run.
3. Environment Configuration
Copy the example environment configuration to create your local .env file:
# Windows
copy .env.example .env
# macOS/Linux
cp .env.example .env
The defaults are already pre-configured to work with a local Ollama server out of the box.
4. Import Specification Documents
Put your .md or .txt specification documents inside the specs/ directory. By default, the repository contains:
auth_spec.md— Authentication, authorization rules, and endpoints.user_management_spec.md— User CRUD API specifications.notification_spec.md— In-app, webhook, and email notification settings.
5. Index Specifications into Vector Store
Run the ingestion pipeline to parse documents, split them into chunks, compute vector embeddings, and save them to your local database:
python ingest.py
6. View Indexed Data
To inspect exactly what text chunks, documents, and metadata are indexed in your local vector database, run the helper database viewer script:
python view_db.py
Running the MCP Server
Run server in Dev Mode (with Inspector)
To test the MCP tools interactively, you can run the server using the MCP developer tool:
mcp dev mcp_server/server.py
This runs the server locally and launches a web-based MCP Inspector where you can invoke and test all tools in real-time.
Integrations
Connect to Claude Desktop
Add the server configuration to your Claude Desktop configuration file:
- Windows:
%APPDATA%\Claude\claude_desktop_config.json - macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
Add the following JSON configuration (replacing absolute paths with your own directory path):
{
"mcpServers": {
"spec-assistant": {
"command": "python",
"args": ["C:/absolute/path/to/spec-mcp-poc/mcp_server/server.py"],
"env": {}
}
}
}
Restart Claude Desktop, and you will see the new tools symbol in the composer window!
Connect to IDE Extension (e.g. Cline or Continue in VS Code)
Add this configuration block to your IDE extension configuration file:
{
"spec-assistant": {
"command": "python",
"args": ["mcp_server/server.py"],
"cwd": "C:/absolute/path/to/spec-mcp-poc"
}
}
Available MCP Tools
| Tool Name | Parameters | Description |
|---|---|---|
get_spec |
query (str) |
Ask natural language questions about specifications. Utilizes semantic vector search to augment your LLM's response. |
list_specs |
None | Returns a detailed list of all specifications currently parsed and indexed inside the database. |
validate_code |
code (str), spec_name (str) |
Validates code snippets against specifications and returns list of compliant features, violations, and recommendation checklist. |
Project Structure
spec-mcp-poc/
├── specs/ # 📄 Raw specification files (add yours here)
│ ├── auth_spec.md
│ ├── user_management_spec.md
│ └── notification_spec.md
├── ingestion/
│ ├── chunker.py # Loads specs and splits them into sliding-window text chunks
│ ├── embedder.py # Embeds chunks using sentence-transformers (local model)
│ └── indexer.py # Interfaces with ChromaDB (creation, deletes, insertions)
├── rag/
│ ├── retriever.py # Performs semantic search querying database via cosine distance
│ ├── prompt_builder.py # Generates LLM chat prompts for retrieval and compliance checks
│ └── llm_client.py # Routes requests to Ollama (local) or OpenAI (cloud)
├── mcp_server/
│ └── server.py # MCP Server exposing standard tools over stdio
├── config.py # Central configurations and environment reader
├── ingest.py # Entry point command line pipeline to run ingestion
├── view_db.py # Helper utility script to view local vector database entries
├── requirements.txt # Python dependencies
├── .gitignore # Git ignored patterns
├── .env # Local environment configurations (ignored)
└── .env.example # Template configuration
Switching to Cloud-based OpenAI (Optional)
If you prefer using OpenAI cloud endpoints instead of local Ollama, update your .env file configuration:
LLM_BACKEND=openai
OPENAI_API_KEY=sk-proj-your-actual-api-key
OPENAI_MODEL=gpt-4o-mini
No code modifications are required; the system automatically switches backends on the fly.
Troubleshooting
| Problem | Potential Cause | Troubleshooting Action |
|---|---|---|
No indexed specs found |
Database has not been initialized. | Run python ingest.py to index specs. |
Connection refused (Ollama) |
Ollama service is not running. | Make sure the Ollama application is running, or run ollama serve. |
Model not found |
The model is missing in Ollama. | Run ollama pull llama3.2 to download the model. |
| Slow execution during first run | Cold start downloads. | The local embedding model (all-MiniLM-L6-v2) is downloaded once and cached for future runs. |
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。