代码逻辑mcp服务器
一 MCP服务器 在您的AI编程助手中利用Codelogic丰富的软件依赖性数据。
组件
工具
服务器实现了五个工具:
代码分析工具
- 代码逻辑方法影响:从CodeLogic服务器的API中为您的代码提取影响评估。
- 接受您正在处理的给定“方法”及其关联的“类”。
- 代码逻辑数据库影响:分析代码和数据库实体之间的影响。
- 获取数据库实体类型(列、表或视图)及其名称。
DevOps和CI/CD集成工具
- 代码逻辑docker代理:为CI/CD管道中的CodeLogic扫描生成Docker代理配置。
- 支持。NET、Java、SQL和TypeScript代理 - 为Jenkins、GitHub Actions、Azure DevOps和GitLab CI生成配置
- 代码逻辑构建信息:生成CodeLogic集成的构建信息并发送命令。
- 支持Git信息、构建日志和元数据收集 - 提供Docker和独立使用示例
- 代码逻辑管道助手:为CodeLogic集成生成完整的CI/CD管道配置。
- 使用最佳实践创建全面的管道配置 - 包括错误处理、通知和扫描空间管理策略
安装
先决条件
MCP服务器依赖Astral UV运行,请 安装
适用于uvx的MacOS解决方案
存在一个已知的问题 uvx 上 MacOS 在某些IDE(如Cursor)中,CodeLogic MCP服务器可能无法启动,从而导致以下错误: 看 问题#11
Failed to connect client closed这似乎是Astral的问题 uvx 在MacOS上运行。以下方法可作为解决方法:
- 在本地克隆此项目。
- 配置您的
mcp.json使用uv而不是uvx例如:
{
"mcpServers": {
"codelogic-mcp-server": {
"type": "stdio",
"command": "
/uv",
"args": [
"--directory",
"
/codelogic-mcp-server-main",
"run",
"codelogic-mcp-server"
],
"env": {
"CODELOGIC_SERVER_HOST": "",
"CODELOGIC_USERNAME": "",
"CODELOGIC_PASSWORD": "",
"CODELOGIC_WORKSPACE_NAME": "",
"CODELOGIC_DEBUG_MODE": "true"
}
}
}
}- 重新启动游标。
- 确保CodeLogic的游标全局规则已到位。
- 在光标中打开MCP选项卡并刷新
codelogic-mcp-server. - 让Cursor在现有类中进行代码更改。MCP服务器现在应该成功运行影响分析。
不同IDE的配置
Visual Studio代码配置
要在VS代码中配置此MCP服务器:
- 首先,确保在VS Code中启用了GitHub Copilot代理模式。
- 创建
.vscode/mcp.json使用以下配置在工作区中创建文件:
{
"servers": {
"codelogic-mcp-server": {
"type": "stdio",
"command": "uvx",
"args": [
"codelogic-mcp-server@latest"
],
"env": {
"CODELOGIC_SERVER_HOST": "",
"CODELOGIC_USERNAME": "",
"CODELOGIC_PASSWORD": "",
"CODELOGIC_WORKSPACE_NAME": "",
"CODELOGIC_DEBUG_MODE": "true"
}
}
}
}注: 在某些系统上,您可能需要使用uvx可执行文件的完整路径,而不仅仅是“uvx”。例如:/home/user/.local/bin/uvx在Linux/Mac或C:\Users\username\AppData\Local\astral\uvx.exe在Windows上。
- 或者,您可以运行
MCP: Add Server命令面板中的命令,并提供服务器信息。
- 要管理您的MCP服务器,请使用
MCP: List Servers命令选项板中的命令。
- 配置后,服务器的工具将可用于Copilot代理模式。在代理模式下,您可以通过单击聊天视图中的工具按钮根据需要打开/关闭特定工具。
- 要在代理模式下使用Codelogic工具,您可以专门询问代码影响或数据库关系,代理将使用适当的工具。
Claude桌面配置
通过编辑配置文件配置Claude Desktop:
- 在MacOS上:
~/Library/Application\ Support/Claude/claude_desktop_config.json - 在Windows上:
%APPDATA%/Claude/claude_desktop_config.json - 在Linux上:
~/.config/Claude/claude_desktop_config.json
将以下内容添加到配置文件中:
"mcpServers": {
"codelogic-mcp-server": {
"command": "uvx",
"args": [
"codelogic-mcp-server@latest"
],
"env": {
"CODELOGIC_SERVER_HOST": "",
"CODELOGIC_USERNAME": "",
"CODELOGIC_PASSWORD": "",
"CODELOGIC_WORKSPACE_NAME": ""
}
}
}注: 在某些系统上,您可能需要使用uvx可执行文件的完整路径,而不仅仅是“uvx”。例如:/home/user/.local/bin/uvx在Linux/Mac或C:\Users\username\AppData\Local\astral\uvx.exe在Windows上。
添加配置后,重新启动Claude Desktop以应用更改。
Windsurf IDE配置
使用以下命令运行此MCP服务器 Windsurf IDE:
配置Windsurf IDE:
要配置Windsurf IDE,您需要创建或修改 ~/.codeium/windsurf/mcp_config.json 配置文件。
将以下配置添加到文件中:
"mcpServers": {
"codelogic-mcp-server": {
"command": "uvx",
"args": [
"codelogic-mcp-server@latest"
],
"env": {
"CODELOGIC_SERVER_HOST": "",
"CODELOGIC_USERNAME": "",
"CODELOGIC_PASSWORD": "",
"CODELOGIC_WORKSPACE_NAME": ""
}
}
}注: 在某些系统上,您可能需要使用uvx可执行文件的完整路径,而不仅仅是“uvx”。例如:/home/user/.local/bin/uvx在Linux/Mac或C:\Users\username\AppData\Local\astral\uvx.exe在Windows上。
添加配置后,重新启动Windsurf IDE或刷新工具以应用更改。
光标配置
要在Cursor中配置CodeLogic MCP服务器,请执行以下操作:
- 通过创建配置MCP服务器
.cursor/mcp.json文件:
{
"mcpServers": {
"codelogic-mcp-server": {
"command": "uvx",
"args": [
"codelogic-mcp-server@latest"
],
"env": {
"CODELOGIC_SERVER_HOST": "",
"CODELOGIC_USERNAME": "",
"CODELOGIC_PASSWORD": "",
"CODELOGIC_WORKSPACE_NAME": "",
"CODELOGIC_DEBUG_MODE": "true"
}
}
}
}注: 在某些系统上,您可能需要使用uvx可执行文件的完整路径,而不仅仅是“uvx”。例如:/home/user/.local/bin/uvx在Linux/Mac或C:\Users\username\AppData\Local\astral\uvx.exe在Windows上。
- 重新启动Cursor以应用更改。
CodeLogic MCP服务器工具现在将在您的Cursor工作区中可用。
DevOps集成
CodeLogic MCP服务器现在包括强大的DevOps功能,用于将CodeLogic扫描集成到您的CI/CD管道中。这些工具可以帮助DevOps团队:
Docker代理集成
- 为CodeLogic代理生成Docker运行命令
- 创建特定于平台的配置(Jenkins、GitHub Actions、Azure DevOps、GitLab CI)
- 设置适当的环境变量和卷装载
- 包括构建信息收集
构建信息管理
- 将Git信息、构建日志和元数据发送到CodeLogic服务器
- 支持具有平台特定变量的多个CI/CD平台
- 处理日志文件管理和轮换
- 提供Docker和独立使用选项
完整的管道配置
- 生成端到端CI/CD管道配置
- 包括错误处理、通知和监控
- 支持不同的扫描空间管理策略
- 遵循DevOps的安全和性能最佳实践
示例用法
# Generate Docker agent configuration for .NET
codelogic-docker-agent --agent-type=dotnet --scan-path=/app --application-name=MyApp --ci-platform=jenkins
# Set up build information sending
codelogic-build-info --build-type=all --output-format=docker --ci-platform=github-actions
# Create complete pipeline configuration
codelogic-pipeline-helper --ci-platform=jenkins --agent-type=dotnet --scan-triggers=main,developAI助手说明/规则
为了帮助AI助手有效地使用CodeLogic工具,您可以将以下说明/规则添加到客户端的配置中。我们建议定制这些说明,以符合您团队的特定编码标准、最佳实践和工作流程要求:
VS代码(GitHub副本)说明
创建 .vscode/copilot-instructions.md 包含以下内容的文件:
# CodeLogic MCP Server Instructions
When modifying existing code methods:
- Use codelogic-method-impact to analyze code changes
- Use codelogic-database-impact for database modifications
- Highlight impact results for the modified methods
When modifying SQL code or database entities:
- Always use codelogic-database-impact to analyze potential impacts
- Highlight impact results for the modified database entities
For DevOps and CI/CD integration:
- Use codelogic-docker-agent to generate Docker agent configurations
- Use codelogic-build-info to set up build information sending
- Use codelogic-pipeline-helper to create complete CI/CD pipeline configurations
- Support Jenkins, GitHub Actions, Azure DevOps, and GitLab CI platforms
To use the CodeLogic tools effectively:
- For code impacts: Ask about specific methods or functions
- For database relationships: Ask about tables, views, or columns
- For DevOps: Ask about CI/CD integration, Docker agents, or build information
- Review the impact results before making changes
- Consider both direct and indirect impactsClaude桌面说明
创建文件 ~/.claude/instructions.md 内容如下:
# CodeLogic MCP Server Instructions
When modifying existing code methods:
- Use codelogic-method-impact to analyze code changes
- Use codelogic-database-impact for database modifications
- Highlight impact results for the modified methods
When modifying SQL code or database entities:
- Always use codelogic-database-impact to analyze potential impacts
- Highlight impact results for the modified database entities
For DevOps and CI/CD integration:
- Use codelogic-docker-agent to generate Docker agent configurations
- Use codelogic-build-info to set up build information sending
- Use codelogic-pipeline-helper to create complete CI/CD pipeline configurations
- Support Jenkins, GitHub Actions, Azure DevOps, and GitLab CI platforms
To use the CodeLogic tools effectively:
- For code impacts: Ask about specific methods or functions
- For database relationships: Ask about tables, views, or columns
- For DevOps: Ask about CI/CD integration, Docker agents, or build information
- Review the impact results before making changes
- Consider both direct and indirect impactsWindsurf IDE规则
创建或修改 ~/.codeium/windsurf/memories/global_rules.md 包含以下内容的markdown文件:
When modifying existing code methods:
- Use codelogic-method-impact to analyze code changes
- Use codelogic-database-impact for database modifications
- Highlight impact results for the modified methods
When modifying SQL code or database entities:
- Always use codelogic-database-impact to analyze potential impacts
- Highlight impact results for the modified database entities
For DevOps and CI/CD integration:
- Use codelogic-docker-agent to generate Docker agent configurations
- Use codelogic-build-info to set up build information sending
- Use codelogic-pipeline-helper to create complete CI/CD pipeline configurations
- Support Jenkins, GitHub Actions, Azure DevOps, and GitLab CI platforms
To use the CodeLogic tools effectively:
- For code impacts: Ask about specific methods or functions
- For database relationships: Ask about tables, views, or columns
- For DevOps: Ask about CI/CD integration, Docker agents, or build information
- Review the impact results before making changes
- Consider both direct and indirect impacts光标全局规则
要在游标中配置CodeLogic规则,请执行以下操作:
- 打开光标设置
- 导航到“规则”部分
- 在“用户规则”中添加以下内容:
# CodeLogic MCP Server Rules
## Codebase
- The CodeLogic MCP Server is for java, javascript, typescript, and C# dotnet codebases
- don't run the tools on python or other non supported codebases
## AI Assistant Behavior
- When modifying existing code methods:
- Use codelogic-method-impact to analyze code changes
- Use codelogic-database-impact for database modifications
- Highlight impact results for the modified methods
- When modifying SQL code or database entities:
- Always use codelogic-database-impact to analyze potential impacts
- Highlight impact results for the modified database entities
- To use the CodeLogic tools effectively:
- For code impacts: Ask about specific methods or functions
- For database relationships: Ask about tables, views, or columns
- Review the impact results before making changes
- Consider both direct and indirect impacts环境变量
可以配置以下环境变量来自定义服务器的行为:
CODELOGIC_SERVER_HOST:CodeLogic服务器的URL。CODELOGIC_USERNAME:您的CodeLogic用户名。CODELOGIC_PASSWORD:您的CodeLogic密码。CODELOGIC_WORKSPACE_NAME:要使用的工作区的名称。CODELOGIC_DEBUG_MODE:设置为true启用调试模式。启用后,其他调试文件,如timing_log.txt和impact_data*.json将生成。默认为false.
配置示例
"env": {
"CODELOGIC_SERVER_HOST": "",
"CODELOGIC_USERNAME": "",
"CODELOGIC_PASSWORD": "",
"CODELOGIC_WORKSPACE_NAME": "",
"CODELOGIC_DEBUG_MODE": "true"
}固定版本
而不是使用 最新的 服务器的版本,您可以通过更改 参数 字段以匹配中的版本 PyPI 例如
"args": [
"codelogic-mcp-server@0.2.2"
],版本兼容性
此MCP服务器具有以下版本兼容性要求:
- 0.3.1及以下版本:兼容所有CodeLogic API版本
- 0.4.0及以上版本:需要CodeLogic API 25.10.0或更高版本
如果正在升级,请确保CodeLogic服务器满足API版本的最低要求。
调试日志
当 CODELOGIC_DEBUG_MODE=true,调试文件将写入系统临时目录:
- 视窗:
%TEMP%\codelogic-mcp-server(通常C:\Users\{username}\AppData\Local\Temp\codelogic-mcp-server) - macOS:
/tmp/codelogic-mcp-server(或$TMPDIR/codelogic-mcp-server如果设置) - Linux:
/tmp/codelogic-mcp-server(或$TMPDIR/codelogic-mcp-server如果设置)
调试文件包括:
timing_log.txt-性能计时信息impact_data_*.json-用于故障排除的原始影响分析数据
查找日志目录:
import tempfile
import os
print("Log directory:", os.path.join(tempfile.gettempdir(), "codelogic-mcp-server"))测试
运行单元测试
该项目使用单元测试进行测试。您可以在没有任何外部依赖的情况下运行单元测试:
python -m unittest discover -s test -p "unit_*.py"单元测试使用模拟数据,不需要连接到CodeLogic服务器。
集成测试(可选)
如果要运行连接到真实CodeLogic服务器的集成测试:
- 复制
test/.env.test.example到test/.env.test并填充您的CodeLogic服务器详细信息 - 运行集成测试:
python -m unittest discover -s test -p "integration_*.py"注意:集成测试需要访问CodeLogic服务器实例。
MCP官方注册验证
mcp名称:io.github。CodeLogicIncEngineering/codelogic mcp服务器

