github / github/copilot-cli

Shared MCP Token Cache Across CLI Sessions

Ouverte
#2,780 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
area:authentication area:mcp
Langage dominant
Shell
Étoiles
11.2k
Forks
1.9k
Merge moyen
14 h 16 min
PR mergées (30 j)
6

Description

### Describe the feature or problem you'd like to solve

_No response_

### Proposed solution

# Feature Request: Shared MCP Token Cache Across CLI Sessions

## Problem

Each Copilot CLI terminal/session maintains its own independent MCP connections and token cache. When a token expires:

1. Running `/mcp reload` in **Terminal A** does NOT fix **Terminal B**
2. Each terminal must be individually refreshed
3. Users working with multiple CLI sessions (common for parallel workflows) must reload each one

This is inconsistent with how other developer tools work — `az login`, `gh auth login`, and `docker login` all share credentials across terminal sessions on the same machine.

## Proposed Solution

**Shared token cache**: MCP server OAuth tokens should be stored in a machine-local cache (e.g., OS keychain or a file-based token cache) that all CLI sessions on the same machine can read from.

### Implementation suggestions

- Store MCP OAuth tokens in a shared location:
- **Windows**: Windows Credential Manager or `~/.copilot/mcp-token-cache/`
- **macOS**: Keychain Access
- **Linux**: `libsecret` / `gnome-keyring` or file-based fallback
- When a CLI session needs an MCP token, check the shared cache first
- When any session refreshes a token (via `/mcp reload` or auto-refresh), update the shared cache
- Include a file lock or atomic write mechanism to prevent race conditions
- Optional: a `--no-shared-cache` flag for users who want isolated sessions

### Interaction with auto-refresh (Feature Request #1)

If auto-refresh is implemented, the shared cache becomes even more valuable:

- One session refreshes the token → all sessions benefit immediately
- No "thundering herd" of multiple sessions trying to refresh simultaneously

## Environment

- Copilot CLI on Windows (PowerShell)
- Multiple terminal sessions on the same machine
- MCP servers using Entra ID (Azure AD) OAuth

## Current Workaround

When tokens expire, users must run `/mcp reload` in **every open CLI session** individually. There is no way to refresh once and have all sessions pick up the new token.

### Example prompts or workflows

_No response_

### Additional context

_No response_

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

L’issue ne nomme aucun fichier ni test. Commencez par suivre la gestion des tokens MCP et le point d’entrée `/mcp reload` ; déterminez comment les sessions stockent et actualisent actuellement les tokens. Le travail est considéré comme terminé lorsque les sessions partagent les tokens actualisés de manière sûre sous Windows, macOS et Linux, que les conditions de concurrence sont empêchées et que l’option d’isolation demandée est prise en compte.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Domaine
authentication, cli, security
Type d'issue
Fonctionnalité
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
Calme
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.