Token导航 LogoToken导航TokenDH.com
Ada MCP Server logo
开发工具stdio官方级别未说明来源级核验

Ada MCP Server

MCP Server

Ada MCP Server是一个为AI编程代理(如GitHub Copilot)提供Ada语言语义功能的服务器,支持代码导航、诊断、补全和重构等功能。

工具数

20

提示词数

0

GitHub Stars

1

资源数

0
代码导航PythonVS Code开发工具VS Code

安装说明

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

作者 / 组织

MDBrothers

提供方

MDBrothers

最后核验

2026/5/17 20:20

运行时

Python

快速接入

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

命令预览

python --version # Should be 3.11 or higher

详细介绍

Ada MCP服务器

![CI](https://github.com/ada-mcp/ada-mcp-server/actions) ![Python 3.11+](https://www.python.org/downloads/) ![License: MIT](https://opensource.org/licenses/MIT)

MCP(模型上下文协议)服务器,封装Ada语言服务器(ALS),为GitHub Copilot等AI编码代理提供语义Ada语言功能。

为什么选择Ada MCP服务器?

使用Ada代码的AI代理在没有语义理解的情况下面临着巨大的局限性:

不使用此工具使用Ada MCP服务器
基于文本的grep搜索缺少上下文精确定义的语义导航
必须构建以检测类型错误无需编译的实时诊断
无法跳转到定义或用法完整代码导航(定义、引用、实现)
不知道Ada的强类型通过悬停和补全输入信息

特性

  • 🧭 语义导航:转到定义,查找引用、类型定义、实现
  • 🔍 符号搜索:使用过滤进行文档和工作区符号搜索
  • ⚠️ 诊断:实时编译器错误和警告
  • 📁 项目智能:GPR项目解析、调用层次结构、依赖关系图
  • ✨ 代码智能:上下文感知补全、签名帮助
  • 🔧 重构:安全的符号重命名、代码格式化
  • 🏗️ 构建集成:GPRbuild集成,Alire支持
  • 💪 可靠性:在发生指数级回退的崩溃时自动重启
  • ⚡ 演出:基于TTL的缓存可实现更快的响应

先决条件

1.Ada语言服务器(ALS)

通过以下方法之一进行安装:

# Option 1: Alire (recommended)
alr get ada_language_server
cd ada_language_server*
alr build --release
# Binary will be at ./bin/ada_language_server

# Option 2: Pre-built from GitHub releases
# https://github.com/AdaCore/ada_language_server/releases

# Option 3: VS Code Ada extension (usually already installed)
# Found at: ~/.vscode/extensions/adacore.ada-*/x64/linux/ada_language_server

2.Python 3.11+

python --version  # Should be 3.11 or higher

安装

# From PyPI
pip install ada-mcp-server

# From source
git clone https://github.com/ada-mcp/ada-mcp-server
cd ada-mcp-server
pip install -e .

# With uvx (isolated environment)
uvx ada-mcp-server

快速开始

VS代码/副驾驶配置

添加到您的VS代码 settings.json:

{
  "mcpServers": {
    "ada": {
      "command": "ada-mcp",
      "env": {
        "ALS_PATH": "/path/to/ada_language_server",
        "ADA_PROJECT_ROOT": "/path/to/your/ada/project"
      }
    }
  }
}

使用uvx(建议隔离)

{
  "mcpServers": {
    "ada": {
      "command": "uvx",
      "args": ["ada-mcp-server"],
      "env": {
        "ALS_PATH": "ada_language_server",
        "ADA_PROJECT_FILE": "project.gpr"
      }
    }
  }
}

直接执行

# Set environment
export ALS_PATH=/path/to/ada_language_server
export ADA_PROJECT_ROOT=/path/to/project

# Run the server
ada-mcp

# Or via Python module
python -m ada_mcp

______________________________________________________________________

可用工具

导航工具

工具说明
ada_goto_definition导航到符号定义
ada_find_references查找对某个符号的所有引用
ada_type_definition导航到符号的类型定义
ada_implementation从规格导航到车身
ada_hover获取类型信息和文档
ada_get_spec从车身导航到规格

符号工具

工具说明
ada_document_symbols列出文件中的所有符号(大纲)
ada_workspace_symbols跨工作区搜索符号

诊断与构建

工具说明
ada_diagnostics获取编译器错误和警告
ada_build使用GPRbuild构建项目
ada_alire_info获取Alire项目信息

代码智能

工具说明
ada_completions获得上下文感知的完成
ada_signature_help获取函数签名提示
ada_code_actions获取可用的快速修复程序

项目工具

工具说明
ada_project_info获取项目结构信息
ada_call_hierarchy接听/接听来电
ada_dependency_graph获取包依赖关系

重构

工具说明
ada_rename_symbol在整个项目中重命名符号
ada_format_file格式化Ada源文件

______________________________________________________________________

工具示例

ada_goto_definition

导航到定义符号的位置。

{
  "file": "/project/src/main.adb",
  "line": 10,
  "column": 12
}

答复:

{
  "found": true,
  "file": "/project/src/utils.ads",
  "line": 25,
  "column": 4,
  "preview": "procedure Process_Data (Input : String);"
}

ada_find_references

查找项目中符号的所有用法。

{
  "file": "/project/src/utils.ads",
  "line": 25,
  "column": 12,
  "include_declaration": true
}

答复:

{
  "symbol": "Process_Data",
  "references": [
    {"file": "/project/src/utils.ads", "line": 25, "column": 12, "isDefinition": true},
    {"file": "/project/src/main.adb", "line": 10, "column": 4, "isDefinition": false},
    {"file": "/project/src/tests.adb", "line": 8, "column": 8, "isDefinition": false}
  ],
  "totalCount": 3
}

ada_hover

获取符号的类型信息和文档。

{
  "file": "/project/src/main.adb",
  "line": 15,
  "column": 8
}

答复:

{
  "found": true,
  "contents": "function Calculate_Sum (A, B : Integer) return Integer",
  "documentation": "Calculate the sum of two integers.",
  "range": {"start": {"line": 15, "column": 4}, "end": {"line": 15, "column": 17}}
}

阿达迪诊断学

获取编译器错误和警告。

{
  "file": "/project/src/main.adb",
  "severity": "error"
}

答复:

{
  "diagnostics": [
    {
      "file": "/project/src/main.adb",
      "line": 12,
      "column": 10,
      "severity": "error",
      "message": "expected type \"Integer\", found type \"String\""
    }
  ],
  "errorCount": 1,
  "warningCount": 0,
  "hintCount": 0
}

ada_document_symbols

获取文件中的所有符号(轮廓视图)。

{
  "file": "/project/src/utils.ads"
}

答复:

{
  "file": "/project/src/utils.ads",
  "symbols": [
    {
      "name": "Utils",
      "kind": "package",
      "line": 1,
      "children": [
        {"name": "Process_Data", "kind": "procedure", "line": 10, "children": []},
        {"name": "Calculate_Sum", "kind": "function", "line": 15, "children": []}
      ]
    }
  ]
}

ada_完成

获取上下文感知的代码补全。

{
  "file": "/project/src/main.adb",
  "line": 20,
  "column": 10,
  "trigger": "."
}

答复:

{
  "completions": [
    {
      "label": "Process_Data",
      "kind": "procedure",
      "detail": "procedure (Input : String)",
      "insertText": "Process_Data"
    },
    {
      "label": "Calculate_Sum",
      "kind": "function",
      "detail": "function (A, B : Integer) return Integer",
      "insertText": "Calculate_Sum"
    }
  ],
  "isIncomplete": false
}

ada_rename_符号

在整个项目中重命名符号。

{
  "file": "/project/src/utils.ads",
  "line": 10,
  "column": 12,
  "new_name": "Handle_Data",
  "preview": true
}

答复:

{
  "oldName": "Process_Data",
  "newName": "Handle_Data",
  "changes": [
    {"file": "/project/src/utils.ads", "line": 10, "oldText": "Process_Data", "newText": "Handle_Data"},
    {"file": "/project/src/utils.adb", "line": 25, "oldText": "Process_Data", "newText": "Handle_Data"},
    {"file": "/project/src/main.adb", "line": 12, "oldText": "Process_Data", "newText": "Handle_Data"}
  ],
  "totalChanges": 3,
  "applied": false
}

ada_建筑

使用GPRbuild构建项目。

{
  "clean": false
}

答复:

{
  "success": true,
  "exitCode": 0,
  "errors": [],
  "warnings": [],
  "buildTime": 2.5
}

ada_项目信息

获取项目结构信息。

{}

答复:

{
  "projectFile": "/project/project.gpr",
  "projectName": "My_Project",
  "sourceDirs": ["/project/src"],
  "objectDir": "/project/obj",
  "execDir": "/project/bin",
  "mainUnits": ["main.adb"]
}

ada_call_层次结构

获取子程序的调用关系。

{
  "file": "/project/src/utils.adb",
  "line": 25,
  "column": 12,
  "direction": "both"
}

答复:

{
  "symbol": "Process_Data",
  "kind": "procedure",
  "incoming": [
    {"name": "Main", "file": "/project/src/main.adb", "line": 12}
  ],
  "outgoing": [
    {"name": "Validate_Input", "file": "/project/src/validators.ads", "line": 8}
  ]
}

______________________________________________________________________

AI代理使用指南

推荐工作流程

1. UNDERSTAND CONTEXT
   └─→ ada_document_symbols - Get file structure
   └─→ ada_project_info - Understand project layout
   └─→ ada_diagnostics - Check current errors

2. NAVIGATE CODE
   └─→ ada_goto_definition - Find where symbol is defined
   └─→ ada_find_references - Find all usages
   └─→ ada_type_definition - Find type declaration
   └─→ ada_implementation - Find body/implementation

3. UNDERSTAND SYMBOLS
   └─→ ada_hover - Get type info and documentation
   └─→ ada_signature_help - Get subprogram signatures
   └─→ ada_call_hierarchy - See who calls what

4. MAKE CHANGES
   └─→ ada_completions - Get context-aware suggestions
   └─→ ada_rename_symbol - Safely rename across project
   └─→ ada_format_file - Format code consistently

5. VERIFY CHANGES
   └─→ ada_diagnostics - Confirm no new errors
   └─→ ada_build - Full compilation check

工具选择指南

AI代理任务推荐工具
“这个变量是什么类型的?”ada_hover
“这在哪里定义的?”ada_goto_definition
“这个用在哪里?”ada_find_references
“显示此文件的结构”ada_document_symbols
“查找所有名为X的符号”ada_workspace_symbols
“有什么错误吗?”ada_diagnostics
“安全重命名”ada_rename_symbol
“我可以在这里打什么?”ada_completions
“显示此车身的规格”ada_get_spec
“显示此规格的车身”ada_implementation
“这个程序叫什么?”ada_call_hierarchy

最佳实践

  1. 编辑后务必检查诊断 -Ada的类型很强;验证您的更改是否已编译
  2. 在做出假设之前使用鼠标悬停 -获取准确的类型信息
  3. 在重构之前使用find_references -了解全部影响
  4. 使用document_symbols作为方向 -在开始之前了解文件结构
  5. 更喜欢重命名_符号而不是查找替换 -它正确处理所有用法

______________________________________________________________________

配置

环境变量

变量默认值描述
ALS_PATHada_language_serverALS可执行文件的路径
ADA_PROJECT_FILE自动检测GPR项目文件路径
ADA_PROJECT_ROOT当前目录项目根目录
ADA_MCP_LOG_LEVELINFO记录详细信息(调试、信息、警告、错误)
ADA_MCP_TIMEOUT30请求超时(秒)
ADA_MCP_CACHE_TTL5缓存生存时间(秒)

日志记录

ADA_MCP_LOG_LEVEL 调整措辞:

# Debug mode (verbose)
export ADA_MCP_LOG_LEVEL=DEBUG

# Production mode (errors only)
export ADA_MCP_LOG_LEVEL=ERROR

______________________________________________________________________

建筑

┌─────────────────┐     MCP/JSON-RPC      ┌─────────────────┐
│   AI Agent      │ ◄──────────────────► │  Ada MCP Server │
│ (Copilot, etc.) │     (NDJSON/stdio)    │    (Python)     │
└─────────────────┘                       └────────┬────────┘
                                                   │
                                                   │ LSP/JSON-RPC
                                                   │ (stdio)
                                                   ▼
                                          ┌─────────────────┐
                                          │ Ada Language    │
                                          │ Server (ALS)    │
                                          └────────┬────────┘
                                                   │
                                                   ▼
                                          ┌─────────────────┐
                                          │ Ada Project     │
                                          │ (.gpr, .ads,    │
                                          │  .adb files)    │
                                          └─────────────────┘

可靠性特征

  • 自动重启:如果ALS崩溃,服务器会自动以指数回退方式重新启动它
  • 健康监测:后台任务监控ALS过程健康状况
  • 响应缓存:基于TTL的缓存减少了冗余的ALS查询

______________________________________________________________________

发展

# Clone repository
git clone https://github.com/ada-mcp/ada-mcp-server
cd ada-mcp-server

# Create virtual environment
python -m venv .venv
source .venv/bin/activate

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Run linter
ruff check src/

# Format code
ruff format src/

# Type checking
mypy src/

项目结构

ada-mcp-server/
├── src/ada_mcp/
│   ├── __main__.py      # Entry point
│   ├── server.py        # MCP server setup
│   ├── als/             # ALS communication
│   │   ├── client.py    # LSP client
│   │   ├── process.py   # ALS lifecycle & health monitoring
│   │   └── types.py     # LSP type definitions
│   ├── tools/           # MCP tool implementations
│   │   ├── navigation.py
│   │   ├── symbols.py
│   │   ├── diagnostics.py
│   │   ├── project.py
│   │   ├── refactoring.py
│   │   └── build.py
│   └── utils/           # Utilities
│       ├── cache.py     # Response caching
│       ├── position.py  # Line/column conversions
│       └── uri.py       # File URI handling
├── tests/               # Unit tests
└── scripts/             # Integration test scripts

测试

单元测试(CI)

模拟ALS的单元测试在GitHub Actions中运行:

pytest tests/ -v

集成测试(仅限本地)

集成测试需要实际的Ada语言服务器:

# Set ALS path
export ALS_PATH=/path/to/ada_language_server

# Run integration tests
python scripts/test_phase1_integration.py

______________________________________________________________________

故障排除

未找到ALS

Error: FileNotFoundError: ada_language_server

解决方案:设置 ALS_PATH 到ALS可执行文件的完整路径:

export ALS_PATH=/home/user/.local/bin/ada_language_server

未找到GPR文件

Warning: No GPR project file found. Disabling ALS indexing...

解决方案:设置 ADA_PROJECT_FILE 或者确保你的项目有 .gpr 文件:

export ADA_PROJECT_FILE=my_project.gpr

ALS反复崩溃

服务器将尝试以指数回退方式重新启动ALS(最多5次尝试)。检查:

  1. ALS版本兼容性(使用ALS 24.x或更新版本)
  2. GPR文件有效性
  3. 可用系统内存

反应缓慢

尝试减少缓存TTL以获得更新鲜的结果:

export ADA_MCP_CACHE_TTL=2

或者增加它以在稳定的代码库上获得更好的性能:

export ADA_MCP_CACHE_TTL=30

调试记录

启用调试日志以进行故障排除:

export ADA_MCP_LOG_LEVEL=DEBUG
ada-mcp 2>&1 | tee mcp-debug.log

______________________________________________________________________

贡献

欢迎投稿!拜托:

  1. 分叉存储库
  2. 创建要素分支
  3. 添加新功能的测试
  4. 确保所有测试通过(pytest)
  5. 提交拉取请求

许可证

MIT许可证-请参阅 许可证 了解详情。

相关项目

目录标签

目录标签

代码导航PythonVS Code开发工具语义分析本地部署Ada语言支持AI编程辅助

支持客户端

VS Code

接入字段

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

stdio

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

none

运行时(runtime,运行环境)

Python

工具数量(toolCount,工具数)

20

资源数量(resourceCount,资源数)

0

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

0

权限和风险

stdionone部署方式未说明

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

安装前确认

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

来源信息

继续浏览同类 MCP