Skip to content

Add a stable environment variable for local MCP servers to detect Copilot CLI as their host #2107

@tlmii

Description

@tlmii

Describe the feature or problem you'd like to solve

MCP servers launched by Copilot CLI currently have no reliable, intentional way to detect they're running under the CLI - COPILOT_CLI_BINARY_VERSION only works in SEA mode and COPILOT_RUN_APP is an internal loader implementation detail. Adding a deliberate env var like COPILOT_CLI=true in setupProcess.ts would provide a stable, documented signal that works across both SEA and source modes, enabling MCP servers to adapt behavior or log appropriate details based on their host without requiring special arguments in the server configuration. This also layers cleanly with existing env vars like MSFT_AGENCY to let consumers infer the full orchestration stack.

Proposed solution

Defining the name of the env var is probably one of the hardest parts. Assuming for the moment that we pick something like COPILOT_CLI, then one option for implementation would be to set process.env.COPILOT_CLI = "true" in setupProcess.ts, which runs early in the CLI entry point across all modes (interactive, server, ACP) and in both SEA and source builds. Since this env var isn't in the filter list, it naturally propagates to MCP server child processes via the existing environment inheritance.

Example prompts or workflows

N/A

Additional context

  1. The MCP initialize handshake already sends clientInfo.name: "github-copilot-developer", but that value is shared with CCA and other hosts, so it only tells you "some Copilot client" — not specifically the CLI.
  2. The DO NOT CHANGE THE CLIENT NAME comments in the codebase confirm MCP servers already rely on client identification — this request aligns with that existing pattern but fills the CLI-specific gap.
  3. Telemetry is a specific use-case here, but there are likely others.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions