Skip to content

Comments

Add environment variable configuration for MCP agent sessions#20

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/support-mcp-env-configuration
Draft

Add environment variable configuration for MCP agent sessions#20
Copilot wants to merge 4 commits intomainfrom
copilot/support-mcp-env-configuration

Conversation

Copy link
Contributor

Copilot AI commented Feb 18, 2026

Enables configuring environment variables for Copilot agents to support MCP tools requiring API keys, database URLs, and service endpoints. Leverages SDK 0.1.25's envValueMode: direct fix for proper env var propagation to MCP servers.

Implementation

  • SDK: Updated to @github/copilot-sdk@^0.1.25
  • Data model: Added Task.env (task-specific) and Settings.globalEnv (applies to all tasks)
  • Execution: Executor merges global + task env vars (task overrides) and sets in process.env before session creation
  • UI: TaskEditor field for editing env vars as KEY=value pairs; sensitive values (matching key|token|password|secret|auth|credential) masked as ***
  • Persistence: Plans containing env vars include _warning field about secret management
  • Validation: isSensitiveEnvKey() utility warns on suspicious keys during save

Usage

// .planeteer/settings.json
{
  "model": "claude-sonnet-4",
  "globalEnv": {
    "DATABASE_URL": "postgresql://localhost:5432/dev",
    "LOG_LEVEL": "info"
  }
}
// Task in plan file
{
  "id": "deploy-api",
  "title": "Deploy API",
  "env": {
    "API_KEY": "sk-prod-xyz",
    "REGION": "us-west-2"
  }
}

Task-specific env vars override globals with the same key. All merged vars are available to MCP servers via inherited process.env.

Original prompt

This section details on the original issue you should resolve

<issue_title>[enhancement] Support MCP environment variable configuration for agent sessions</issue_title>
<issue_description>## Background

The Copilot SDK v0.1.25 (Feb 18, 2026) includes important MCP (Model Context Protocol) environment variable improvements in PR colindembovsky/planeteer#484 authored by Steve Sanderson. The change fixes MCP environment variable handling by sending envValueMode: direct across all SDK implementations.

Key changes:

  • Updated @github/copilot to 0.0.411-1 with MCP env var fixes
  • CLI now supports direct environment variable mode for MCP servers
  • Ensures environment variables are properly passed to MCP tools

Related SDK commits:

Proposal

Add support for configuring MCP environment variables when creating Copilot agent sessions in Planeteer. This would allow users to:

  1. Specify environment variables needed by MCP tools (e.g., API keys, database URLs, service endpoints) in the plan definition or a configuration file
  2. Pass these environment variables to agent sessions via SessionConfig when executing tasks
  3. Support both global environment variables (apply to all tasks) and task-specific environment variables

Implementation approach:

  • Extend the Task model to include optional env field (key-value pairs)
  • Update src/services/executor.ts to merge global and task-specific env vars when creating sessions
  • Add UI in the refine screen for users to configure environment variables for tasks
  • Store environment variables in the persisted plan JSON (with warnings about sensitive data)

Benefit

This enhancement enables Planeteer to work with Copilot agents that rely on MCP tools requiring configuration:

  • MCP tool support: Many MCP servers need API keys, database credentials, or service endpoints passed as environment variables
  • Task customization: Different tasks can use different configurations (e.g., dev vs. prod database URLs)
  • Professional workflows: Supports real-world scenarios where agents need access to external services (databases, APIs, cloud providers)
  • SDK alignment: Takes advantage of the recent SDK fixes ensuring environment variables are properly propagated

Acceptance Criteria

  • Add env?: Record&lt;string, string&gt; field to the Task interface in src/models/plan.ts
  • Update src/services/executor.ts to accept environment variables in session configuration when creating agent sessions
  • Display environment variables in the refine screen task editor (with masking for sensitive values)
  • Save environment variables to plan JSON with a warning comment about not committing secrets
  • Add a settings file (.planeteer/settings.json) for global environment variables that apply to all plans
  • Update SDK dependency to ^0.1.25 in package.json to ensure MCP env var fixes are available
  • Document environment variable configuration in README with examples
  • Add validation to warn users when environment variables look like secrets (contain "key", "token", "password", etc.)

AI generated by Weekly Enhancement Suggestions

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits February 18, 2026 08:18
Co-authored-by: colindembovsky <1932561+colindembovsky@users.noreply.github.com>
Co-authored-by: colindembovsky <1932561+colindembovsky@users.noreply.github.com>
Co-authored-by: colindembovsky <1932561+colindembovsky@users.noreply.github.com>
Copilot AI changed the title [WIP] Enhance MCP environment variable configuration for agent sessions Add environment variable configuration for MCP agent sessions Feb 18, 2026
Copilot AI requested a review from colindembovsky February 18, 2026 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[enhancement] Support MCP environment variable configuration for agent sessions

2 participants