mcp: populate Image and URL structured output fields#3681
mcp: populate Image and URL structured output fields#3681Ankitsinghsisodya wants to merge 1 commit intoknative:mainfrom
Conversation
- Introduced TestTool_Build_StructuredOutput to verify that the Image field is correctly populated from the .func/built-image file after a successful build. - Added TestTool_Build_StructuredOutput_NoFuncYaml to ensure that a missing func.yaml does not cause failures, resulting in an empty Image field. - Implemented TestParseDeployedURL to validate URL extraction from various deploy output formats. - Created TestTool_Deploy_StructuredOutput to confirm that the URL is correctly populated from parsed output after deployment. These tests enhance coverage for the build and deploy functionalities, ensuring proper handling of structured outputs.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Ankitsinghsisodya 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 @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 Tip We noticed you've done this a few times! Consider joining the org to skip this step and gain 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. |
|
/ok-to-test |
There was a problem hiding this comment.
Pull request overview
Fixes MCP build and deploy tool handlers so their structured outputs (image, url) are actually populated (instead of requiring clients to scrape the raw message text).
Changes:
- Populate
BuildOutput.Imageby reloading the function afterfunc buildand reading.func/built-imageviafn.NewFunction(...).Build.Image. - Populate
DeployOutput.URLby parsing combined command output, and populateDeployOutput.Imageby reloading the function and readingf.Deploy.Image. - Add unit tests for URL parsing and end-to-end structured output assertions for both tools.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pkg/mcp/tools_build.go | Populate BuildOutput.Image from reloaded function state after build. |
| pkg/mcp/tools_build_test.go | Add tests asserting structured image output (including missing func.yaml case). |
| pkg/mcp/tools_deploy.go | Add URL parsing and populate structured url/image fields after deploy. |
| pkg/mcp/tools_deploy_test.go | Add table tests for URL parsing and an end-to-end structured url output test. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| scanner := bufio.NewScanner(bytes.NewReader(out)) | ||
| urlNext := false | ||
| for scanner.Scan() { |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3681 +/- ##
==========================================
+ Coverage 56.92% 56.97% +0.04%
==========================================
Files 181 181
Lines 20933 20958 +25
==========================================
+ Hits 11916 11940 +24
Misses 7809 7809
- Partials 1208 1209 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
What
The
buildanddeployMCP tool handlers declared structured output fields(
image,url) that were never populated — only the rawmessagestring wasset. Agents inspecting the structured response to learn the deployed URL or
built image name always received empty strings and had to parse raw text instead.
Why
Structured output fields exist so MCP clients can consume typed values without
text scraping. Empty fields make the schema misleading and break any agent that
relies on them.
How
tools_build.go— afterfunc buildexits, reload the function from diskand read
f.Build.Image. The build CLI writes the final image reference (withdigest) to
.func/built-image;fn.NewFunctionpicks it up viagetLastBuiltImage().tools_deploy.go— two changes:parseDeployedURLto extract the route URL from combined stdout. Handlesboth the local-deploy format (
exposed at URL:\n <url>) and the remotepipeline format (
Function Deployed at <url>).f.Deploy.Imagefromfunc.yaml(where the deploy step persists it).Tests
TestTool_Build_StructuredOutput— verifiesImageis read from.func/built-imageafter a successful build.TestTool_Build_StructuredOutput_NoFuncYaml— verifies that a missingfunc.yamldoes not cause the handler to fail;Imageis empty but noerror is returned.
TestParseDeployedURL— table-driven coverage of both output formats,surrounding noise, and the empty / no-URL cases.
TestTool_Deploy_StructuredOutput— end-to-end: mock executor returnslocal-deploy output; asserts
URLis correctly extracted.