Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 4, 2025

Plan: Change MCP Servers from Slice to Map

  • Explore repository structure and understand current implementation
  • Run initial tests, lint, and build to confirm working state
  • Change TaskFrontMatter.MCPServers from []MCPServerConfig to map[string]MCPServerConfig
  • Change RuleFrontMatter.MCPServers from []MCPServerConfig to map[string]MCPServerConfig
  • Update Result.MCPServers() method to return map instead of slice
  • Update all tests to use map structure instead of slices
  • Update example files to use map format
  • Update documentation to reflect map structure
  • Run lint, build, and tests to verify changes
  • Manual verification of changes
  • Address PR feedback: simplified merge logic to allow non-deterministic duplicates in rules
  • Address PR feedback: add MCPServerConfigs type alias

Summary

Successfully changed MCP servers from a slice to a map structure and addressed all feedback.

Latest Changes (addressing PR feedback):

  • Added new type MCPServerConfigs as an alias for map[string]MCPServerConfig
  • Updated all usages throughout the codebase to use the new type alias
  • This improves code readability and makes it easier to work with server configurations

The new type is defined in mcp_server_config.go and used consistently across:

  • TaskFrontMatter.MCPServers
  • RuleFrontMatter.MCPServers
  • Result.MCPServers() return type
  • All test cases

All tests pass, lint succeeds, and the build completes successfully.

Original prompt

MCP servers needs to be a map from name to mcp server, not a slice.


💡 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.

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
Copilot AI requested a review from alexec December 4, 2025 16:58
// 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"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot please add a new type:

type MCPServerConfigs map[string]MCPServerConfig

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added MCPServerConfigs type alias and updated all usages throughout the codebase. (f6ec4d7)

Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
@alexec alexec marked this pull request as ready for review December 4, 2025 17:18
Copilot AI review requested due to automatic review settings December 4, 2025 17:18
@alexec alexec enabled auto-merge (squash) December 4, 2025 17:18
@alexec alexec merged commit 52fbcce into main Dec 4, 2025
6 checks passed
@alexec alexec deleted the copilot/update-mcp-servers-to-map branch December 4, 2025 17:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 MCPServers field from []MCPServerConfig to MCPServerConfigs (a type alias for map[string]MCPServerConfig) in both TaskFrontMatter and RuleFrontMatter
  • 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants