Skip to content

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

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.

Activity

  1. added theissue type on Mar 17, 2026
  2. added
    area:configurationConfig files, instruction files, settings, and environment variables
    on Apr 6, 2026
  3. added
    area:mcpMCP server configuration, discovery, connectivity, OAuth, policy, and registry
    on Apr 6, 2026
  4. lonitra commented on Apr 7, 2026

    @lonitra

    Additionally, current environment variables that could be used to detect CCA as their host are not propagated to the MCP server due to existing environment inheritance. For the same reasons, an env var for detecting CCA that is propagated to MCP servers would be helpful as well.

  5. patniko commented on Oct 26, 2026

    @patniko
    Collaborator

    Thanks for the report. We've shipped fixes in this area since this was filed (most recently in Copilot CLI v1.0.28), and we believe this may now be resolved. Could you retest on the latest release (Copilot CLI v1.0.103) and let us know whether you still see it? If we don't hear back in a couple of weeks, we may close this issue — you can always reopen it.

    Triaged as part of a Copilot SDK backlog review, with help from GitHub Copilot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:configurationConfig files, instruction files, settings, and environment variablesarea:mcpMCP server configuration, discovery, connectivity, OAuth, policy, and registrymore-info-needed

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions