Convert MCP servers from slice to map structure#137
Merged
Conversation
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Update MCP servers to use a map from name to server
Convert MCP servers from slice to map structure
Dec 4, 2025
alexec
reviewed
Dec 4, 2025
alexec
reviewed
Dec 4, 2025
| // MCPServers maps server names to their configurations | ||
| // Does not filter rules, metadata only | ||
| MCPServers []MCPServerConfig `yaml:"mcp_servers,omitempty" json:"mcp_servers,omitempty"` | ||
| MCPServers map[string]MCPServerConfig `yaml:"mcp_servers,omitempty" json:"mcp_servers,omitempty"` |
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
alexec
approved these changes
Dec 4, 2025
Contributor
There was a problem hiding this comment.
Pull request overview
This PR converts the MCP servers configuration from a slice-based structure to a map-based structure, where server names map to their configurations. This change improves the API by allowing servers to be referenced by name and enables task-level server configurations to override rule-level configurations with the same name.
- Changed
MCPServersfield from[]MCPServerConfigtoMCPServerConfigs(a type alias formap[string]MCPServerConfig) in bothTaskFrontMatterandRuleFrontMatter - Updated the
Result.MCPServers()method to merge servers from rules and tasks, with task servers taking precedence over rule servers with the same name - Added comprehensive test coverage including a new test case for override behavior
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/codingcontext/mcp_server_config.go | Adds MCPServerConfigs type alias for map[string]MCPServerConfig |
| pkg/codingcontext/task_frontmatter.go | Changes MCPServers field from slice to map using new type alias |
| pkg/codingcontext/rule_frontmatter.go | Changes MCPServers field from slice to map using new type alias |
| pkg/codingcontext/result.go | Updates merge logic to use map iteration and task-override-rule precedence |
| pkg/codingcontext/task_frontmatter_test.go | Updates test data to use map structure instead of slices |
| pkg/codingcontext/rule_frontmatter_test.go | Updates test data to use map structure instead of slices |
| pkg/codingcontext/result_test.go | Updates all test cases to use maps, adds override test case, updates assertions to iterate over map |
| pkg/codingcontext/context_test.go | Updates test YAML strings and assertions to use map format |
| examples/agents/tasks/example-with-standard-fields.md | Updates example frontmatter to use proper map YAML syntax with server names as keys |
| docs/reference/file-formats.md | Updates documentation to describe map structure and provides comprehensive examples |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Plan: Change MCP Servers from Slice to Map
TaskFrontMatter.MCPServersfrom[]MCPServerConfigtomap[string]MCPServerConfigRuleFrontMatter.MCPServersfrom[]MCPServerConfigtomap[string]MCPServerConfigResult.MCPServers()method to return map instead of sliceSummary
Successfully changed MCP servers from a slice to a map structure and addressed all feedback.
Latest Changes (addressing PR feedback):
MCPServerConfigsas an alias formap[string]MCPServerConfigThe new type is defined in
mcp_server_config.goand used consistently across:TaskFrontMatter.MCPServersRuleFrontMatter.MCPServersResult.MCPServers()return typeAll tests pass, lint succeeds, and the build completes successfully.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.