Code Knowledge MCP Server

local-only server

The server can only run on the client’s local machine because it depends on local resources.

Integrations

  • Provides knowledge management tool for code repositories, suggesting integration with Git repositories

  • References cloning from a GitHub repository as part of the setup process

  • Uses Ollama for efficient embedding generation, requiring it to be installed and running for vector operations

代码知识工具

一个使用向量嵌入的代码库知识管理工具。此工具使用高级嵌入技术,帮助您维护和查询代码库知识。

构建和安装

1. 构建包

首先,您需要构建分发文件:

# Clone the repository git clone https://github.com/yourusername/code-knowledge-tool.git cd code-knowledge-tool # Create and activate a virtual environment python -m venv venv source venv/bin/activate # Install build tools python -m pip install --upgrade pip build # Build the package python -m build

这将在 dist/ 目录中创建两个文件:

  • code_knowledge_tool-0.1.0-py3-none-any.whl(安装用wheel文件)
  • code_knowledge_tool-0.1.0.tar.gz(源代码分发)

2.安装软件包

先决条件

  1. 确保 Ollama 已安装并正在运行:
# Install Ollama (if not already installed) curl https://ollama.ai/install.sh | sh # Start Ollama service ollama serve
  1. 安装软件包:
选项 1:从 wheel 文件安装(推荐使用)
# Navigate to where you built the package cd /path/to/code_knowledge_tool # Install from the wheel file pip install dist/code_knowledge_tool-0.1.0-py3-none-any.whl
选项 2:以可编辑模式安装(推荐用于开发)

如果您想修改该工具或为其开发做出贡献,那么此选项是最好的:

# Assuming you're already in the code-knowledge-tool directory # and have activated your virtual environment # Install in editable mode with development dependencies pip install -e ".[dev]"

与 RooCode/Cline 集成

  1. 将 MCP 配置复制到您的设置中:

对于 Cline (VSCode):

# Open the settings file open ~/Library/Application\ Support/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_mcp_settings.json

添加此配置:

{ "mcpServers": { "code_knowledge": { "command": "python", "args": ["-m", "code_knowledge_tool.mcp_tool"], "env": { "PYTHONPATH": "${workspaceFolder}" } } } }

对于 RooCode:

# Open the settings file open ~/Library/Application\ Support/RooCode/roocode_config.json

添加与上面相同的配置。

  1. 重新启动 RooCode/Cline 以加载新工具。

用作记忆库和 RAG 上下文提供程序

此工具可用作项目的记忆库和 RAG 上下文提供程序。设置方法如下:

  1. 将提供的模板复制到您的项目中:
cp clinerules_template.md /path/to/your/project/.clinerules
  1. 根据项目需求定制 .clinerules 中的规则和模式

该模板包含以下方面的全面说明:

  • 知识库管理
  • 基于 RAG 的开发工作流程
  • 代码质量指南
  • 内存管理实践

有关完整配置和使用详情,请参阅 clinerules_template.md。

特征

  • 用于代码知识的本地向量存储
  • 使用 Ollama 高效生成嵌入
  • 支持多种文件类型
  • 上下文感知代码理解
  • 通过 MCP 与 RooCode 和 Cline 集成
  • 基于 RAG 的上下文增强
  • 持久知识存储

要求

  • Python 3.8 或更高版本
  • Ollama 服务在本地运行
  • 用于向量运算的 chromadb

发展

运行测试

该项目采用集成优先的测试方法,重点关注端到端功能和 MCP 合同合规性。测试套件包括:

  1. MCP 合同测试
    • 工具注册和执行
    • 资源管理
    • 知识运营
    • 错误处理
  2. 包构建测试
    • 安装验证
    • 依赖关系解析
    • MCP 服务器初始化
    • 基本功能

运行测试:

# Install test dependencies pip install -e ".[dev]" # Run all tests pytest # Run specific test suites pytest tests/integration/test_mcp_contract.py -v # MCP functionality pytest tests/integration/test_package_build.py -v # Installation verification

测试环境要求:

# Ensure Ollama is running ollama serve

测试使用临时目录(test_knowledge_store),该目录会在测试运行之间自动清理。

有关测试策略和模式的更多详细信息,请参阅docs/中的文档。

未来分布

如果您想通过 pip 使用这个包(即pip install code-knowledge-tool ),您需要:

  1. PyPI上注册一个账户
  2. 安装 twine: pip install twine
  3. 上传你的发行版: twine upload dist/*

但是,目前请使用上面描述的本地构建和安装方法。

执照

MIT 许可证

-
security - not tested
F
license - not found
-
quality - not tested

提供项目存储库和 RAG 上下文提供程序,通过矢量嵌入增强代码理解和管理,并与 RooCode 和 Cline 集成。

  1. Building and Installing
    1. 1. Build the Package
    2. 2. Install the Package
  2. Integration with RooCode/Cline
    1. Using as Memory Bank and RAG Context Provider
      1. Features
        1. Requirements
          1. Development
            1. Running Tests
          2. Future Distribution
            1. License
              ID: prkz57y7a2