Token导航 LogoToken导航TokenDH.com
Code Delite MCP logo
AI代理stdio官方级别未说明来源级核验

Code Delite MCP

MCP Server

Codedelite MCP Server是一个增强AI编码辅助的协议服务器,通过包装用户查询并提供全面的编码标准,自动记录请求-响应对以进行分析和训练数据收集。

工具数

0

提示词数

0

GitHub Stars

0

资源数

0
PythonClaudeAI代理ClaudeVS Code

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

MSSHARSHITH22

提供方

MSSHARSHITH22

最后核验

2026/5/17 20:22

运行时

Python

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

python -m venv venv

详细介绍

Codedelite MCP 服务器

一个模型上下文协议(MCP)服务器,它通过将用户查询与全面的编码标准相结合,并自动记录请求-响应对以供分析和训练数据收集,从而增强AI编码辅助功能。

🚀 特性

  • 标准提升自动将用户查询包裹在您的自定义编码标准中
  • 请求-响应日志记录捕获完整的对话对以进行分析
  • 会话跟踪将请求和响应通过唯一的会话ID关联起来
  • 元数据收集记录响应元数据(模型、令牌、时间等)
  • 自动客户端指令为AI客户端提供明确的指示,以便将响应记录回传

📋 目录

🛠 安装

先决条件

  • Python 3.11及以上版本
  • 带有MCP扩展的VS Code
  • 虚拟环境(推荐)

设置

  1. 克隆或下载服务器文件
   # Ensure you have the server.py file in your project directory
  1. 创建并激活虚拟环境
   python -m venv venv
   source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. 安装依赖项
   pip install fastmcp pydantic
  1. 测试服务器
   python server.py

⚙️ 配置

VS Code MCP 配置

在你的VS Code中添加以下内容 mcp.json 配置文件:

{
  "servers": {
    "codedelite": {
      "type": "stdio",
      "command": "/Users/kanavkahol/work/codeMCP/venv/bin/python",
      "args": ["-u", "/Users/kanavkahol/work/codeMCP/server.py"],
      "env": {
        "CODEDELITE_LOG_PATH": "/Users/kanavkahol/work/codeMCP/.codedelite/codedelite.log.jsonl"
      }
    }
  }
}

重要的更新路径以匹配您的实际安装目录。

环境变量

  • CODEDELITE_LOG_PATH日志文件的路径(默认: ./codedelite.log.jsonl)

🎯 使用方法

基本工作流程

  1. 用户查询用户在VS Code中提出一个编码问题
  2. 标准提升服务器根据您的编码标准对查询进行封装
  3. 人工智能回复AI根据增强后的提示生成回复
  4. 自动记录客户端自动将响应记录回服务器
  5. 数据收集完整的请求-响应对被存储起来以供分析

示例交互

用户查询: "what is pytest. give me a getting started guide."

服务器响应增强提示,包含标准+记录响应的说明

人工智能回复全面的pytest指南

自动记录响应连同元数据一起被记录返回

🏗 建筑

核心组件

┌─────────────────┐    ┌──────────────────┐    ┌─────────────────┐
│   VS Code       │    │  Codedelite      │    │   AI Client     │
│   (User)        │    │  MCP Server      │    │   (Copilot)     │
└─────────────────┘    └──────────────────┘    └─────────────────┘
         │                       │                       │
         │ 1. User Query         │                       │
         ├──────────────────────►│                       │
         │                       │                       │
         │                       │ 2. Enhanced Prompt    │
         │                       ├──────────────────────►│
         │                       │                       │
         │                       │ 3. AI Response        │
         │                       │◄──────────────────────┤
         │                       │                       │
         │                       │ 4. Log Response       │
         │                       │◄──────────────────────┤
         │                       │                       │
         │ 5. Final Response     │                       │
         │◄──────────────────────┤                       │

可用工具

  1. generate增强用户查询的编码标准
  2. log_response捕获AI响应以进行分析

📊 日志系统

日志结构

服务器创建包含以下字段的结构化JSON日志:

请求日志

{
  "ts": "2025-09-04T17:47:11.302955+00:00",
  "version": "1.0.0",
  "tool": "codedelite.generate",
  "type": "request",
  "query": "user query here",
  "session_id": "unique-uuid",
  "augmented_prompt_len": 1054
}

响应日志

{
  "ts": "2025-09-04T17:53:54.605861+00:00",
  "version": "1.0.0",
  "tool": "codedelite.log_response",
  "type": "response",
  "original_query": "original user query",
  "response": "AI generated response",
  "session_id": "matching-uuid",
  "response_metadata": {
    "model": "claude-3-5-sonnet",
    "tokens_used": 8500,
    "response_time_ms": 15000
  },
  "response_length": 6579
}

日志字段说明

字段类型描述
ts字符串事件的ISO时间戳
version字符串服务器版本
tool字符串生成日志条目的工具
type字符串"请求" 或 "响应"
query字符串原始用户查询
session_id字符串用于关联请求-响应对的 UUID
response字符串人工智能生成的回复(仅限回复日志)
response_metadata对象额外响应信息
response_length编号响应字符数

📝 示例日志

以下是日志文件中的一个实际示例,展示了完整的请求-响应对:

请求日志条目

{
  "ts": "2025-09-04T17:47:11.302955+00:00",
  "version": "1.0.0",
  "tool": "codedelite.generate",
  "type": "request",
  "query": "what is pytest. give me a getting started guide.",
  "session_id": "e7953783-9425-43a2-b538-e6a41a81898c",
  "augmented_prompt_len": 1054
}

响应日志条目

{
  "ts": "2025-09-04T17:53:54.605861+00:00",
  "version": "1.0.0",
  "tool": "codedelite.log_response",
  "type": "response",
  "original_query": "what is pytest. give me a getting started guide.",
  "response": "# Pytest Getting Started Guide\n\n## Plan\nI've provided a comprehensive pytest guide covering:\n1. **What pytest is** and its key advantages\n2. **Installation and setup** process\n3. **Core testing concepts** with practical examples\n4. **Advanced features** like fixtures and parametrization\n5. **Best practices** and testing patterns\n\n## What is Pytest?\n\n**Pytest** is a mature, feature-rich Python testing framework that makes it easy to write simple and scalable test cases. It's designed to support simple unit testing as well as complex functional testing for applications and libraries.\n\n### Key Advantages:\n- **Simple syntax**: Write tests with plain `assert` statements\n- **Auto-discovery**: Automatically finds and runs test files\n- **Rich plugin ecosystem**: Extensive third-party plugins\n- **Detailed failure reporting**: Clear, informative test failure messages\n- **Fixtures**: Powerful dependency injection system\n- **Parametrization**: Run tests with multiple input sets\n\n## Complete Implementation\n\nI've created a comprehensive pytest demonstration project with:\n\n### Core Files Created:\n1. **`pytest_demo/calculator.py`** - A feature-rich calculator class with proper error handling and documentation\n2. **`pytest_demo/test_calculator.py`** - Comprehensive test suite demonstrating all pytest features\n3. **`pytest_demo/test_advanced.py`** - Advanced testing patterns including mocking, fixtures, and performance testing\n4. **`pytest_demo/conftest.py`** - Shared fixtures and pytest configuration\n5. **`pyproject.toml`** - Project configuration with pytest settings\n6. **`PYTEST_GUIDE.md`** - Complete documentation and tutorial\n7. **`run_tests.py`** - Test runner script with different execution options\n\n### Key Features Demonstrated:\n\n#### 1. **Basic Testing Patterns**\n```python\ndef test_add_positive_numbers(calculator):\n    result = calculator.add(5, 3)\n    assert result == 8\n```\n\n#### 2. **Exception Testing**\n```python\ndef test_divide_by_zero_raises_value_error(calculator):\n    with pytest.raises(ValueError, match=\"Cannot divide by zero\"):\n        calculator.divide(10, 0)\n```\n\n#### 3. **Parametrized Tests**\n```python\n@pytest.mark.parametrize(\"a, b, expected\", [\n    (1, 2, 3),\n    (0, 0, 0),\n    (-1, 1, 0),\n])\ndef test_add_parametrized(calculator, a, b, expected):\n    result = calculator.add(a, b)\n    assert result == expected\n```\n\n#### 4. **Fixtures for Dependency Injection**\n```python\n@pytest.fixture\ndef calculator():\n    return Calculator()\n\n@pytest.fixture(scope=\"session\")\ndef temp_dir():\n    with tempfile.TemporaryDirectory() as tmp_dir:\n        yield Path(tmp_dir)\n```\n\n#### 5. **Test Markers and Categories**\n```python\n@pytest.mark.slow\ndef test_large_factorial():\n    result = factorial(20)\n    assert result == 2432902008176640000\n\n@pytest.mark.integration\ndef test_complex_calculation_chain(calculator):\n    # Test multiple operations together\n```\n\n### Live Demo Results:\n\nI executed the tests to show pytest in action:\n\n**✅ 56 tests passed** with detailed output showing:\n- Test discovery and execution\n- Clear pass/fail indicators\n- Coverage analysis (97% for calculator.py)\n- Parametrized test execution\n- Error reporting for intentional failures\n\n### Command Examples:\n\n```bash\n# Run all tests\npytest\n\n# Run with verbose output\npytest -v\n\n# Run specific test file\npytest test_calculator.py\n\n# Run tests matching pattern\npytest -k \"add\"\n\n# Run with coverage\npytest --cov=src --cov-report=html\n\n# Skip slow tests\npytest -m \"not slow\"\n\n# Run only unit tests\npytest -m \"unit\"\n```\n\n## Design Choices & Trade-offs\n\n1. **Comprehensive Calculator Example**: Chose a calculator as it's familiar yet complex enough to demonstrate all pytest features\n2. **Multiple Test Categories**: Organized tests into logical groups (basic, exceptions, parametrized, etc.)\n3. **Fixture Scoping**: Demonstrated different fixture scopes for optimal performance\n4. **Configuration**: Used pyproject.toml for modern Python project standards\n5. **Error Handling**: Included comprehensive exception testing\n\n## Unit Tests Included\n\nThe project includes extensive unit tests covering:\n- ✅ **56 test functions** across multiple test classes\n- ✅ **Basic operations** (add, subtract, multiply, divide)\n- ✅ **Edge cases** (infinity, NaN, very large numbers)\n- ✅ **Exception handling** with proper error messages\n- ✅ **Parametrized tests** with multiple input sets\n- ✅ **Fixture usage** for setup and teardown\n- ✅ **Mocking examples** for external dependencies\n- ✅ **History tracking** and state management\n- ✅ **Performance considerations** for slow operations\n\n### Running Instructions:\n```bash\n# Install dependencies\npip install pytest pytest-cov pytest-mock\n\n# Run basic tests\npython run_tests.py --basic\n\n# Run all tests with coverage\npython run_tests.py --all\n\n# Generate HTML reports\npython run_tests.py --reports\n```\n\n## Alternative Implementations\n\n### Alternative 1: Simpler Structure\n**Pros**: Easier to understand for beginners\n**Cons**: Less comprehensive, fewer advanced features\n\n```python\n# Simple approach\ndef test_addition():\n    assert add(2, 3) == 5\n\ndef test_division():\n    assert divide(10, 2) == 5\n```\n\n### Alternative 2: Class-based Testing (unittest style)\n**Pros**: Familiar to developers from other frameworks\n**Cons**: More verbose, less pythonic\n\n```python\nclass CalculatorTest(unittest.TestCase):\n    def setUp(self):\n        self.calc = Calculator()\n    \n    def test_addition(self):\n        self.assertEqual(self.calc.add(2, 3), 5)\n```\n\n### Alternative 3: Property-based Testing (Hypothesis)\n**Pros**: Tests more edge cases automatically\n**Cons**: Requires additional dependency, more complex\n\n```python\nfrom hypothesis import given, strategies as st\n\n@given(st.integers(), st.integers())\ndef test_addition_commutative(a, b):\n    assert add(a, b) == add(b, a)\n```\n\n## Next Steps\n\n1. **Explore Plugins**: pytest-django, pytest-asyncio, pytest-benchmark\n2. **CI/CD Integration**: Set up automated testing in GitHub Actions\n3. **Property-based Testing**: Add Hypothesis for more thorough testing\n4. **Performance Testing**: Use pytest-benchmark for performance regression testing\n5. **Test Coverage Goals**: Aim for >90% coverage with meaningful tests\n\n## Assumptions Made\n\n- Python 3.8+ environment\n- Familiarity with basic Python concepts\n- Interest in comprehensive testing practices\n- VS Code as development environment\n- Modern project structure preferences\n\nThe implementation demonstrates pytest's power while maintaining readability and educational value. Each test serves as both validation and documentation of expected behavior.",
  "session_id": "e7953783-9425-43a2-b538-e6a41a81898c",
  "response_metadata": {
    "model": "claude-3-5-sonnet",
    "tokens_used": 8500,
    "response_time_ms": 15000,
    "features_demonstrated": ["pytest_basics", "fixtures", "parametrization", "mocking", "coverage", "markers", "configuration"]
  },
  "response_length": 6579
}

这个例子的分析

这个日志条目显示:

  • 请求用户请求一份pytest入门指南
  • 回应全面的6,579字指南,涵盖从pytest基础到高级功能
  • 元数据

- 模型:Claude 3.5 Sonnet - 使用的代币数:8,500 - 响应时间:15秒 - 展示的功能:多个pytest概念

  • 会话链接两个条目使用相同的会话ID,以便轻松配对

🔧 API参考

工具

generate

增强用户查询以符合编码标准,并提供响应日志记录的说明。

输入:

{
  "query": "string - The user's coding question"
}

输出:

{
  "augmented_prompt": "string - Enhanced prompt with standards",
  "suggested_copilot_message": "string - Complete message for AI client",
  "meta": {
    "version": "string",
    "server": "string", 
    "timestamp": "number",
    "session_id": "string - UUID for linking responses"
  }
}

log_response

记录AI的响应以创建请求-响应对。

输入:

{
  "original_query": "string - Original user query",
  "response": "string - AI generated response",
  "session_id": "string - UUID from generate tool",
  "response_metadata": {
    "model": "string - AI model used",
    "tokens_used": "number - Token count",
    "response_time_ms": "number - Response time"
  }
}

输出:

{
  "success": "boolean - Whether logging succeeded",
  "message": "string - Status message",
  "meta": {
    "version": "string",
    "server": "string",
    "timestamp": "number",
    "log_entry_id": "string - Timestamp of log entry"
  }
}

🛠 开发

项目结构

codeMCP/
├── server.py              # Main MCP server
├── venv/                  # Virtual environment
├── .codedelite/           # Log directory
│   └── codedelite.log.jsonl
└── README.md              # This file

关键组件

  1. FastMCP 服务器处理MCP协议通信
  2. Pydantic 模型类型安全的数据验证
  3. 日志系统结构化JSON日志记录
  4. 会话管理基于UUID的请求-响应关联

定制化

修改编码规范

编辑 HOUSE_BLOCK 恒定不变于 server.py

HOUSE_BLOCK = """\
Please adhere to all the following standards and behaviors:

1) Code Quality & Linting
   - Follow idiomatic patterns and established style guides
   - Include docstrings/comments for complex logic
   - Keep functions cohesive; avoid excessive side effects

2) Unit Tests
   - Provide unit tests for all non-trivial functions
   - Use realistic fixtures/mocks; cover edge cases
   - Show clear instructions for running tests

# Add your custom standards here...
"""

添加响应元数据

这个(或“该”) response_metadata 字段可以包含任何自定义数据:

{
  "model": "gpt-4",
  "tokens_used": 1500,
  "response_time_ms": 2500,
  "custom_field": "custom_value",
  "user_feedback": "helpful",
  "code_quality_score": 9.5
}

故障排除

常见问题

  1. 导入错误确保已激活虚拟环境
  2. 权限错误检查日志文件路径的权限
  3. MCP 连接验证 VS Code MCP 配置路径

调试模式

通过修改服务器来添加调试日志:

import logging
logging.basicConfig(level=logging.DEBUG)

做出贡献

  1. 为仓库创建分支(或:克隆仓库)
  2. 创建一个特性分支
  3. 进行你的更改
  4. 进行彻底测试
  5. 提交一个拉取请求

📈 优势/好处

对于开发者

  • 一致的代码质量自动应用编码标准
  • 学习工具看看标准如何提升人工智能的回应质量
  • 训练数据收集高质量的对话对

适用于团队

  • 标准化确保所有使用AI辅助生成的代码都符合团队标准
  • 分析(或分析学)追踪AI响应的质量和效果
  • 改进利用记录的数据来完善提示和标准

对于组织而言

  • 合规确保人工智能生成的代码符合组织标准
  • 审计轨迹/审计路径人工智能交互的完整记录
  • 优化基于数据的AI编码辅助优化

🔮 未来改进方向

  • 响应质量评分自动质量评估
  • 根据项目定制标准项目特定的编码标准
  • 分析仪表盘日志分析的网页界面
  • 集成API(应用程序编程接口)与其他开发工具连接
  • 机器学习利用记录的数据来提升标准

📄 许可证

这个项目是开源的。请随意根据您的需求进行修改和分发。

🤝 支持

如需报告问题、提出疑问或做出贡献,请在项目仓库中提交一个议题。

______________________________________________________________________

享受增强型AI辅助的快乐编码! 🚀 表情符号“🚀”在中文中通常被翻译为“火箭”或“飞速前进”,用来表示快速、进步或充满活力的状态。所以,这个表情可以理解为“火箭”或“飞速前进”。

目录标签

目录标签

PythonClaudeAI代理AI编码辅助本地部署协议服务器编码标准请求-响应日志训练数据收集

支持客户端

ClaudeVS Code

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

token

运行时(runtime,运行环境)

Python

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdiotoken部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP