code-context

code-context

Enables AI coding assistants to automatically scan, store, and query API endpoints from codebases, providing instant lookup and semantic search to reduce context switching and token consumption.

Category
访问服务器

README

code-context

License: MIT Python 3.10+ PyPI version

MCP (Model Context Protocol) server for managing API endpoints and code context for AI coding assistants.

Problem

When using AI coding assistants like Claude Code, you often need to reference API endpoints while writing code. This requires:

  • Repeatedly searching through codebases
  • High token consumption from context switching
  • Risk of using outdated API information
  • Manual tracking of endpoint specifications

Solution

code-context automatically scans and stores your API endpoints in a vector database, enabling:

  • Instant lookup by endpoint name or route
  • Semantic search by describing what the endpoint does
  • Complete specifications (headers, parameters, responses)
  • Always up-to-date with your codebase

Features

  • 🔍 Automatic scanning of Python FastAPI/Flask projects
  • 💾 Vector storage with Qdrant (embedded mode)
  • 🔧 MCP integration with Claude Code/Desktop
  • 📝 CRUD operations for endpoint management
  • 🚀 Zero-config setup with pipx install
  • 🎯 Extensible architecture for more languages

Installation

Quick Start (Recommended)

# Step 1: Install code-context
pipx install code-context

# Step 2: Initialize configuration (run once)
code-context init

# Step 3: Install MCP client integration
code-context install-mcp

The install-mcp wizard will guide you through:

  • Selecting your AI coding assistant platform
  • Automatically configuring the MCP integration
  • Testing the connection

Manual Installation (Development)

# Clone repository
git clone https://github.com/jieyefriic/code-context
cd code-context

# Install in development mode
pip install -e .

# Initialize configuration
code-context init

# Install MCP client
code-context install-mcp

MCP Client Installation

code-context works with 12+ AI coding assistants through the Model Context Protocol (MCP):

Supported Platforms: Claude Code • Cursor • Antigravity • Windsurf • Warp • Cline • VS Code Copilot • Copilot CLI • Amp • Gemini CLI • Codex • Factory CLI

Quick Install

code-context install-mcp

This interactive wizard will automatically configure your AI assistant.

Manual Installation

For detailed platform-specific instructions, see INSTALLATION.md

Quick Links:

Usage

1. Initialize (Run Once)

code-context init

This wizard will:

  • Guide you through selecting LLM provider (OpenAI, Gemini, DeepSeek, etc.)
  • Configure API keys securely
  • Set up embedding configuration
  • Create data directory at ~/.code-context/
  • Initialize embedded Qdrant database

Important: This step must be completed before using the MCP server.

2. Scan Your Codebase

In Claude Code, ask:

Scan my project directory for API endpoints

Or manually:

# In Python REPL
from code_context import tools
tools.scan_codebase("/path/to/your/project", language="python")

3. Query Endpoints

In Claude Code, you can now ask:

What's the user login endpoint specification?
Show me all endpoints related to authentication
What parameters does the /api/users/:id endpoint accept?

MCP Tools

The following tools are available to Claude Code:

search_endpoint

Search for endpoints by name or route

{
  "name": "get_user",      // Optional: exact name match
  "route": "/api/users"    // Optional: exact route match
}

add_endpoint

Manually add an endpoint

{
  "name": "create_user",
  "route": "/api/users",
  "method": "POST",
  "file_path": "/path/to/api.py",
  "description": "Create a new user",
  "parameters": {...},
  "response_format": {...}
}

scan_codebase

Scan a directory for endpoints

{
  "directory": "/path/to/project",
  "language": "python"
}

update_endpoint

Update an existing endpoint

{
  "endpoint_id": "uuid-here",
  "updates": {
    "description": "Updated description"
  }
}

delete_endpoint

Delete an endpoint

{
  "endpoint_id": "uuid-here"
}

list_endpoints

List all stored endpoints

{
  "limit": 100
}

Supported Frameworks

Current

  • ✅ Python: FastAPI, Flask

Planned

  • 🔜 Node.js: Express, NestJS
  • 🔜 Go: Gin, Echo, Chi
  • 🔜 Rust: Axum, Actix

Architecture

code-context/
├── src/code_context/
│   ├── server.py           # MCP server core
│   ├── config.py           # Configuration management
│   ├── tools/              # MCP tool implementations
│   ├── scanner/            # Code scanners (extensible)
│   │   ├── python.py       # Python scanner
│   │   └── [future: go.py, rust.py, etc.]
│   └── database/           # Qdrant client wrapper
└── tests/

Configuration

Environment Variables

# Custom data directory
export CODE_CONTEXT_DATA_DIR=~/.my-code-context

# Use remote Qdrant
export CODE_CONTEXT_QDRANT_URL=http://localhost:6333
export CODE_CONTEXT_QDRANT_API_KEY=your-key

# Collection settings
export CODE_CONTEXT_COLLECTION_NAME=my_endpoints
export CODE_CONTEXT_VECTOR_SIZE=1536

View Current Config

code-context info

Development

Setup

# Clone and install with dev dependencies
git clone https://github.com/jieyefriic/code-context
cd code-context
pip install -e ".[dev]"

Run Tests

pytest tests/

Code Formatting

black src/
ruff check src/

Extending

Add a New Language Scanner

Create src/code_context/scanner/golang.py:

from . import BaseScanner
from ..database import Endpoint

class GoScanner(BaseScanner):
    def can_handle(self, file_path):
        return file_path.suffix == ".go"

    def scan_file(self, file_path):
        # Implement Go-specific scanning
        endpoints = []
        # ... parse Go code ...
        return endpoints

Register in scanner/python.py:

def get_scanner(language: str):
    scanners = {
        "python": PythonScanner,
        "go": GoScanner,  # Add here
    }
    # ...

Roadmap

  • [x] Basic MCP server
  • [x] Python FastAPI/Flask scanner
  • [x] Embedded Qdrant storage
  • [ ] LLM integration for semantic search
  • [ ] Support for more languages (Go, Rust, Node.js)
  • [ ] Web UI for endpoint management
  • [ ] VS Code extension
  • [ ] Automatic re-scanning on file changes
  • [ ] Cloud-hosted version for teams

Contributing

Contributions welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

License

MIT License - see LICENSE file for details

FAQ

Q: Does this work with Claude Desktop?

A: Yes! It works with both Claude Code and Claude Desktop.

Q: Can I use a remote Qdrant server?

A: Yes, set CODE_CONTEXT_QDRANT_URL environment variable.

Q: How do I update endpoints when code changes?

A: Re-run scan_codebase on the directory. Future versions will support auto-refresh.

Q: Can I use this with non-Python projects?

A: Not yet, but Go/Rust/Node.js support is planned. You can manually add endpoints with add_endpoint.

Q: Does this send my code to external services?

A: No. Everything runs locally unless you configure a remote Qdrant server. LLM integration (optional) will use your API keys.

Support


Made with ❤️ for the AI coding community

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选