Back to MCP directory
publicPublicdnsLocal runtime

CodeQL

一个运行Model Context Protocol (MCP)服务器的项目,封装了CodeQL查询服务器,支持通过结构化命令和文档搜索与CodeQL交互。

article

README

🚀 CodeQL MCP 服务器

本项目运行一个模型上下文协议(MCP)服务器,该服务器对 CodeQL 查询服务器进行了封装。借助它,工具(例如 Cursor 或 AI 代理)能够通过结构化命令和文档搜索与 CodeQL 展开交互。

🚀 快速开始

先决条件

使用 uv 安装:

uv pip install -r requirements.txt

或使用 pip

pip install fastmcp httpx

运行 MCP 服务器

uv run mcp run server.py -t sse
  • 服务器将在 http://localhost:8000/sse 启动。
  • 此服务器适用于 Cursor 或 AI 代理使用。

Cursor 配置

确保你的 .cursor/config.json 包含以下内容:

{
  "mcpServers": {
    "CodeQL": {
      "url": "http://localhost:8000/sse"
    }
  }
}

✨ 主要特性

  • ✅ 注册 CodeQL 数据库
  • ✅ 运行完整查询或快速评估一个符号
  • ✅ 解码 .bqrs 文件为 JSON
  • ✅ 定位谓词/类符号位置

📦 安装指南

安装依赖

你可以选择使用 uvpip 来安装所需依赖:

  • 使用 uv
uv pip install -r requirements.txt
  • 使用 pip
pip install fastmcp httpx

启动服务器

使用以下命令启动 MCP 服务器:

uv run mcp run server.py -t sse

📚 详细文档

文件结构

| 文件 | 用途 | |-------------------|-----------------------------------------------------| | server.py | 主 FastMCP 服务器,暴露 CodeQL 工具 | | codeqlclient.py | CodeQLQueryServer 实现(JSON-RPC 处理器) |

注意事项

⚠️ 重要提示

  • 工具如 Cursor 会通过自然语言直接调用这些命令。
  • 你必须在 PATH 中有一个 codeql 可执行文件,或在 codeqlclient.py 中硬编码其路径。
  • 你可能需要在提示中指定查询位置、查询写入位置和数据库路径。
help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client