mcp: add logs tool to retrieve deployed Function logs#3794
mcp: add logs tool to retrieve deployed Function logs#3794Ankitsinghsisodya wants to merge 2 commits into
Conversation
- Introduced a new 'logs' tool to fetch recent logs from deployed functions. - Updated documentation to include usage instructions for the logs command. - Added tests to ensure correct argument handling and mutual exclusivity between path and name parameters. This enhancement allows users to diagnose function behavior by accessing logs, improving the overall usability of the MCP tools.
|
[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 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. |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a new MCP tool (logs) to retrieve deployed Function logs via the server’s executor, along with help/resource wiring and documentation updates.
Changes:
- Introduces
logstool implementation (LogsInput→ CLI args; handler executesfunc logs) - Registers the tool and a corresponding help resource in the MCP server
- Adds tool usage documentation and comprehensive argument-passing tests
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pkg/mcp/tools_logs.go | Implements the logs tool, input/output types, and handler logic. |
| pkg/mcp/tools_logs_test.go | Adds tests covering args by path/name, mutual exclusivity, and no-args behavior. |
| pkg/mcp/mcp.go | Registers the logs tool and adds a help/logs resource. |
| pkg/mcp/instructions.md | Documents how/when to use the new logs tool. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3794 +/- ##
==========================================
+ Coverage 45.41% 54.28% +8.86%
==========================================
Files 200 201 +1
Lines 23426 23794 +368
==========================================
+ Hits 10640 12916 +2276
+ Misses 11843 9613 -2230
- Partials 943 1265 +322
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:
|
…xclusivity - Revised the logs tool description to clarify the usage of the 'since' argument. - Updated error message in logsHandler to indicate that 'path' and 'name' are mutually exclusive, allowing for at most one instead of exactly one. These changes enhance the clarity of the tool's documentation and improve user feedback on input errors.
Summary
Adds a
logsMCP tool that lets agents retrieve logs from a deployedFunction. This closes the observe gap in the agentic workflow: an agent
can now deploy a Function, invoke it, and immediately inspect its logs
without leaving the MCP context.
Changes
pkg/mcp/tools_logs.go— newlogstool withLogsInput/LogsOutputtypes andlogsHandler. Supports identification bypath(readsfunc.yaml) or byname, with optionalnamespace,since(time window, e.g.5m,1h), andverboseflags.Enforces mutual exclusion of
pathandnameat the handler level.Marked
ReadOnlyHint: trueandDestructiveHint: false.pkg/mcp/tools_logs_test.go— four unit tests following theexisting tool test pattern:
TestTool_Logs_Args_ByPath— all flags via pathTestTool_Logs_Args_ByName— identification by function nameTestTool_Logs_MutuallyExclusive— bothpath+name→ errorTestTool_Logs_NoArgs— no args falls through to CLI default (server cwd)pkg/mcp/mcp.go— registers thelogstool and thefunc://help/logshelp resource alongside the existing tools.pkg/mcp/instructions.md— adds### logsagent guidance andfunc://help/logsto the pre-invocation checklist.Test plan
make testpassesmake checkpassesfunc mcp start→ calllogstool with a deployedFunction path and confirm log output is returned
logswith bothpathandnameset → confirmerror is returned without executing the command