Skip to content

Fix mcp inspect to apply imports before extracting MCP configurations#1359

Merged
pelikhan merged 4 commits into
mainfrom
copilot/fix-mcp-launch-imports
Oct 8, 2025
Merged

Fix mcp inspect to apply imports before extracting MCP configurations#1359
pelikhan merged 4 commits into
mainfrom
copilot/fix-mcp-launch-imports

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 8, 2025

Problem

The mcp inspect command was not processing the imports: field in workflow frontmatter before extracting MCP server configurations. This meant that MCP servers defined in imported files were invisible to the inspect command, even though they would be properly included during workflow compilation.

For example, the pdf-summary.md workflow imports shared/markitdown-mcp.md which defines a markitdown MCP server:

# .github/workflows/pdf-summary.md
---
imports:
  - shared/markitdown-mcp.md
---
# .github/workflows/shared/markitdown-mcp.md
---
mcp-servers:
  markitdown:
    container: "ghcr.io/microsoft/markitdown"
    allowed: ["*"]
---

Running gh aw mcp inspect pdf-summary would fail to find the markitdown MCP server because imports were not being processed.

Solution

Updated both InspectWorkflowMCP and spawnMCPInspector functions to:

  1. Process imports from frontmatter using parser.ProcessImportsFromFrontmatterWithManifest (the same function used by the workflow compiler)
  2. Merge imported MCP servers and tools with top-level configurations
  3. Extract MCP configurations from the merged result

This ensures mcp inspect sees the complete MCP server configuration, including servers defined in imported files.

Key Changes

  • Exported merge methods (MergeTools, MergeMCPServers) in pkg/workflow/imports.go for reuse across the codebase
  • Added applyImportsToFrontmatter helper to merge imported configurations into frontmatter before extraction
  • Updated both inspect functions to process imports before extracting MCP configurations

Testing

  • Added unit test TestApplyImportsToFrontmatter to verify import merging logic
  • Verified all 60 existing workflows compile successfully
  • Integration testing confirms:
    • ✅ Workflows with imports (e.g., pdf-summary) correctly find imported MCP servers
    • ✅ Workflows without imports continue to work normally
    • ✅ Filtering by server name works for imported MCP servers

Now running gh aw mcp inspect pdf-summary correctly finds and inspects the markitdown MCP server imported from shared/markitdown-mcp.md.

Original prompt

mcp inspect must apply imports before trying to launch mcps. Reuse existing helper function to parse, apply the imports.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix import application before launching mcps Fix mcp inspect to apply imports before extracting MCP configurations Oct 8, 2025
Copilot AI requested a review from pelikhan October 8, 2025 15:14
@pelikhan pelikhan marked this pull request as ready for review October 8, 2025 15:20
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