Skip to content

Add args support for github and playwright tools in frontmatter#1130

Merged
pelikhan merged 10 commits intomainfrom
copilot/fix-029c513d-394a-4ff4-ae62-eea332504e83
Oct 1, 2025
Merged

Add args support for github and playwright tools in frontmatter#1130
pelikhan merged 10 commits intomainfrom
copilot/fix-029c513d-394a-4ff4-ae62-eea332504e83

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 1, 2025

Summary: Add args support for github and playwright tools ✅

This PR successfully adds support for optional "args" argument for github and playwright tools in the frontmatter, allowing users to customize MCP server behavior.

Changes completed:

  • Update pkg/workflow/mcps.go to extract and return args from tool configuration
  • Update pkg/parser/mcp.go to handle args field in processBuiltinMCPTool for github and playwright
  • Update all engine renderers to append custom args:
    • pkg/workflow/custom_engine.go - renderGitHubMCPConfig and renderPlaywrightMCPConfig
    • pkg/workflow/copilot_engine.go - renderGitHubCopilotMCPConfig and renderPlaywrightCopilotMCPConfig
    • pkg/workflow/claude_engine.go - renderGitHubClaudeMCPConfig and renderPlaywrightMCPConfig
    • pkg/workflow/codex_engine.go - renderGitHubCodexMCPConfig and renderPlaywrightCodexMCPConfig
  • Add comprehensive tests for args functionality
  • Update JSON schema to allow args field for github and playwright tools
  • Fix validation logic to prevent args from marking built-in tools as custom MCP tools
  • Address code review feedback - improved comments
  • Use proper JSON quoting/escaping with json.Marshal for args ✅
  • Refactor to dedicated args.go file with helper functions ✅
  • Add comprehensive documentation for args feature
  • Add test agentic workflows demonstrating args usage
  • Update documentation to clarify Chromium-only support
  • Run make agent-finish to verify all changes ✅

Implementation details:

  1. Helper functions (pkg/workflow/args.go):

    • extractCustomArgs() - Generic extraction helper for tool args
    • getGitHubCustomArgs() - Extracts custom args from GitHub tool config
    • getPlaywrightCustomArgs() - Extracts custom args from Playwright tool config
    • writeArgsToYAML() - Writes args to YAML with proper JSON quoting (multi-line)
    • writeArgsToYAMLInline() - Writes args to YAML inline (single-line format)
    • All functions properly handle []any and []string formats
    • Use json.Marshal for proper quoting and escaping
  2. Parser updates (pkg/parser/mcp.go):

    • Extended processBuiltinMCPTool() to append custom args after default args
    • Args are appended to the Args slice for both github and playwright tools
  3. Engine renderer updates:

    • All four engines (Custom, Copilot, Claude, Codex) now use centralized helpers
    • Args are properly quoted and escaped using helper functions
    • Removed duplicate json imports where no longer needed
  4. Schema updates (pkg/parser/schemas/main_workflow_schema.json):

    • Added args field definition for both github and playwright tools
    • Field is optional array of strings with descriptive documentation
  5. Validation fix (pkg/workflow/mcp-config.go):

    • Excluded args from MCP-defining fields in getRawMCPConfig()
    • This prevents built-in tools from being incorrectly treated as custom MCP tools
    • Added comprehensive comments explaining the consequences
  6. Comprehensive tests (pkg/workflow/args_field_test.go):

    • 5 test cases covering extraction, parser integration, and combined usage
    • Validates args work correctly with version field
    • All tests passing ✅
  7. Documentation:

    • Updated docs/src/content/docs/reference/tools.md with detailed args configuration examples
    • Updated .github/instructions/github-agentic-workflows.instructions.md with args usage patterns
    • Added examples for GitHub and Playwright tools
    • Documented common use cases (debugging flags, testing scenarios)
    • Noted special character escaping behavior
    • Clarified that only Chromium browser is supported
  8. Test Workflows:

    • pkg/cli/workflows/test-github-args.md - Demonstrates GitHub tool args with --verbose flag
    • pkg/cli/workflows/test-playwright-args.md - Demonstrates Playwright args with browser selection
    • pkg/cli/workflows/test-args-special-chars.md - Tests special character escaping (spaces, key=value formats)
    • All test workflows compile successfully and generate proper MCP configurations

Code Organization:

  • Created new pkg/workflow/args.go file with all args-related helper functions
  • Removed duplicate extraction logic from pkg/workflow/mcps.go
  • Centralized YAML writing logic with proper quoting in helper functions
  • Cleaner, more maintainable codebase with single source of truth for args handling

Test results:

  • ✅ All unit tests passing (3.6s)
  • ✅ Build successful
  • ✅ Linting passed
  • ✅ All 47 workflow files compiled successfully (including new test workflows)
  • ✅ Special character escaping verified
  • ✅ Code review addressed
  • ✅ Documentation complete
  • ✅ Test workflows validated

Usage example:

---
on: workflow_dispatch
engine: claude
tools:
  github:
    version: "v2.0.0"
    args: ["--custom-flag", "--verbose"]
  playwright:
    allowed_domains: ["example.com"]
    args: ["--browser", "chromium"]
---

# My Workflow
The custom args will be appended to the MCP server commands with proper escaping.

Documentation and Examples:

Users can reference:

  • Tools Reference: docs/src/content/docs/reference/tools.md - Detailed args configuration guide
  • Instructions: .github/instructions/github-agentic-workflows.instructions.md - Args usage patterns
  • Test Workflows: pkg/cli/workflows/test-*-args.md - Working examples demonstrating various args configurations
Original prompt

Add support for optimal "args" argument for github and playwright tools in the frontmatter.

The args is a string array and gets appended to the generated command in the MCP server configuration file if present.

This argument allows further customizations of the behavior of those MCPs.


💬 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>
@pelikhan
Copy link
Copy Markdown
Collaborator

pelikhan commented Oct 1, 2025

@copilot use proper quoting when generating the yaml with args. Look for existing helpers or use Go quoted string format support.

Copilot AI and others added 2 commits October 1, 2025 16:02
…ywright

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title Add support for optimal "args" argument for github and playwright tools in the frontmatter. The args is a string array and gets appended to the generated command in the MCP server configuration file if present. This argument allows further customizat... Add args support for github and playwright tools in frontmatter Oct 1, 2025
Copilot AI requested a review from pelikhan October 1, 2025 16:07
Comment thread pkg/workflow/mcps.go Outdated

// getPlaywrightCustomArgs extracts custom args from Playwright tool configuration
func getPlaywrightCustomArgs(playwrightTool any) []string {
if toolConfig, ok := playwrightTool.(map[string]any); ok {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot create helper function to extract args, move to args.go

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Created pkg/workflow/args.go with helper function extractCustomArgs() that consolidates the extraction logic. Moved getGitHubCustomArgs() and getPlaywrightCustomArgs() to use this shared helper (commit 157012c).

Comment thread pkg/workflow/mcps.go Outdated

// getGitHubCustomArgs extracts custom args from GitHub tool configuration
func getGitHubCustomArgs(githubTool any) []string {
if toolConfig, ok := githubTool.(map[string]any); ok {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot use custom helper

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated to use extractCustomArgs() helper function from args.go (commit 157012c).

Comment thread pkg/workflow/custom_engine.go Outdated
…ration

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Oct 1, 2025

@copilot use proper quoting when generating the yaml with args. Look for existing helpers or use Go quoted string format support.

Updated to use json.Marshal for proper quoting and escaping of args in all engine renderers (commit 58cf0fe). This handles special characters including spaces, quotes, backslashes, tabs, and newlines correctly.

…elper functions

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review October 1, 2025 16:31
@pelikhan
Copy link
Copy Markdown
Collaborator

pelikhan commented Oct 1, 2025

@copilot

  • update documentation
  • add test agentic workflows for these features

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan
Copy link
Copy Markdown
Collaborator

pelikhan commented Oct 1, 2025

@copilot only chromium available in headless mode, do not use in documentation samples

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Oct 1, 2025

@copilot

  • update documentation
    ...

Added documentation and test workflows (commits 0533fd8, 5b081a7):

Documentation:

  • Updated docs/src/content/docs/reference/tools.md with args examples for GitHub and Playwright
  • Updated .github/instructions/github-agentic-workflows.instructions.md with args usage patterns

Test Workflows:

  • test-github-args.md - Tests GitHub tool args with --verbose flag
  • test-playwright-args.md - Tests Playwright args with --browser chromium
  • test-args-special-chars.md - Tests special character escaping (spaces, key=value)

All workflows compile successfully and generate proper MCP configurations with escaped args.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Oct 1, 2025

@copilot only chromium available in headless mode, do not use in documentation samples

Removed --headless flag from documentation examples and added note clarifying that only Chromium is available in headless mode (commit 8f7b644).

playwright:
version: "latest" # Optional: Playwright version
allowed_domains: ["defaults", "github", "*.custom.com"] # Domain access control
args: ["--browser", "firefox"] # Optional: additional command-line arguments
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot remove this line

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed the args line from Playwright Configuration Options section (commit 5ac2a96).

- Browser selection: `["--browser", "firefox"]` or `["--browser", "chromium"]`
- Custom flags for debugging or testing scenarios

**Note**: Only Chromium is available in headless mode.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot remove mention of choosing browser, only chromium is supported

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed browser selection examples and updated note to clarify that only Chromium browser is supported (commit 5ac2a96).

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI requested a review from pelikhan October 1, 2025 17:07
@pelikhan pelikhan merged commit 31ece23 into main Oct 1, 2025
@pelikhan pelikhan deleted the copilot/fix-029c513d-394a-4ff4-ae62-eea332504e83 branch October 1, 2025 18:11
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