Skip to content

fix: load Copilot MCP servers into SDK sessions#28

Merged
zortos293 merged 1 commit intomainfrom
capy/fix-copilot-mcp-servers
Mar 14, 2026
Merged

fix: load Copilot MCP servers into SDK sessions#28
zortos293 merged 1 commit intomainfrom
capy/fix-copilot-mcp-servers

Conversation

@zortos293
Copy link
Owner

@zortos293 zortos293 commented Mar 14, 2026

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.

  • Added apps/server/src/provider/Layers/copilotMcpServers.ts to parse mcp-config.json, normalize server entries (local/stdio with command/args or remote HTTP with url/headers), and default the tools allowlist to "*".
  • Updated apps/server/src/provider/Layers/CopilotAdapter.ts to load the MCP server map before creating or resuming sessions, resolving the path from the provided configDir (or ~/.copilot by default), and passing it to the SDK via the mcpServers session option.
  • Added unit tests in apps/server/src/provider/Layers/CopilotAdapter.test.ts to verify that a configured local stdio server is correctly transformed and injected into the SDK session config.

Open in Capy TC-10 · 5.4

Summary by CodeRabbit

  • New Features

    • Added MCP (Model Context Protocol) server configuration support, enabling integration with local and HTTP/SSE MCP servers
    • MCP server configurations are now automatically loaded and passed to sessions during creation and resumption
    • Includes error handling for configuration loading failures
  • Tests

    • Added comprehensive tests for MCP configuration loading and session integration

@zortos293 zortos293 added the capy Generated by capy.ai label Mar 14, 2026 — with Capy AI
@coderabbitai
Copy link

coderabbitai bot commented Mar 14, 2026

📝 Walkthrough

Walkthrough

This pull request introduces MCP (model context protocol) server configuration loading to the CopilotAdapter. It adds a new module, copilotMcpServers.ts, that parses and validates MCP configurations from a JSON file with type guards and normalization. The main adapter is updated to load these configurations and pass them to Copilot client session creation and resumption. Test coverage is extended with a dedicated MCP configuration test layer, and the FakeCopilotClient is modified to accept and forward config parameters through its session lifecycle methods.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: loading Copilot MCP servers into SDK sessions, which is the core objective of the PR.
Description check ✅ Passed The description covers the key changes, provides context about what MCP servers are and why they're needed, and explains the approach. Required sections are present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

Copy link

@capy-ai capy-ai bot left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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 | 🟠 Major

Pass mcpServers during session reconfiguration.

When reconfigureSession calls resumeSession (e.g., after a model switch), it doesn't pass mcpServers—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 mcpServers in ActiveCopilotSession and pass them to resumeSession in 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

📥 Commits

Reviewing files that changed from the base of the PR and between b974cea and d677b51.

📒 Files selected for processing (3)
  • apps/server/src/provider/Layers/CopilotAdapter.test.ts
  • apps/server/src/provider/Layers/CopilotAdapter.ts
  • apps/server/src/provider/Layers/copilotMcpServers.ts

@zortos293 zortos293 merged commit 57b01c1 into main Mar 14, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

capy Generated by capy.ai size:L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant