fix: load Copilot MCP servers into SDK sessions#28
Conversation
📝 WalkthroughWalkthroughThis pull request introduces MCP (model context protocol) server configuration loading to the CopilotAdapter. It adds a new module, 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 📝 Coding Plan
Comment Tip CodeRabbit can use Trivy to scan for security misconfigurations and secrets in Infrastructure as Code files.Add a .trivyignore file to your project to customize which findings Trivy reports. |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/server/src/provider/Layers/CopilotAdapter.ts (1)
1136-1143:⚠️ Potential issue | 🟠 MajorPass
mcpServersduring session reconfiguration.When
reconfigureSessioncallsresumeSession(e.g., after a model switch), it doesn't passmcpServers—unlike the initial session creation at line 1321. This causes MCP server configurations to be lost mid-session when changing models or reasoning effort.Store
mcpServersinActiveCopilotSessionand pass them toresumeSessionin the reconfigureSession call to maintain consistent behavior with initial session setup.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/server/src/provider/Layers/CopilotAdapter.ts` around lines 1136 - 1143, The reconfigureSession call to record.client.resumeSession is not forwarding mcpServers, causing MCP configuration loss; update ActiveCopilotSession to persist mcpServers and include them when calling resumeSession in reconfigureSession (alongside handlers, model, reasoningEffort, workingDirectory, configDir, streaming) so resumeSession receives the same mcpServers used during initial session creation; ensure the stored property name (e.g., ActiveCopilotSession.mcpServers) is read and passed through to resumeSession.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@apps/server/src/provider/Layers/CopilotAdapter.ts`:
- Around line 1136-1143: The reconfigureSession call to
record.client.resumeSession is not forwarding mcpServers, causing MCP
configuration loss; update ActiveCopilotSession to persist mcpServers and
include them when calling resumeSession in reconfigureSession (alongside
handlers, model, reasoningEffort, workingDirectory, configDir, streaming) so
resumeSession receives the same mcpServers used during initial session creation;
ensure the stored property name (e.g., ActiveCopilotSession.mcpServers) is read
and passed through to resumeSession.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 3cd4600b-1db5-4d8c-b4b9-103e5f4ef510
📒 Files selected for processing (3)
apps/server/src/provider/Layers/CopilotAdapter.test.tsapps/server/src/provider/Layers/CopilotAdapter.tsapps/server/src/provider/Layers/copilotMcpServers.ts
This PR enables local stdio and remote MCP servers configured in the GitHub Copilot CLI config (
~/.copilot/mcp-config.json) to work within t3code by passing the server definitions to the underlying Copilot SDK.apps/server/src/provider/Layers/copilotMcpServers.tsto parsemcp-config.json, normalize server entries (local/stdio withcommand/argsor remote HTTP withurl/headers), and default thetoolsallowlist to"*".apps/server/src/provider/Layers/CopilotAdapter.tsto load the MCP server map before creating or resuming sessions, resolving the path from the providedconfigDir(or~/.copilotby default), and passing it to the SDK via themcpServerssession option.apps/server/src/provider/Layers/CopilotAdapter.test.tsto verify that a configured local stdio server is correctly transformed and injected into the SDK session config.Summary by CodeRabbit
New Features
Tests