Skip to content

Remove duplicate parsing logic from mcp inspect commands#11898

Merged
pelikhan merged 2 commits intomainfrom
copilot/review-mcp-inspect-logic
Jan 26, 2026
Merged

Remove duplicate parsing logic from mcp inspect commands#11898
pelikhan merged 2 commits intomainfrom
copilot/review-mcp-inspect-logic

Conversation

Copy link
Contributor

Copilot AI commented Jan 26, 2026

The mcp inspect and mcp inspect --inspector commands reimplemented frontmatter parsing, import processing, and MCP server merging logic that already exists in the compiler.

Changes

  • mcp_inspect.go: Replace manual parsing pipeline with compiler.ParseWorkflowFile()
  • mcp_inspect_inspector.go: Same compiler-based approach
  • mcp_inspect_imports.go: Removed (78 lines) - applyImportsToFrontmatter() no longer needed
  • mcp_inspect_test.go: Removed obsolete test (103 lines)

Added buildFrontmatterFromWorkflowData() helper that uses ParsedFrontmatter.ToMap() to reconstruct frontmatter for MCP extraction.

Before/After

Before:

// Manual parsing and merging
content, _ := os.ReadFile(workflowPath)
parsedData, _ := parser.ExtractFrontmatterFromContent(string(content))
importsResult, _ := parser.ProcessImportsFromFrontmatterWithManifest(...)
frontmatterWithImports, _ := applyImportsToFrontmatter(parsedData.Frontmatter, importsResult)
mcpConfigs, _ := parser.ExtractMCPConfigurations(frontmatterWithImports, serverFilter)

After:

// Compiler handles parsing, imports, and merging
compiler := workflow.NewCompiler(verbose, "", "")
workflowData, _ := compiler.ParseWorkflowFile(workflowPath)
frontmatter := buildFrontmatterFromWorkflowData(workflowData)
mcpConfigs, _ := parser.ExtractMCPConfigurations(frontmatter, serverFilter)

This ensures consistent behavior between compilation and inspection commands, eliminating ~220 lines of duplicate code.

Original prompt

Review mcp_inspect workflow parsing logic and remove duplicate custom parsing/merging that should be been done by the compiler. The compiler functions should be used to generate the mcp server config.


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

… parsing

- Replace manual frontmatter parsing in mcp_inspect.go with compiler.ParseWorkflowFile()
- Remove duplicate applyImportsToFrontmatter function and mcp_inspect_imports.go
- Update mcp_inspect_inspector.go to use compiler functions consistently
- Use ParsedFrontmatter.ToMap() to reconstruct frontmatter for MCP extraction
- Remove test for deleted applyImportsToFrontmatter function

Benefits:
- Eliminates ~100 lines of duplicate parsing/merging logic
- Ensures consistent behavior between compilation and inspection
- Automatically handles all import types (mcp-servers, tools, safe-inputs, etc.)
- Leverages compiler's robust validation and error handling

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Review mcp_inspect workflow parsing logic and remove duplicates Remove duplicate parsing logic from mcp inspect commands Jan 26, 2026
Copilot AI requested a review from pelikhan January 26, 2026 15:44
@pelikhan pelikhan marked this pull request as ready for review January 26, 2026 15:47
@pelikhan pelikhan merged commit 4eecb5b into main Jan 26, 2026
151 of 152 checks passed
@pelikhan pelikhan deleted the copilot/review-mcp-inspect-logic branch January 26, 2026 15:55
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