Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 6, 2025

Overview

Refactored the Tavily MCP server configuration from the scout workflow into a separate shared workflow file and updated scout to use the imports field. Added full compiler support for importing mcp-servers entries from shared workflows. This change improves code reusability and maintainability by allowing MCP server configurations to be shared across multiple workflows.

Changes

1. Created Shared Tavily MCP Configuration

Created .github/workflows/shared/tavily-mcp.md containing the reusable Tavily MCP server configuration using mcp-servers:

---
mcp-servers:
  tavily:
    url: "https://mcp.tavily.com/mcp/?tavilyApiKey=${{ secrets.TAVILY_API_KEY }}"
    allowed: ["*"]
---

2. Updated Scout Workflow

Modified .github/workflows/scout.md to import the shared configuration instead of defining it inline:

---
name: Scout
# ... other config ...
engine: copilot
imports:
  - shared/tavily-mcp.md
tools:
  cache-memory:
    retention-days: 7
# mcp-servers section removed - now imported
---

3. Added Compiler Support for Importing MCP Servers

Schema Updates:

  • Added full mcp-servers schema to included_file_schema.json with proper $defs for stdio_mcp_tool and http_mcp_tool (copied from main workflow schema)
  • This ensures imported MCP servers are properly validated with the same strict schema as main workflows

Parser Updates (pkg/parser/frontmatter.go):

  • Added MergedMCPServers field to ImportsResult struct
  • Implemented extractMCPServersFromContent() to extract MCP servers from imported files
  • Updated ProcessImportsFromFrontmatterWithManifest() to collect and merge MCP servers from imports

Compiler Updates (pkg/workflow/compiler.go):

  • Implemented mergeMCPServers() to merge imported MCP servers with top-level ones using object maps
  • Updated workflow compilation to merge imported MCP servers with main workflow MCP servers
  • Handles newline-separated JSON objects from multiple imports

4. Fixed Critical Bug in Import Merging

Discovered and fixed a bug in pkg/workflow/compiler.go where the mergeTools() function failed to parse tools from multiple imports. The function was attempting to parse concatenated newline-separated JSON objects as a single JSON object, which is invalid:

{"tool1": {...}}
{"tool2": {...}}

The Fix: Modified mergeTools() to:

  1. Split the input string by newlines
  2. Parse each JSON object individually
  3. Iteratively merge them using parser.MergeTools()

This fix enables workflows to properly import and merge both tools and mcp-servers from multiple shared configuration files.

5. Updated Documentation

Include Directives Documentation:

  • Updated frontmatter merging section to mention both tools: and mcp-servers:
  • Added example showing MCP server merging with Tavily

Packaging and Imports Guide:

  • Updated frontmatter merging section with MCP server example
  • Added new Example 3 showing MCP server imports via the imports: field
  • Enhanced imports field documentation to mention MCP servers

6. Added Integration Tests

Added comprehensive tests in pkg/workflow/imports_test.go to prevent regressions:

  • TestCompileWorkflowWithImports - validates single import functionality for tools
  • TestCompileWorkflowWithMultipleImports - validates multiple tool imports merge correctly
  • TestCompileWorkflowWithMCPServersImport - validates MCP server imports work correctly

7. Merged Main Branch

  • Merged latest changes from main branch
  • Recompiled all workflows to update lock files with latest changes
  • All tests passing including import-related tests

8. Code Organization and Linting

  • Created pkg/workflow/imports.go to consolidate import/merge related functions
  • Moved mergeTools() and mergeMCPServers() from compiler.go to imports.go
  • Fixed linting issue: removed unnecessary nil check (S1031)
  • All linting checks passing

Verification

  • ✅ Scout workflow compiles successfully with Tavily MCP server imported from shared file
  • ✅ All existing tests pass
  • ✅ New integration tests validate imports functionality for both tools and mcp-servers
  • ✅ Lock file contains correct MCP configuration:
"tavily": {
  "type": "http",
  "url": "https://mcp.tavily.com/mcp/?tavilyApiKey=${{ secrets.TAVILY_API_KEY }}",
  "tools": ["*"]
}
  • ✅ Successfully merged main branch with no conflicts
  • ✅ All workflows recompiled successfully
  • ✅ All linting checks passing
  • ✅ Code properly organized with imports functionality in dedicated file

Impact

This change enables reusable MCP server configurations across multiple workflows using the mcp-servers field in shared workflow files, improving maintainability and consistency. It also fixes a fundamental issue with the imports system that would have affected any workflow using multiple imports.

Original prompt

Refactor Tavily MCP configuration in a separate shared workflow and import in scout using "imports" field in front matter.


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

Copilot AI and others added 3 commits October 6, 2025 22:56
…erging

- Created shared/tavily-mcp.md for reusable Tavily MCP configuration
- Updated scout.md to use imports field instead of inline mcp-servers
- Fixed bug in mergeTools where newline-separated JSON objects weren't being parsed correctly
- Import functionality now properly handles multiple JSON objects from different imports

Co-authored-by: pelikhan <[email protected]>
Added comprehensive tests to verify that imports work correctly with single and multiple imported files. Tests validate that MCP configurations are properly merged from imported files.

Co-authored-by: pelikhan <[email protected]>
Copilot AI changed the title [WIP] Refactor Tavily MCP configuration into shared workflow Refactor Tavily MCP configuration to shared workflow and fix import merging bug Oct 6, 2025
Copilot AI requested a review from pelikhan October 6, 2025 23:03
Copilot finished work on behalf of pelikhan October 6, 2025 23:03
@@ -0,0 +1,6 @@
---
tools:
Copy link
Contributor

@pelikhan pelikhan Oct 6, 2025

Choose a reason for hiding this comment

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

@copilot the compiler should support importing mcp-servers entries. move tavily under mcp-servers and add support in compiler to import mcp servers entries as well


🤖 Workflow run triggered by this comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! I've moved tavily under mcp-servers in the shared file and added full compiler support for importing mcp-servers entries.

Changes in commit 7892cf8:

  • Updated shared/tavily-mcp.md to use mcp-servers instead of tools
  • Added mcp-servers to the included file schema
  • Implemented extractMCPServersFromContent() and mergeMCPServers() functions
  • Updated the parser and compiler to merge imported mcp-servers with top-level ones
  • Added test case TestCompileWorkflowWithMCPServersImport to validate the functionality

The scout workflow now correctly imports the Tavily MCP server from the shared file using mcp-servers, and the compiled lock file contains the proper HTTP MCP server configuration.

- Updated shared/tavily-mcp.md to use mcp-servers instead of tools
- Added mcp-servers to included_file_schema.json
- Added MergedMCPServers field to ImportsResult struct
- Implemented extractMCPServersFromContent and mergeMCPServers functions
- Updated ProcessImportsFromFrontmatterWithManifest to extract and merge mcp-servers
- Updated compiler to merge imported mcp-servers with top-level mcp-servers
- Added test for importing mcp-servers (TestCompileWorkflowWithMCPServersImport)

Co-authored-by: pelikhan <[email protected]>
@githubnext githubnext deleted a comment from github-actions bot Oct 6, 2025
Copilot AI changed the title Refactor Tavily MCP configuration to shared workflow and fix import merging bug Refactor Tavily MCP configuration to shared workflow and add mcp-servers import support Oct 6, 2025
Copilot AI requested a review from pelikhan October 6, 2025 23:19
Copilot finished work on behalf of pelikhan October 6, 2025 23:19
Copy link
Contributor

@pelikhan pelikhan left a comment

Choose a reason for hiding this comment

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

@copilot update docs on imports to mention MCP servers

- Copied full MCP servers schema from main workflow to included file schema with $defs for stdio_mcp_tool and http_mcp_tool
- Refactored mergeMCPServers to ensure clean map creation instead of modifying input
- Updated documentation to mention MCP servers can be imported:
  - include-directives.md: Added frontmatter merging section for mcp-servers with example
  - packaging-imports.md: Added MCP server import examples and updated existing examples
- All tests passing

Co-authored-by: pelikhan <[email protected]>
Copy link
Contributor Author

Copilot AI commented Oct 6, 2025

@copilot update docs on imports to mention MCP servers

Done! Updated documentation to mention MCP servers can be imported:

include-directives.md:

  • Updated frontmatter merging section to mention both tools: and mcp-servers:
  • Added example showing Tavily MCP server merging

packaging-imports.md:

  • Updated frontmatter merging with MCP server example
  • Added Example 3 demonstrating MCP server imports via the imports: field
  • Enhanced imports field documentation

Commit d413d04

Copilot AI requested a review from pelikhan October 6, 2025 23:44
Copilot finished work on behalf of pelikhan October 6, 2025 23:44
@pelikhan
Copy link
Contributor

pelikhan commented Oct 6, 2025

@copilot merge main, recompile


🤖 Workflow run triggered by this comment

Copilot AI and others added 2 commits October 6, 2025 23:55
- Merged latest changes from main branch
- Recompiled all workflows to update lock files
- All tests passing including import-related tests
- Tavily MCP server still correctly configured in scout workflow

Co-authored-by: pelikhan <[email protected]>
Copy link
Contributor Author

Copilot AI commented Oct 6, 2025

@copilot merge main, recompile

---...

Done! Merged main branch and recompiled all workflows.

Changes:

  • Merged latest commits from main (including new issue-classifier workflow and copilot log parsing improvements)
  • Recompiled all 9 workflows successfully
  • All import-related tests passing
  • Tavily MCP server still correctly configured in scout.lock.yml

Commit 9f3a0b6

@pelikhan pelikhan marked this pull request as ready for review October 6, 2025 23:59
@githubnext githubnext deleted a comment from github-actions bot Oct 7, 2025
…ty and error handling

- Simplified the parsing and validation of agent output in create_discussion.js and create_issue.js.
- Enhanced error messages for better debugging.
- Improved the handling of discussion categories and issue labels.
- Added checks for empty titles and bodies, ensuring defaults are set appropriately.
- Streamlined the creation process for discussions and issues, including better logging of created items.
- Updated summary writing to include details of created discussions and issues.
@githubnext githubnext deleted a comment from github-actions bot Oct 7, 2025
@pelikhan
Copy link
Contributor

pelikhan commented Oct 7, 2025

@copilot

  • lint and fix linting issues
  • move code related to import/merge of share workflows to "imports.go"

🤖 Workflow run triggered by this comment

- Created pkg/workflow/imports.go with mergeTools and mergeMCPServers functions
- Removed these functions from compiler.go for better code organization
- Fixed linting issue: removed unnecessary nil check in mergeMCPServers (S1031)
- All tests passing including import-related tests
- Scout workflow still compiles correctly with Tavily MCP server

Co-authored-by: pelikhan <[email protected]>
Copy link
Contributor Author

Copilot AI commented Oct 7, 2025

@copilot

  • lint and fix linting issues
  • move code related to import/merge of share workflows to "imports.go"...

Done!

Linting:

  • Fixed linting issue S1031 (unnecessary nil check in mergeMCPServers)
  • All golangci-lint checks passing

Code Organization:

  • Created pkg/workflow/imports.go with import/merge related functions
  • Moved mergeTools() and mergeMCPServers() from compiler.go to imports.go
  • All tests passing

Commit 1f8e0a5

Copilot finished work on behalf of pelikhan October 7, 2025 00:20
@pelikhan pelikhan merged commit 1c2c23b into main Oct 7, 2025
13 checks passed
@pelikhan pelikhan deleted the copilot/refactor-tavily-mcp-configuration branch October 7, 2025 00:29
Copilot finished work on behalf of pelikhan October 7, 2025 01:37
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