Skip to content

Commit a690c4b

Browse files
stephentoubCopilot
andcommitted
Expose enableConfigDiscovery in all SDK languages
Add enableConfigDiscovery option to session config types in Node.js, Python, Go, and .NET SDKs. When set to true, the runtime automatically discovers MCP server configurations (.mcp.json, .vscode/mcp.json) and skill directories from the working directory, merging them with any explicitly provided values (explicit takes precedence on name collision). This surfaces a capability already implemented in copilot-agent-runtime's resolveDiscoveredConfig() for SDK consumers. Changes per SDK: - Node.js: SessionConfig + ResumeSessionConfig pick + client passthrough - Python: create_session/resume_session params + payload serialization - Go: config structs + wire request structs + client passthrough - .NET: config classes + clone constructors + wire records + client passthrough Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent e0a9028 commit a690c4b

File tree

7 files changed

+92
-0
lines changed

7 files changed

+92
-0
lines changed

dotnet/src/Client.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ public async Task<CopilotSession> CreateSessionAsync(SessionConfig config, Cance
502502
config.CustomAgents,
503503
config.Agent,
504504
config.ConfigDir,
505+
config.EnableConfigDiscovery,
505506
config.SkillDirectories,
506507
config.DisabledSkills,
507508
config.InfiniteSessions,
@@ -618,6 +619,7 @@ public async Task<CopilotSession> ResumeSessionAsync(string sessionId, ResumeSes
618619
hasHooks ? true : null,
619620
config.WorkingDirectory,
620621
config.ConfigDir,
622+
config.EnableConfigDiscovery,
621623
config.DisableResume is true ? true : null,
622624
config.Streaming is true ? true : null,
623625
config.McpServers,
@@ -1640,6 +1642,7 @@ internal record CreateSessionRequest(
16401642
List<CustomAgentConfig>? CustomAgents,
16411643
string? Agent,
16421644
string? ConfigDir,
1645+
bool? EnableConfigDiscovery,
16431646
List<string>? SkillDirectories,
16441647
List<string>? DisabledSkills,
16451648
InfiniteSessionConfig? InfiniteSessions,
@@ -1686,6 +1689,7 @@ internal record ResumeSessionRequest(
16861689
bool? Hooks,
16871690
string? WorkingDirectory,
16881691
string? ConfigDir,
1692+
bool? EnableConfigDiscovery,
16891693
bool? DisableResume,
16901694
bool? Streaming,
16911695
Dictionary<string, object>? McpServers,

dotnet/src/Types.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,6 +1603,7 @@ protected SessionConfig(SessionConfig? other)
16031603
CustomAgents = other.CustomAgents is not null ? [.. other.CustomAgents] : null;
16041604
Agent = other.Agent;
16051605
DisabledSkills = other.DisabledSkills is not null ? [.. other.DisabledSkills] : null;
1606+
EnableConfigDiscovery = other.EnableConfigDiscovery;
16061607
ExcludedTools = other.ExcludedTools is not null ? [.. other.ExcludedTools] : null;
16071608
Hooks = other.Hooks;
16081609
InfiniteSessions = other.InfiniteSessions;
@@ -1660,6 +1661,19 @@ protected SessionConfig(SessionConfig? other)
16601661
/// </summary>
16611662
public string? ConfigDir { get; set; }
16621663

1664+
/// <summary>
1665+
/// When <see langword="true"/>, automatically discovers MCP server configurations
1666+
/// (e.g. <c>.mcp.json</c>, <c>.vscode/mcp.json</c>) and skill directories from
1667+
/// the working directory and merges them with any explicitly provided
1668+
/// <see cref="McpServers"/> and <see cref="SkillDirectories"/>, with explicit
1669+
/// values taking precedence on name collision.
1670+
/// <para>
1671+
/// Custom instruction files (<c>.github/copilot-instructions.md</c>, <c>AGENTS.md</c>, etc.)
1672+
/// are always loaded from the working directory regardless of this setting.
1673+
/// </para>
1674+
/// </summary>
1675+
public bool? EnableConfigDiscovery { get; set; }
1676+
16631677
/// <summary>
16641678
/// Custom tool functions available to the language model during the session.
16651679
/// </summary>
@@ -1817,6 +1831,7 @@ protected ResumeSessionConfig(ResumeSessionConfig? other)
18171831
Agent = other.Agent;
18181832
DisabledSkills = other.DisabledSkills is not null ? [.. other.DisabledSkills] : null;
18191833
DisableResume = other.DisableResume;
1834+
EnableConfigDiscovery = other.EnableConfigDiscovery;
18201835
ExcludedTools = other.ExcludedTools is not null ? [.. other.ExcludedTools] : null;
18211836
Hooks = other.Hooks;
18221837
InfiniteSessions = other.InfiniteSessions;
@@ -1929,6 +1944,19 @@ protected ResumeSessionConfig(ResumeSessionConfig? other)
19291944
/// </summary>
19301945
public string? ConfigDir { get; set; }
19311946

1947+
/// <summary>
1948+
/// When <see langword="true"/>, automatically discovers MCP server configurations
1949+
/// (e.g. <c>.mcp.json</c>, <c>.vscode/mcp.json</c>) and skill directories from
1950+
/// the working directory and merges them with any explicitly provided
1951+
/// <see cref="McpServers"/> and <see cref="SkillDirectories"/>, with explicit
1952+
/// values taking precedence on name collision.
1953+
/// <para>
1954+
/// Custom instruction files (<c>.github/copilot-instructions.md</c>, <c>AGENTS.md</c>, etc.)
1955+
/// are always loaded from the working directory regardless of this setting.
1956+
/// </para>
1957+
/// </summary>
1958+
public bool? EnableConfigDiscovery { get; set; }
1959+
19321960
/// <summary>
19331961
/// When true, the session.resume event is not emitted.
19341962
/// Default: false (resume event is emitted).

go/client.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,9 @@ func (c *Client) CreateSession(ctx context.Context, config *SessionConfig) (*Ses
578578
req.ClientName = config.ClientName
579579
req.ReasoningEffort = config.ReasoningEffort
580580
req.ConfigDir = config.ConfigDir
581+
if config.EnableConfigDiscovery {
582+
req.EnableConfigDiscovery = Bool(true)
583+
}
581584
req.Tools = config.Tools
582585
wireSystemMessage, transformCallbacks := extractTransformCallbacks(config.SystemMessage)
583586
req.SystemMessage = wireSystemMessage
@@ -754,6 +757,9 @@ func (c *Client) ResumeSessionWithOptions(ctx context.Context, sessionID string,
754757
}
755758
req.WorkingDirectory = config.WorkingDirectory
756759
req.ConfigDir = config.ConfigDir
760+
if config.EnableConfigDiscovery {
761+
req.EnableConfigDiscovery = Bool(true)
762+
}
757763
if config.DisableResume {
758764
req.DisableResume = Bool(true)
759765
}

go/types.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,13 @@ type SessionConfig struct {
465465
// ConfigDir overrides the default configuration directory location.
466466
// When specified, the session will use this directory for storing config and state.
467467
ConfigDir string
468+
// EnableConfigDiscovery, when true, automatically discovers MCP server configurations
469+
// (e.g. .mcp.json, .vscode/mcp.json) and skill directories from the working directory
470+
// and merges them with any explicitly provided MCPServers and SkillDirectories, with
471+
// explicit values taking precedence on name collision.
472+
// Custom instruction files (.github/copilot-instructions.md, AGENTS.md, etc.) are
473+
// always loaded from the working directory regardless of this setting.
474+
EnableConfigDiscovery bool
468475
// Tools exposes caller-implemented tools to the CLI
469476
Tools []Tool
470477
// SystemMessage configures system message customization
@@ -692,6 +699,13 @@ type ResumeSessionConfig struct {
692699
WorkingDirectory string
693700
// ConfigDir overrides the default configuration directory location.
694701
ConfigDir string
702+
// EnableConfigDiscovery, when true, automatically discovers MCP server configurations
703+
// (e.g. .mcp.json, .vscode/mcp.json) and skill directories from the working directory
704+
// and merges them with any explicitly provided MCPServers and SkillDirectories, with
705+
// explicit values taking precedence on name collision.
706+
// Custom instruction files (.github/copilot-instructions.md, AGENTS.md, etc.) are
707+
// always loaded from the working directory regardless of this setting.
708+
EnableConfigDiscovery bool
695709
// Streaming enables streaming of assistant message and reasoning chunks.
696710
// When true, assistant.message_delta and assistant.reasoning_delta events
697711
// with deltaContent are sent as the response is generated.
@@ -909,6 +923,7 @@ type createSessionRequest struct {
909923
CustomAgents []CustomAgentConfig `json:"customAgents,omitempty"`
910924
Agent string `json:"agent,omitempty"`
911925
ConfigDir string `json:"configDir,omitempty"`
926+
EnableConfigDiscovery *bool `json:"enableConfigDiscovery,omitempty"`
912927
SkillDirectories []string `json:"skillDirectories,omitempty"`
913928
DisabledSkills []string `json:"disabledSkills,omitempty"`
914929
InfiniteSessions *InfiniteSessionConfig `json:"infiniteSessions,omitempty"`
@@ -948,6 +963,7 @@ type resumeSessionRequest struct {
948963
Hooks *bool `json:"hooks,omitempty"`
949964
WorkingDirectory string `json:"workingDirectory,omitempty"`
950965
ConfigDir string `json:"configDir,omitempty"`
966+
EnableConfigDiscovery *bool `json:"enableConfigDiscovery,omitempty"`
951967
DisableResume *bool `json:"disableResume,omitempty"`
952968
Streaming *bool `json:"streaming,omitempty"`
953969
MCPServers map[string]MCPServerConfig `json:"mcpServers,omitempty"`

nodejs/src/client.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,7 @@ export class CopilotClient {
742742
customAgents: config.customAgents,
743743
agent: config.agent,
744744
configDir: config.configDir,
745+
enableConfigDiscovery: config.enableConfigDiscovery,
745746
skillDirectories: config.skillDirectories,
746747
disabledSkills: config.disabledSkills,
747748
infiniteSessions: config.infiniteSessions,
@@ -873,6 +874,7 @@ export class CopilotClient {
873874
hooks: !!(config.hooks && Object.values(config.hooks).some(Boolean)),
874875
workingDirectory: config.workingDirectory,
875876
configDir: config.configDir,
877+
enableConfigDiscovery: config.enableConfigDiscovery,
876878
streaming: config.streaming,
877879
mcpServers: config.mcpServers,
878880
envValueMode: "direct",

nodejs/src/types.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,19 @@ export interface SessionConfig {
10741074
*/
10751075
configDir?: string;
10761076

1077+
/**
1078+
* When true, automatically discovers MCP server configurations (e.g. `.mcp.json`,
1079+
* `.vscode/mcp.json`) and skill directories from the working directory and merges
1080+
* them with any explicitly provided `mcpServers` and `skillDirectories`, with
1081+
* explicit values taking precedence on name collision.
1082+
*
1083+
* Note: custom instruction files (`.github/copilot-instructions.md`, `AGENTS.md`, etc.)
1084+
* are always loaded from the working directory regardless of this setting.
1085+
*
1086+
* @default false
1087+
*/
1088+
enableConfigDiscovery?: boolean;
1089+
10771090
/**
10781091
* Tools exposed to the CLI server
10791092
*/
@@ -1226,6 +1239,7 @@ export type ResumeSessionConfig = Pick<
12261239
| "hooks"
12271240
| "workingDirectory"
12281241
| "configDir"
1242+
| "enableConfigDiscovery"
12291243
| "mcpServers"
12301244
| "customAgents"
12311245
| "agent"

python/copilot/client.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,6 +1202,7 @@ async def create_session(
12021202
custom_agents: list[CustomAgentConfig] | None = None,
12031203
agent: str | None = None,
12041204
config_dir: str | None = None,
1205+
enable_config_discovery: bool | None = None,
12051206
skill_directories: list[str] | None = None,
12061207
disabled_skills: list[str] | None = None,
12071208
infinite_sessions: InfiniteSessionConfig | None = None,
@@ -1238,6 +1239,13 @@ async def create_session(
12381239
custom_agents: Custom agent configurations.
12391240
agent: Agent to use for the session.
12401241
config_dir: Override for the configuration directory.
1242+
enable_config_discovery: When True, automatically discovers MCP server
1243+
configurations (e.g. ``.mcp.json``, ``.vscode/mcp.json``) and skill
1244+
directories from the working directory and merges them with any
1245+
explicitly provided ``mcp_servers`` and ``skill_directories``, with
1246+
explicit values taking precedence on name collision. Custom instruction
1247+
files (``.github/copilot-instructions.md``, ``AGENTS.md``, etc.) are
1248+
always loaded regardless of this setting.
12411249
skill_directories: Directories to search for skills.
12421250
disabled_skills: Skills to disable.
12431251
infinite_sessions: Infinite session configuration.
@@ -1362,6 +1370,10 @@ async def create_session(
13621370
if config_dir:
13631371
payload["configDir"] = config_dir
13641372

1373+
# Add config discovery flag if provided
1374+
if enable_config_discovery is not None:
1375+
payload["enableConfigDiscovery"] = enable_config_discovery
1376+
13651377
# Add skill directories configuration if provided
13661378
if skill_directories:
13671379
payload["skillDirectories"] = skill_directories
@@ -1455,6 +1467,7 @@ async def resume_session(
14551467
custom_agents: list[CustomAgentConfig] | None = None,
14561468
agent: str | None = None,
14571469
config_dir: str | None = None,
1470+
enable_config_discovery: bool | None = None,
14581471
skill_directories: list[str] | None = None,
14591472
disabled_skills: list[str] | None = None,
14601473
infinite_sessions: InfiniteSessionConfig | None = None,
@@ -1491,6 +1504,13 @@ async def resume_session(
14911504
custom_agents: Custom agent configurations.
14921505
agent: Agent to use for the session.
14931506
config_dir: Override for the configuration directory.
1507+
enable_config_discovery: When True, automatically discovers MCP server
1508+
configurations (e.g. ``.mcp.json``, ``.vscode/mcp.json``) and skill
1509+
directories from the working directory and merges them with any
1510+
explicitly provided ``mcp_servers`` and ``skill_directories``, with
1511+
explicit values taking precedence on name collision. Custom instruction
1512+
files (``.github/copilot-instructions.md``, ``AGENTS.md``, etc.) are
1513+
always loaded regardless of this setting.
14941514
skill_directories: Directories to search for skills.
14951515
disabled_skills: Skills to disable.
14961516
infinite_sessions: Infinite session configuration.
@@ -1588,6 +1608,8 @@ async def resume_session(
15881608
payload["workingDirectory"] = working_directory
15891609
if config_dir:
15901610
payload["configDir"] = config_dir
1611+
if enable_config_discovery is not None:
1612+
payload["enableConfigDiscovery"] = enable_config_discovery
15911613

15921614
# TODO: disable_resume is not a keyword arg yet; keeping for future use
15931615
if mcp_servers:

0 commit comments

Comments
 (0)