Add 'add' tool to mcp-server command#3447
Conversation
|
@copilot continue working |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Completed! Added the The tool wraps the
All tests pass and no security issues were found. The tool is listed in the help text and available via MCP protocol. |
|
|
||
| Workflow specifications: | ||
| - Two parts: "owner/repo[@version]" (lists available workflows in the repository) | ||
| - Three parts: "owner/repo/workflow-name[@version]" (implicitly looks in workflows/ directory) | ||
| - Four+ parts: "owner/repo/workflows/workflow-name.md[@version]" (requires explicit .md extension) | ||
| - Wildcard: "owner/repo/*[@version]" (adds all workflows from the repository) | ||
| - Version can be tag, branch, or SHA | ||
|
|
||
| Examples: | ||
| - ["githubnext/agentics"] - List available workflows | ||
| - ["githubnext/agentics/ci-doctor"] - Add specific workflow | ||
| - ["githubnext/agentics/ci-doctor@v1.0.0"] - Add with version | ||
| - ["githubnext/agentics/*"] - Add all workflows | ||
|
|
||
| The tool will: | ||
| 1. Install the required repository if not already installed | ||
| 2. Copy the workflow file(s) to .github/workflows/ | ||
| 3. Update .gitattributes to exclude .lock.yml files from diffs | ||
| 4. Compile the workflow to generate .lock.yml file | ||
|
|
||
| Note: This tool does not support PR creation (--pr flag) or interactive mode.`, |
There was a problem hiding this comment.
Removed verbose description text in commit 591d7b9. The tool description is now concise and matches the style of other MCP server tools: "Add workflows from remote repositories to .github/workflows"
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot remove force, verbose, append arguments from tool signature |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR adds MCP server support for the add command, enabling AI agents to add workflows from remote repositories through the Model Context Protocol.
Key changes:
- Adds new "add" tool to the MCP server that wraps the CLI
addcommand - Implements basic parameter support for workflows, number of copies, and custom naming
- Includes comprehensive integration tests to verify tool exposure and invocation
- Updates the expected tools list in existing tests
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| pkg/cli/mcp_server.go | Adds the "add" tool to MCP server with argument handling and command execution wrapper |
| pkg/cli/mcp_server_add_test.go | New integration tests verifying the add tool is properly exposed and functional via MCP |
| pkg/cli/mcp_server_test.go | Updates expected tools list to include the new "add" tool |
| .github/workflows/go.mod | Minor formatting cleanup (removes empty require block, reorders go version) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| type addArgs struct { | ||
| Workflows []string `json:"workflows" jsonschema:"Workflows to add (e.g., 'owner/repo/workflow-name' or 'owner/repo/workflow-name@version')"` | ||
| Number int `json:"number,omitempty" jsonschema:"Create multiple numbered copies (corresponds to -c flag, default: 1)"` | ||
| Name string `json:"name,omitempty" jsonschema:"Specify name for the added workflow - without .md extension (corresponds to -n flag)"` | ||
| } |
There was a problem hiding this comment.
The MCP add tool is missing support for several important CLI flags that are available in the add command:
--engine/-a- Override AI engine (claude, codex, copilot, custom)--pr- Create a pull request with the workflow changes--force- Overwrite existing workflow files--append- Append extra content to the end of agentic workflow on installation--no-gitattributes- Skip updating .gitattributes file
These flags provide important functionality that MCP users may need, particularly --pr and --force which are commonly used. Consider adding these as optional parameters in the addArgs struct to provide feature parity with the CLI command.
| Description: "Add workflows from remote repositories to .github/workflows", | ||
| }, func(ctx context.Context, req *mcp.CallToolRequest, args addArgs) (*mcp.CallToolResult, any, error) { |
There was a problem hiding this comment.
The tool description is too brief and doesn't provide enough context for AI agents using this tool. Following the pattern from other tools in this file (e.g., status, logs, mcp-inspect), the description should include:
- Examples of workflow specifications (e.g., "owner/repo/workflow-name" or "owner/repo/workflow-name@version")
- Explanation of what happens when just a repository is specified (lists available workflows)
- Information about version specifications (tag, branch, or SHA)
- Details about the workflow file destination (.github/workflows)
Example:
Description: `Add workflows from remote repositories to .github/workflows.
Workflow specifications:
- Two parts: "owner/repo[@version]" (lists available workflows in the repository)
- Three parts: "owner/repo/workflow-name[@version]" (implicitly looks in workflows/ directory)
- Four+ parts: "owner/repo/workflows/workflow-name.md[@version]" (requires explicit .md extension)
- GitHub URL: "https://github.com/owner/repo/blob/branch/path/to/workflow.md"
- Wildcard: "owner/repo/*[@version]" (adds all workflows from the repository)
- Version can be tag, branch, or SHA
The number parameter creates multiple numbered copies of the workflow.
The name parameter specifies a custom name for the added workflow file (without .md extension).`,| Description: "Add workflows from remote repositories to .github/workflows", | |
| }, func(ctx context.Context, req *mcp.CallToolRequest, args addArgs) (*mcp.CallToolResult, any, error) { | |
| Description: `Add workflows from remote repositories to .github/workflows. |
| Workflows []string `json:"workflows" jsonschema:"Workflows to add (e.g., 'owner/repo/workflow-name' or 'owner/repo/workflow-name@version')"` | ||
| Number int `json:"number,omitempty" jsonschema:"Create multiple numbered copies (corresponds to -c flag, default: 1)"` | ||
| Name string `json:"name,omitempty" jsonschema:"Specify name for the added workflow - without .md extension (corresponds to -n flag)"` |
There was a problem hiding this comment.
The JSON schema descriptions for the arguments should be more detailed to help AI agents understand how to use them properly:
Workflows- Should explain the format options (owner/repo, owner/repo/workflow-name, with optional @Version, etc.)Number- Should clarify that it corresponds to the-cflag and creates multiple numbered copiesName- Should clarify that it should not include the .md extension
Example:
Workflows []string `json:"workflows" jsonschema:"Workflow specifications to add (e.g., 'owner/repo', 'owner/repo/workflow-name', 'owner/repo/workflow-name@version', or GitHub URL). Specify just 'owner/repo' to list available workflows."`
Number int `json:"number,omitempty" jsonschema:"Create multiple numbered copies of the workflow (corresponds to -c flag, default: 1)"`
Name string `json:"name,omitempty" jsonschema:"Custom name for the added workflow file without .md extension (corresponds to -n flag). Only applies to the first workflow when adding multiple."`| Workflows []string `json:"workflows" jsonschema:"Workflows to add (e.g., 'owner/repo/workflow-name' or 'owner/repo/workflow-name@version')"` | |
| Number int `json:"number,omitempty" jsonschema:"Create multiple numbered copies (corresponds to -c flag, default: 1)"` | |
| Name string `json:"name,omitempty" jsonschema:"Specify name for the added workflow - without .md extension (corresponds to -n flag)"` | |
| Workflows []string `json:"workflows" jsonschema:"Workflow specifications to add (e.g., 'owner/repo', 'owner/repo/workflow-name', 'owner/repo/workflow-name@version', or GitHub URL). Specify just 'owner/repo' to list available workflows."` | |
| Number int `json:"number,omitempty" jsonschema:"Create multiple numbered copies of the workflow (corresponds to -c flag, default: 1)"` | |
| Name string `json:"name,omitempty" jsonschema:"Custom name for the added workflow file without .md extension (corresponds to -n flag). Only applies to the first workflow when adding multiple."` |
This PR adds the
addtool to the MCP server command, allowing users to add workflows from remote repositories through the MCP protocol.Changes Made
Added
addtool to MCP server (pkg/cli/mcp_server.go):addArgsstruct with minimal parameters: workflows (required), number, and nameaddCLI command with appropriate argumentsaddtoolUpdated existing tests (
pkg/cli/mcp_server_test.go):TestMCPServer_ListToolsto includeaddin the expected tools listAdded new integration tests (
pkg/cli/mcp_server_add_test.go):TestMCPServer_AddTool: Verifies theaddtool is exposed with proper descriptionTestMCPServer_AddToolInvocation: Tests actual tool invocation with workflows parameterTool Parameters
The
addtool supports the following minimal parameters:workflows(required): Array of workflow specifications to add (e.g., 'owner/repo/workflow-name' or 'owner/repo/workflow-name@version')number: Create multiple numbered copies (corresponds to -c flag)name: Specify custom name for the workflow (corresponds to -n flag)Testing
make test-unitTestMCPServer_AddToolmake lintmake fmtThe tool is fully functional and follows the same patterns as other tools in the MCP server (status, compile, logs, audit, mcp-inspect).
Original prompt
💡 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.