Refactor MCP server config types across all SDK languages#1051
Refactor MCP server config types across all SDK languages#1051stephentoub wants to merge 5 commits intomainfrom
Conversation
Introduce an abstract McpServerConfig base class in C# with a private protected constructor and sealed derived types McpStdioServerConfig and McpHttpServerConfig. Shared properties (Tools, Type, Timeout) are deduplicated into the base class. The Type property uses the JsonPolymorphic discriminator pattern consistent with SessionEvent. All Dictionary<string, object> McpServers properties are now strongly typed as Dictionary<string, McpServerConfig>. Rename Local/Remote to Stdio/Http across all four SDK languages to match MCP protocol terminology: - C#: McpStdioServerConfig / McpHttpServerConfig - TypeScript: MCPStdioServerConfig / MCPHttpServerConfig - Go: MCPStdioServerConfig / MCPHTTPServerConfig - Python: MCPStdioServerConfig / MCPHttpServerConfig Update documentation examples accordingly. Fixes #245 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR refactors MCP server configuration types across the SDKs, primarily improving the .NET SDK by introducing a polymorphic McpServerConfig hierarchy and updating McpServers dictionaries to be strongly typed. It also renames “Local/Remote” MCP config types to “Stdio/Http” across TypeScript, Python, Go, .NET, and updates documentation and tests accordingly.
Changes:
- .NET: Introduces polymorphic
McpServerConfigwithMcpStdioServerConfig/McpHttpServerConfigand updates allMcpServersdictionaries toDictionary<string, McpServerConfig>. - TypeScript/Python/Go: Renames MCP config types to
Stdio/Httpvariants and updates exports/tests accordingly. - Docs: Updates MCP feature and troubleshooting docs to use the new type names and removes explicit
"local"type from C# examples.
Show a summary per file
| File | Description |
|---|---|
| python/copilot/session.py | Renames Python MCP TypedDict config types to MCPStdioServerConfig / MCPHttpServerConfig. |
| nodejs/test/e2e/mcp_and_agents.test.ts | Updates E2E test imports/casts to renamed MCP stdio config type. |
| nodejs/src/types.ts | Renames exported TS MCP config interfaces and updates the union type. |
| nodejs/src/index.ts | Re-exports the renamed TS MCP config interfaces from the public entrypoint. |
| go/types.go | Renames Go MCP config structs to MCPStdioServerConfig / MCPHTTPServerConfig. |
| dotnet/test/McpAndAgentsTests.cs | Updates .NET E2E tests to use typed MCP server configs and new names. |
| dotnet/test/CloneTests.cs | Updates clone tests for strongly-typed McpServers dictionaries. |
| dotnet/src/Types.cs | Adds polymorphic .NET MCP config type hierarchy and updates McpServers property types. |
| dotnet/src/Client.cs | Updates internal RPC request records to use typed MCP server config dictionaries. |
| docs/troubleshooting/mcp-debugging.md | Updates troubleshooting examples for renamed/typed MCP config types. |
| docs/features/mcp.md | Updates MCP feature docs example to use typed McpServerConfig and renamed stdio type. |
Copilot's findings
- Files reviewed: 11/11 changed files
- Comments generated: 2
This comment has been minimized.
This comment has been minimized.
Rename MCPHttpServerConfig to MCPHTTPServerConfig in Python (matching stdlib convention: HTTPServer, HTTPError) and TypeScript (matching the all-caps treatment of MCP already in use). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
|
Replying to review comment on Types.cs line 1422: The suggestion won't compile —
|
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Generated by SDK Consistency Review Agent for issue #1051
Change MCPServerConfig from map[string]any to an interface with a private marker method, matching the type-safety approach used for C#. MCPStdioServerConfig and MCPHTTPServerConfig implement the interface and use MarshalJSON to auto-inject the type discriminator. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
…n tests - Update MCPServerConfigBase JSDoc to reference stdio/http instead of local/remote - Remove explicit type: local from Python E2E tests (omitted type defaults to stdio, matching Go/C# pattern) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Cross-SDK Consistency Review ✅This PR does an excellent job of maintaining consistency across all four SDK implementations. The rename from Naming consistency check
One consistency gap to consider (pre-existing, but worth addressing)The Node.js SDK explicitly re-exports import type { MCPStdioServerConfig } from "`@github/copilot-sdk`";Python's from copilot.session import MCPStdioServerConfig # works
from copilot import MCPStdioServerConfig # ❌ failsThis is pre-existing and not introduced by this PR, but since this PR is already touching Overall: the cross-SDK rename is thorough and consistent. No blocking issues found.
|
|
@SteveSandersonMS, mind taking a peek at this one, just to make sure you agree with the API changes? |
Motivation
The C# SDK typed
McpServersdictionaries asDictionary<string, object>, losing all compile-time safety and forcing consumers to know which concrete config type to use without IDE guidance. The type names (McpLocalServerConfig/McpRemoteServerConfig) also didn't align with MCP protocol terminology. Fixes #245.Approach
C# type hierarchy — Introduces an abstract
McpServerConfigbase class with:private protectedconstructor (no external subclassing)sealedderived typesMcpStdioServerConfigandMcpHttpServerConfigTools,Type,Timeout) deduplicated into the base[JsonPolymorphic]discriminator on"type"following the same pattern asSessionEvent[JsonIgnore]virtualTypeproperty overridden in each derived typeStrongly-typed dictionaries — All
Dictionary<string, object>McpServers properties (SessionConfig,ResumeSessionConfig,CustomAgentConfig, internal RPC records) are nowDictionary<string, McpServerConfig>.Cross-language rename — Renamed Local/Remote → Stdio/Http across all four SDKs to match MCP protocol terminology:
McpStdioServerConfigMcpHttpServerConfigMCPStdioServerConfigMCPHttpServerConfigMCPStdioServerConfigMCPHTTPServerConfigMCPStdioServerConfigMCPHttpServerConfigDocs — Updated MCP feature guide and troubleshooting guide with new type names and removed
Type = "local"from C# examples (now handled by the type discriminator).Validation