Skip to content

mcp: add config_git_set and config_git_remove tools#3818

Open
Ankitsinghsisodya wants to merge 4 commits into
knative:mainfrom
Ankitsinghsisodya:feat/mcp-config-git-tools
Open

mcp: add config_git_set and config_git_remove tools#3818
Ankitsinghsisodya wants to merge 4 commits into
knative:mainfrom
Ankitsinghsisodya:feat/mcp-config-git-tools

Conversation

@Ankitsinghsisodya
Copy link
Copy Markdown
Contributor

@Ankitsinghsisodya Ankitsinghsisodya commented May 21, 2026

Summary

Adds two MCP tools — config_git_set and config_git_remove — to configure Git source repository settings for pipeline-based Function builds. This completes the config tool group alongside the existing volumes, labels, and envs tools.

Note: This is a re-submission of #3795, which was accidentally closed when the head repository was deleted.

Changes

  • pkg/mcp/tools_config_git.go — two tools following the existing config_* pattern:
    • config_git_set: configures Git URL, branch, subdirectory, and optional Pipelines-as-Code (PAC) resources on the Function. Requires path, git_url, and git_branch. Defaults git_dir to "." to avoid the CLI's interactive prompt when no subdirectory is needed. Automatically injects --config-local when no config_* flags are provided to prevent the webhook confirmation prompt in a non-TTY subprocess.
    • config_git_remove: removes Git settings and associated pipeline resources from a Function. Automatically injects --delete-local when neither delete_local nor delete_cluster is set, preventing the interactive "delete all?" prompt.
  • pkg/mcp/tools_config_git_test.go — nine unit tests covering args, defaults, anti-hang behavior, and error propagation.
  • pkg/mcp/mcp.go — registers both tools and three help resources (func://help/config/git, func://help/config/git/set, func://help/config/git/remove).
  • pkg/mcp/instructions.md — adds config_git_set / config_git_remove agent guidance covering required fields, PAC resource flags, GitHub token requirements, and destructive-operation warning for delete_cluster.

Notes

  • No config_git_list tool is added because func config git (the root command) currently prints "Not implemented yet." and provides no useful output. Git settings can be inspected via the func://function resource which exposes the full func.yaml state.

Test plan

  • make test passes
  • make check passes
  • Manual: call config_git_set with path, git_url, git_branch and confirm func.yaml is updated with Git config
  • Manual: call config_git_remove with path only and confirm local pipeline resources are cleaned up without prompting

…ntation

- Introduced `config_git_set` tool to configure Git repository settings for pipeline builds, including required parameters like `git_url` and `git_branch`, and optional flags for local and cluster configurations.
- Added `config_git_remove` tool to remove Git settings and associated resources, with options to delete local files and cluster credentials.
- Updated documentation in `instructions.md` to include usage details for both tools.
- Implemented unit tests for `config_git_set` and `config_git_remove` to ensure correct argument handling and error propagation.
- Adjusted field alignment in the ConfigGitSetInput struct for improved readability and consistency.
- No functional changes were made; this commit focuses on code clarity and maintainability.
- Corrected the documentation in instructions.md to clarify the optional parameters for pipeline resource creation.
- Enhanced the argument validation in tools_config_git.go to ensure that the `git-dir` parameter is not set to empty or whitespace, preventing unintended CLI prompts.
- Added a test case in tools_config_git_test.go to verify that at least two arguments are provided for the `configGitRemove` command, improving robustness in argument handling.
- Updated the error handling in TestTool_ConfigGitSet_MissingGitURL and TestTool_ConfigGitSet_MissingGitBranch to return instead of calling t.Fatal when a protocol-level error occurs, allowing for more graceful test failures.
- Added comments to clarify the expected behavior of the MCP SDK regarding required schema fields validation.
Copilot AI review requested due to automatic review settings May 21, 2026 11:04
@knative-prow knative-prow Bot requested review from dsimansk and jrangelramos May 21, 2026 11:04
@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented May 21, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Ankitsinghsisodya
Once this PR has been reviewed and has the lgtm label, please assign gauron99 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow Bot added size/XL 🤖 PR changes 500-999 lines, ignoring generated files. needs-ok-to-test 🤖 Needs an org member to approve testing labels May 21, 2026
@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented May 21, 2026

Hi @Ankitsinghsisodya. Thanks for your PR.

I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds MCP support for configuring and removing Git pipeline settings on a Function by wrapping func config git set/remove, with safeguards to avoid interactive CLI prompts in non-TTY execution.

Changes:

  • Introduces config_git_set and config_git_remove MCP tools with argument-building that avoids interactive hangs.
  • Registers new tools and help resources in the MCP server.
  • Adds documentation and comprehensive tests for argument forwarding, defaults, and error paths.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
pkg/mcp/tools_config_git.go Implements new Git config tools, argument building, and handlers
pkg/mcp/tools_config_git_test.go Adds tests for correct argument forwarding, defaults, and error propagation
pkg/mcp/mcp.go Registers the new tools and related help resources
pkg/mcp/instructions.md Documents how/when to call the new tools and required/optional params

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

ConfigLocal *bool `json:"config_local,omitempty" jsonschema:"Create local pipeline template files in the Function directory (default: true when no config flags are set)"`
ConfigCluster *bool `json:"config_cluster,omitempty" jsonschema:"Create pipeline credentials and config on the cluster"`
ConfigRemote *bool `json:"config_remote,omitempty" jsonschema:"Configure a webhook on the remote Git provider (requires gh_access_token for GitHub)"`
GhAccessToken *string `json:"gh_access_token,omitempty" jsonschema:"GitHub Personal Access Token for webhook creation (scope: public_repo or repo, admin:repo_hook for automatic webhook setup)"`
args = appendBoolFlag(args, "--config-remote", i.ConfigRemote)
}

args = appendStringFlag(args, "--gh-access-token", i.GhAccessToken)

out, err := s.executor.Execute(ctx, "config", input.Args()...)
if err != nil {
err = fmt.Errorf("%w\n%s", err, string(out))
Comment on lines +45 to +49
// After "git set": --path, path, --git-url, url, --git-branch, branch, --git-dir, dir = 8 args
// + --config-local (1) + --verbose (1) = 10 args after "git set"
remaining := args[2:]
validateStringFlags(t, remaining, stringFlags)
validateBoolFlags(t, remaining, boolFlags)
@lkingland lkingland added ok-to-test 🤖 Non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test 🤖 Needs an org member to approve testing labels May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test 🤖 Non-member PR verified by an org member that is safe to test. size/XL 🤖 PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants