mcp: add invoke tool to test deployed Functions from agent context#3739
mcp: add invoke tool to test deployed Functions from agent context#3739thonmay wants to merge 1 commit into
Conversation
Adds a new MCP 'invoke' tool that wraps 'func invoke', completing the end-to-end Function lifecycle exposed to agents: create -> build -> deploy -> invoke The tool supports all non-interactive flags: path, target (local/ remote/URL), format (http/cloudevent), id, source, type, data, content-type, request-type, file, insecure, and verbose. All fields are optional; with no arguments the function in the current working directory is invoked with auto-discovered target. ReadOnlyHint is false because invoking a function can have side effects within the function itself. IdempotentHint is false for the same reason. Fixes knative#3727 Signed-off-by: Thonmay <mdthoriqulislam384@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: thonmay The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @thonmay. 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 Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
|
🦴 CAVEMAN REVIEWER HAVE QUESTIONS 🦴 Thank for contribution. Before review, answer these. No answer, no review. 1. Explain
2. Why
3. Readonly guard
4. Testing
5. Understanding
We welcome all contributors. But change must be understood by author and solve real problem. PRs that no demonstrate this — closed. |
|
1. Explain Wraps Same pattern as describe/list. No readonly check (doesn't mutate cluster). 2. Why MCP workflow today: create → build → deploy → ??? Agent deployed a Function. Wants to verify it works. Without invoke:
Why not raw HTTP?
3. Readonly guard Correction: the tool sets ReadOnlyHint: true, // Invoke does not mutate cluster state
IdempotentHint: false, // Repeated invocations may produce different resultsNo Invoke sends HTTP to an already-deployed Function. Function might have side effects (DB write), but that's the Function's business logic, not a cluster mutation. Readonly server should allow invoke. 4. Testing Ran locally:
Screenshots attached. 5. Understanding Same architecture as #3736. Tool var + handler + executor. Only design choice specific to invoke: No merge = no verification step after deploy. Agentic workflow incomplete. |


Changes
Adds a new MCP
invoketool that wrapsfunc invoke, completing the end-to-end Function lifecycle exposed to agents:Previously, after deploying a Function via MCP, agents had no MCP-native way to validate the deployment. They had to fall back to external shell commands or manual HTTP requests outside the MCP workflow.
Tool behavior
path,target(local/remote/URL),format(http/cloudevent),id,source,type,data,content-type,request-type,file,insecure,verbose--confirmand--saveare intentionally excluded (interactive-only flags not meaningful in agent context)Annotations
ReadOnlyHint: false— invoking a function can have side effects within the function itselfIdempotentHint: false— repeated invocations may produce different resultsTests added (4)
TestTool_Invoke_Args— all 10 string flags + 2 bool flags passed correctly, arg count validatedTestTool_Invoke_NoArgs— no args invokes with 0 CLI args (cwd-based)TestTool_Invoke_RemoteTarget—--target remotepassed correctlyTestTool_Invoke_BinaryFailure— executor error propagated as MCP error with binary output included/kind enhancement
Fixes #3727