依赖流数据服务器及命令行工具

一个提供对Maestro/BAR(构建资产注册表)数据缓存访问的MCP服务器和独立CLI工具,包含20种查询订阅、构建、通道和健康状态的工具,适用于.NET构建基础设施的依赖流管理。

  • by lewing
  • C#
  • 本地部署
  • 更新于
在 GitHub 查看 lewing/maestro.mcp

使用说明

maestro.mcp——用于maestro/BAR依赖流数据的mcp服务器和CLI

MCP服务器 以及独立的CLI工具 提供缓存访问 大师/酒吧 的(构建资产注册表)数据。NET构建基础架构。公开了20个工具,用于查询订阅、构建、通道和运行状况,以及通过模型上下文协议触发订阅更新和管理缓存。还可以作为独立的CLI使用(mstro)对于人类来说——相同的缓存数据,相同的身份验证,不需要人工智能。

内置于 小队 — 与小队见面.

为什么是微软?

大师/BAR API的力量。NET的依赖流基础架构,但直接使用它是痛苦的:

  • 订阅ID是GUID --您需要按仓库/通道查询,而不是记住UUID
  • 构建过时需要多步骤查找 --比较上次应用的构建与最新可用的构建,然后通过GitHub计算提交距离
  • 无跨进程缓存 --每一个 darc 调用刷新API,即使是每隔5到15分钟更改一次的数据
  • 代码流状态不透明 -回流PR、跟踪PR和订阅历史记录分散在多个API端点上

mstro 将所有这些打包在一个工具中 智能缓存 (SQLite,在所有MCP客户端之间共享), 自动身份验证 (重复使用 darc 参赛者ID凭证),以及 富集产出 (承诺距离、健康评分、新鲜度检查)。无论你是一个正在调查过时订阅的人工智能代理,还是一个正在对构建流程进行人工分类的人工智能代理人,你都会得到同样快速、准确的答案。

安装

使用dnx运行(无需安装)

dnx (.NET 10中的新功能)自动下载并运行NuGet工具包——无需安装步骤:

dnx lewing.maestro.mcp

这是MCP服务器配置的推荐方法(见下文)。MCP stdio模式为默认模式。

作为全局工具安装

dotnet tool install -g lewing.maestro.mcp

通过以下方式进行repo本地安装 工具清单:

dotnet new tool-manifest   # if .config/dotnet-tools.json doesn't exist
dotnet tool install --local lewing.maestro.mcp

从本地版本安装

dotnet pack src/MaestroTool
dotnet tool install -g --add-source src/MaestroTool/nupkg lewing.maestro.mcp

安装后, mstro 全球可用。

从源代码构建

# Prerequisites: .NET 10 SDK
git clone https://github.com/lewing/maestro.mcp.git
cd maestro.mcp
dotnet build

NuGet进料要求: 这 Microsoft.DotNet.ProductConstructionService.Client 包已发布到 大唐能 Azure工件提要。包括 nuget.config 引用此提要。

快速入门-CLI

mstro 是面向人类的完整CLI。每个查询都使用与MCP服务器相同的缓存API层。

# List subscriptions for a repo
mstro subscriptions --source-repository https://github.com/dotnet/runtime

# Get a specific subscription by ID
mstro subscription <guid>

# Check subscription health for a target repo (includes commit distance)
mstro subscription-health https://github.com/dotnet/sdk --include-commit-details

# Get the latest build for a repo on a channel
mstro latest-build https://github.com/dotnet/runtime --channel-name ".NET 10.0.1xx SDK"

# Get a specific build by ID
mstro build 302353

# List all channels
mstro channels

# List default channel mappings
mstro default-channels --repository https://github.com/dotnet/runtime

# Check build freshness via aka.ms
mstro build-freshness ".NET 10.0.1xx SDK"

# List active codeflow (backflow) PRs
mstro codeflow-prs --channel-name ".NET 10 Engineering"

# Get tracked PR for a subscription
mstro tracked-pr <guid>

# Get backflow status for a VMR build
mstro backflow-status 302627

# View subscription update history
mstro subscription-history <guid>

# Get build dependency graph
mstro build-graph 302353

# Get dependency flow graph for a channel
mstro flow-graph 1234 --days 14

# Get codeflow status (forward/backflow) for a repository
mstro codeflow-statuses https://github.com/dotnet/dotnet --branch main

# Trigger a subscription update (requires auth)
mstro trigger-subscription <guid> 302353

# Trigger all daily subscriptions (requires auth)
mstro trigger-daily-update

# Cache management
mstro cache status
mstro cache clear

所有命令支持 --json 用于结构化输出和 --no-cache 绕过缓存。

交互式检测

mstro 自动检测其启动方式:

背景 行为
终端(无参数) 表演 --help 使用可用命令
MCP主机(标准输入管道) 自动启动MCP服务器模式
使用子命令 运行指定的CLI命令

这意味着现有的MCP配置("command": "mstro" 没有参数)继续工作不变-- mstro 检测管道stdin并进入MCP服务器模式。

MCP配置

将以下内容添加到MCP客户端配置中。这 --yes 标志确保 dnx 不提示确认:

{
  "servers": {
    "maestro": {
      "type": "stdio",
      "command": "dotnet",
      "args": ["dnx", "--yes", "lewing.maestro.mcp"]
    }
  }
}

如果您已安装 lewing.maestro.mcp 作为一个全局工具,您可以使用 "command": "mstro" 随着 "args": [] 而不是 dnx.

通过身份验证

{
  "servers": {
    "maestro": {
      "type": "stdio",
      "command": "dotnet",
      "args": ["dnx", "--yes", "lewing.maestro.mcp"],
      "env": {
        "MAESTRO_BAR_TOKEN": "your-token-here"
      }
    }
  }
}

HTTP服务器(备选)

dotnet run --project src/MaestroTool.Mcp

HTTP服务器侦听 http://localhost:5000 默认情况下。

配置文件位置

客户端 配置文件 顶级密钥
GitHub Copilot 命令行界面 ~/.copilot/mcp.json servers
VS代码/GitHub副本 .vscode/mcp.json servers
克劳德桌面 (macOS) ~/Library/Application Support/Claude/claude_desktop_config.json mcpServers
克劳德桌面 (Windows) %APPDATA%\Claude\claude_desktop_config.json mcpServers
克劳德代码/光标 .cursor/mcp.json mcpServers

认证

服务器实现了 三层认证级联:

  1. 显式PAT --设置 MAESTRO_BAR_TOKEN 环境变量
  2. 缓存入口ID --重用来自的凭据 darc authenticate (~/.darc/.auth-record-*)
  3. 匿名 --只读回退(可能受到速率限制)

推荐:运行 darc authenticate 一次(从 街机服务)缓存凭据,然后依靠自动Entra ID身份验证。

行动工具

服务器包括 行动工具 用于触发订阅更新。这些是非破坏性操作——它们会触发处理,但不会删除或修改订阅配置。

去重

操作工具包括内置的重复数据删除功能,冷却时间为2分钟。如果在冷却窗口内再次触发相同的操作,服务器将返回通知,而不是重新执行。这可以防止LLM重试或多个并发技能产生重复触发。

破坏性行动(未来)

未来的版本可能包括破坏性操作(删除订阅、删除默认频道等)。这些将是 默认情况下禁用 并要求明确的选择加入:

{
  "servers": {
    "maestro": {
      "type": "stdio",
      "command": "dotnet",
      "args": ["dnx", "--yes", "lewing.maestro.mcp"],
      "env": {
        "MAESTRO_ENABLE_DESTRUCTIVE_ACTIONS": "true"
      }
    }
  }
}

可用工具

服务器注册 21个MCP工具 用于查询和触发Maestro/BAR操作:

工具名称 描述 关键参数
maestro_subscriptions 列出所有订阅 sourceRepository, targetRepository, channelName, targetBranch (所有可选过滤器); noCache:绕过缓存
maestro_subscription 通过GUID ID获取订阅,并进行健康诊断 subscriptionId:UUID; noCache:绕过缓存
maestro_latest_build 获取存储库的最新版本,可选择按通道名称筛选 repository:仓库URL; channelName (可选); noCache:绕过缓存
maestro_build 通过BAR构建ID获取构建 buildId:构建ID; noCache:绕过缓存
maestro_builds 列表构建,可选择按存储库、通道、提交或构建号进行筛选 repository, channelName, commit, buildNumber, count (全部可选); noCache:绕过缓存
maestro_channels 列出所有频道 noCache:绕过缓存
maestro_channel 按ID或名称获取特定频道 channelId:通道ID(整数)或通道名称(字符串); noCache:绕过缓存
maestro_default_channels 获取存储库的默认通道 repository:源存储库URL; noCache:绕过缓存
maestro_subscription_health 检查目标存储库的订阅运行状况--检测过时的订阅并内联显示最新的触发结果(Updated/Failure/HasConflict/UserError/…) targetRepository:仓库URL; noCache, includeCommitDetails, validate, staleOnly, compact (可选胸部); channelFilter, sourceRepoFilter (可选字符串)
maestro_build_freshness 通过aka.ms重定向检查频道的构建新鲜度 channel:频道短名称(例如“10.0.1xx”); noCache:绕过缓存
maestro_trigger_subscription 触发订阅--提供 buildId 直接,或 sourceRepository + channelName 自动解决 subscriptionId:UUID; buildId (可选); sourceRepository, channelName (可选,用于自动解析); force (可选bool)
maestro_trigger_daily_update 触发所有每日更新订阅 无
maestro_codeflow_prs 列出由Maestro管理的活动代码流(跟踪)拉取请求 channelName (可选); noCache:绕过缓存
maestro_codeflow_pr 获取特定订阅的跟踪PR subscriptionId:UUID; noCache:绕过缓存
maestro_backflow_status 获取VMR构建的回流状态 vmrBuildId:构建ID; noCache:绕过缓存
maestro_subscription_history 获取订阅的更新历史记录--显示带时间戳的操作和错误 subscriptionId:UUID; noCache:绕过缓存
maestro_subscription_outcomes 列出PCS最近的订阅触发结果(已更新/NoUpdate/NotUpdataable/Failure/UserError/HasConflict/Rescheduled),每行一个结果,带有表情符号、构建ID、PR URL和消息 subscriptionId:UUID(可选); buildId, outcomeType, after, before, count (全部可选;ISO 8601用于日期,1-100用于计数); noCache:绕过缓存
maestro_build_graph 获取构建的完整依赖关系图 buildId:BAR构建ID; noCache:绕过缓存
maestro_flow_graph 获取通道的依赖关系流图 channelId:通道ID; days:回顾(默认3,最多30); includeArcade, includeBuildTimes, includeDisabledSubscriptions (可选胸部); noCache:绕过缓存
maestro_codeflow_statuses 获取存储库和分支的代码流状态(正向流和反向流) repositoryUrl:仓库URL(默认值:VMR); branch:分支名称(默认:main); noCache:绕过缓存
maestro_clear_cache 清除共享SQLite缓存 无

命名规范

工具遵循一致的命名模式:

maestro_{resource}               # get one by ID (e.g. maestro_build)
maestro_{resources}              # list (e.g. maestro_builds)
maestro_{resource}_{aspect}      # detail query (e.g. maestro_subscription_health)
maestro_{verb}_{resource}        # action (e.g. maestro_trigger_subscription)

缓存旁路

所有阅读工具都接受可选 noCache 布尔参数。当设置为 true,该请求的缓存条目在获取之前无效,从而保证新的API调用。在触发操作后或调查快速变化的状态时使用此选项。

这 maestro_clear_cache 该工具提供了一个完整的缓存重置功能,在执行批量操作或调试过时数据时非常有用。

代码流跟踪

这 maestro_codeflow_prs, maestro_codeflow_pr, maestro_backflow_status,以及 maestro_subscription_history 这些工具公开了VMR代码流工具使用的相同PCS PullRequest API(请参见 点网/点#4952).这些工具可以查看代码流PR、回流状态和订阅更新历史,而不需要直接访问VMR。

响应时间戳

所有读取工具响应都包括一个检索时间戳头,指示数据何时被提取,以及数据是否来自缓存或新的API调用:

_Retrieved: 2026-02-18 15:30:45Z (cached)_

数据富集

除了原始的Maestro/PCS API之外,此MCP服务器还提供了几个增值增强功能,以提高可见性和决策能力:

订阅健康评分 --将每个订阅的最后应用版本与其通道上的最新可用版本进行比较,计算确切的 BuildsBehind 计数。对于GitHub托管的源repos,GitHub Compare API计算精确的提交距离。对于Azure DevOps仓库,AzDo提交API提供了详细的提交历史记录,包括作者、消息和日期。

通过aka.ms建立新鲜感 --解析aka.ms到其最终blob存储目标的短链接,然后检查 Last-Modified HTTP标头,用于确定通道上次更新的时间,而无需下载工件。包括防止内部网络重定向的SSRF保护。

频道名称解析 --接受所有工具 channelName 执行自动不区分大小写的查找,将人类友好的名称(例如“.NET 10.0.1xx SDK”)解析为数字通道ID。呼叫者永远不需要手动查找ID。

回流状态聚合 --对于给定的VMR构建,聚合每个分支的回流状态,包括所有目标存储库的提交距离和订阅详细信息。

状态振荡检测 --通过分析交替应用更新的更新历史记录来检测卡住的订阅↔ 合并PullRequest状态周期(每 街机服务#6090).在运行状况检查期间自动运行过期订阅。

源清单跟踪 --对于以dotnet/deet为目标的订阅,如下所示 src/source-manifest.json 从VMR中确定VMR实际消耗了什么提交,并与订阅的最后一个应用版本进行交叉引用。

追踪PR诊断 --对于具有跟踪代码流PR的过时订阅,检查GitHub PR状态(已合并但未清除、已关闭但未清理、被CI阻止或处于活动状态),以解释订阅卡住的原因。

流图可视化 --使用构建时间、最长路径关键路径指示符和通道路由信息格式化依赖关系流图,以进行端到端的依赖关系分析。

人类可读格式 -所有工具响应都使用表情符号状态指示器(✅ 电流,⚠️ 陈旧,⏳ 悬而未决的,🔒 需要授权)、结构化表格和用于快速扫描的视觉标记。提交详细信息包括SHA、消息、作者和日期(如果可用)。

建筑

该项目分为三层:

src/
├── MaestroTool/              # CLI tool + stdio MCP server (dotnet tool)
│   └── Program.cs
├── MaestroTool.Core/         # Shared library — Maestro API logic + MCP tool definitions
│   ├── MaestroMcpTools.cs    # MCP tool definitions ([McpServerToolType])
│   ├── MaestroService.cs     # Cached business logic
│   ├── CacheService.cs       # SQLite-backed cross-process cache
│   ├── IMaestroApiClient.cs  # API abstraction
│   └── MaestroApiClient.cs   # PCS client wrapper with auth cascade
├── MaestroTool.Mcp/          # MCP HTTP server (ASP.NET Core)
│   └── Program.cs
└── MaestroTool.Tests/        # Unit tests (167 tests)
  • 大师。 --双模入口点:用于人类的独立CLI和用于AI代理的stdio MCP服务器。包装为 .net工具.默认入口点 dnx / dotnet tool 使用。
  • MaestroTool。模型上下文协议(Model Context Protocol) --用于远程/共享部署的HTTP MCP服务器。
  • MaestroTool。核心 -所有业务逻辑、缓存、API客户端和MCP工具定义。由两个主机共享。

跨进程缓存架构

多个 mstro 实例(例如,同时运行的VS Code、Copilot CLI和Claude Desktop)共享一个SQLite缓存 ~/.mstro/cache.db。这消除了客户端之间冗余的PCS API调用。

graph TB
    subgraph "MCP Clients"
        VSCode["VS Code<br/>Copilot Extension"]
        CLI["GitHub<br/>Copilot CLI"]
        Claude["Claude<br/>Desktop"]
    end

    subgraph "mstro Instances (separate processes)"
        M1["mstro<br/>MaestroMcpTools<br/>↓<br/>MaestroService"]
        M2["mstro<br/>MaestroMcpTools<br/>↓<br/>MaestroService"]
        M3["mstro<br/>MaestroMcpTools<br/>↓<br/>MaestroService"]
    end

    subgraph "Shared State"
        DB[("~/.mstro/cache.db<br/>SQLite (WAL mode)<br/>─────────────<br/>cache table (data)<br/>actions table (dedup)")]
    end

    subgraph "External API"
        PCS["Maestro / PCS API<br/>maestro.dot.net"]
    end

    VSCode -- "stdio" --> M1
    CLI -- "stdio" --> M2
    Claude -- "stdio" --> M3

    M1 -- "read/write" --> DB
    M2 -- "read/write" --> DB
    M3 -- "read/write" --> DB

    M1 -. "on cache miss" .-> PCS
    M2 -. "on cache miss" .-> PCS
    M3 -. "on cache miss" .-> PCS

    style DB fill:#f9f,stroke:#333,stroke-width:2px
    style PCS fill:#bbf,stroke:#333

关键设计决策:

  • WAL(预写日志) 模式允许跨进程并发读取而不会阻塞
  • 单独的表格 用于数据缓存和操作数据消除-- maestro_clear_cache 只清除数据,触发冷却存活
  • 按键TTL 过期,定期清理过期行
  • 10000入场上限 达到容量时自动驱逐

缓存TTL

这 CacheService 用途 带WAL模式的SQLite 用于跨进程缓存共享。全部 mstro 实例共享 ~/.mstro/cache.db:

数据类型 TTL 原因
订阅(列表) 5分钟 订阅更改不频繁
最新版本(按频道/仓库) 5分钟 版本经常发布
频道(列表) 15分钟 频道很少添加/删除
按ID构建 30分钟 发布后构建是不可变的
建立新鲜度(衍生) 10分钟 计算;缓存以避免重复的API调用

TTL可在中配置 CacheService 如果需要更严格的新鲜度。过期的条目会定期自动清理。

测试

运行测试套件:

dotnet test

测试套件包括:

  • 167个单元测试 覆盖 CacheService, MaestroService安全强化和工具行为。
  • 框架:xUnit+N代替嘲讽。
  • 覆盖:缓存命中/未命中、TTL过期、空处理、错误场景、提交距离、SSRF验证、损坏恢复。

测试位于 src/MaestroTool.Tests/.

许可证

麻省理工学院


贡献

如有疑问或问题,请在存储库中打开问题。在修改身份验证逻辑或添加新工具时,请确保所有测试都通过,并相应地更新此README。