github / github/copilot-cli

`resolveDiscoveredConfig` does not read workspace `.mcp.json` — `includeWorkspaceSources` never set

Ouverte Adaptée aux débutants
#3,126 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
area:configuration area:mcp
Langage dominant
Shell
Étoiles
11.2k
Forks
1.9k
Merge moyen
14 h 16 min
PR mergées (30 j)
6

Description

## Summary

When the SDK creates a session with `enableConfigDiscovery: true` and a `workingDirectory`, the CLI's `resolveDiscoveredConfig()` calls the internal MCP config loader (`jv()`) **without** passing `includeWorkspaceSources: true`. That parameter defaults to `false`, so the workspace `.mcp.json` is never read — even though the intent of `enableConfigDiscovery` is clearly to discover it.

## Version

`@github/copilot` v1.0.41-0 (commit `3f18c2c`)

## Steps to reproduce

1. Place a valid `.mcp.json` in a working directory:
```json
{
"mcpServers": {
"time": {
"command": "uvx",
"args": ["mcp-server-time"]
}
}
}
```
2. Create a session via the SDK with `enableConfigDiscovery: true` and `workingDirectory` pointing to that directory.
3. Observe that no MCP servers from `.mcp.json` are discovered.

## Expected behaviour

The MCP servers defined in the workspace `.mcp.json` should be discovered and loaded into the session.

## Actual behaviour

The CLI logs:
```
Loaded MCP config from installed plugins: 0 server(s):
No MCP config loaded from ODR (ODR unavailable or returned no usable servers)
```

No workspace `.mcp.json` is read. The flag triggers config resolution, but the resolution skips the workspace source.

## Root cause

In `resolveDiscoveredConfig()`, the call to `jv()` omits `includeWorkspaceSources`:

```js
async resolveDiscoveredConfig(e) {
if (!e.enableConfigDiscovery) return {};
let r = e.workingDirectory || process.cwd();
// ...
let c = await jv({
cwd: r,
repoRoot: l,
settings: this.options.settings,
installedPlugins: s
// ← missing: includeWorkspaceSources: true
});
}
```

Inside `jv()`, the parameter defaults to `false`. When false, the function skips the code path that reads `.mcp.json` from the working directory:

```js
async function jv(t = {}) {
let { includeWorkspaceSources: s = false } = t;
// ...
if (!s) d = { ...c }; // ← only copies global config
else {
// reads .mcp.json from cwd/repoRoot — this path is never taken
}
}
```

## Suggested fix

Pass `includeWorkspaceSources: true` in the `jv()` call within `resolveDiscoveredConfig()`:

```js
let c = await jv({
cwd: r,
repoRoot: l,
settings: this.options.settings,
installedPlugins: s,
includeWorkspaceSources: true // ← add this
});
```

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Start at resolveDiscoveredConfig() and trace its call to jv(), using the provided workingDirectory and workspace .mcp.json reproduction. Verify that config discovery includes workspace sources, then rerun the SDK session scenario and confirm the time MCP server is loaded from .mcp.json.

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

Évaluation

Stack technique
javascript
Domaine
cli
Type d'issue
Bug
Difficulté
2/5
Temps estimé
1-3 heures
Activité
Calme
Clarté
Clairement spécifiée
Accessibilité débutants
72/100

Recevez les nouvelles issues par e-mail

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