Skip to content

feat: Add GitHub Copilot SDK backend with MCP and custom tools support#916

Draft
Copilot wants to merge 1 commit intocopilot-sdkfrom
copilot/sub-pr-862-again
Draft

feat: Add GitHub Copilot SDK backend with MCP and custom tools support#916
Copilot wants to merge 1 commit intocopilot-sdkfrom
copilot/sub-pr-862-again

Conversation

Copy link

Copilot AI commented Feb 18, 2026

Description

Implements GitHub Copilot backend integration using github-copilot-sdk with native MCP server support, custom MassGen tools, and stateful session management.

Core Implementation:

  • MCP server integration via SDK's native mcpServers configuration
  • Custom tool wrapping as MCP server with workspace-aware spec files
  • Stateful session management with signature-based cache invalidation
  • Authentication flow with retry logic and clear error diagnostics

Key Features:

  • Tool routing detection (is_mcp_tool_call, is_custom_tool_call)
  • Session signature tracking to recreate sessions on config changes
  • Dynamic workspace resolution per agent for custom tool specs
  • Permission policy and system message mode configuration
  • Tool filtering via allowed_tools/exclude_tools with MCP server integration
  • Multimodal tool support (read_media, generate_media)

Architecture:

# Session lifecycle with signature tracking
session_signature = _build_session_signature(
    model=model,
    system_message=system_message,
    workflow_tools=tools,
    mcp_servers=mcp_servers,
    working_directory=working_dir,
    available_tools=available_tools,
)

# Recreate session if config changed
if existing_signature != session_signature:
    await self._destroy_session(agent_id)
    session = await self.client.create_session(session_config)

Tool Integration:

  • Workflow tools converted to SDK Tool objects with async handlers
  • MCP tools exposed via mcp_servers config with per-server tool filtering
  • Custom tools packaged as local MCP server with .copilot/custom_tool_specs.json

Windows Compatibility:

  • Fixed read-only file cleanup in _filesystem_manager.py using shutil.rmtree with onerror handler
  • Fixed debug logging paths to use tempfile.gettempdir() instead of hardcoded /tmp

Type of change

  • New feature (feat:) - Non-breaking change which adds functionality

Checklist

  • I have run pre-commit on my changed files and all checks pass
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Pre-commit status

Applied via commit 2a6ce60

How to Test

Prerequisites

# Install Copilot SDK and authenticate
pip install github-copilot-sdk
copilot login  # Follow authentication flow

Test CLI Command

# Basic Copilot backend test
uv run massgen --automation --config massgen/configs/providers/copilot_basic.yaml "What is 2+2?"

# With MCP filesystem tools
uv run massgen --automation --config massgen/configs/providers/copilot_mcp.yaml "List files in current directory"

# With custom tools
uv run massgen --automation --config massgen/configs/providers/copilot_custom_tools.yaml "Search for 'async def' in Python files"

Expected Results

  • Copilot backend successfully authenticates via gh CLI
  • MCP tools (filesystem, web search) execute correctly
  • Custom MassGen tools are accessible via MCP wrapper
  • Sessions persist across multiple turns
  • Tool calls properly routed (MCP vs workflow vs custom)

Additional context

Dependencies:

  • github-copilot-sdk (added to pyproject.toml)

Capabilities:

  • Model: gpt-4.1 (default)
  • Native MCP support via SDK
  • Streaming with reasoning tokens
  • Tool execution via SDK handlers
  • Session-based state management

Related Files:

  • massgen/backend/copilot.py - Main backend implementation
  • massgen/backend/capabilities.py - Copilot model registry
  • massgen/filesystem_manager/_filesystem_manager.py - Windows cleanup fixes
  • massgen/frontend/displays/textual_*.py - Debug logging path fixes

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI mentioned this pull request Feb 18, 2026
18 tasks
Copilot AI changed the title [WIP] Add support for Copilot SDK feat: Add GitHub Copilot SDK backend with MCP and custom tools support Feb 18, 2026
Copilot AI requested a review from AbhimanyuAryan February 18, 2026 14:14
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