feat(mcp): add run and run_stop tools to the MCP server - #3998
Open
Ankitsinghsisodya wants to merge 4 commits into
Open
feat(mcp): add run and run_stop tools to the MCP server#3998Ankitsinghsisodya wants to merge 4 commits into
run and run_stop tools to the MCP server#3998Ankitsinghsisodya wants to merge 4 commits into
Conversation
- Introduced 'run' tool for executing Functions locally, including detailed usage instructions. - Added 'run_stop' tool to stop Functions that were started with 'run'. - Updated documentation to reflect these new tools and their parameters. - Enhanced server structure to track active local runs. This update enhances the local development experience by allowing users to run and manage Functions directly from the MCP server.
- Updated formatting in mcp.go for better readability. - Replaced b.WriteString with fmt.Fprintf in process_test.go for consistency in string formatting. - Added missing newline at the end of tools_run_test.go to adhere to file formatting standards. These changes enhance code clarity and maintainability across the MCP package.
|
[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 |
Ankitsinghsisodya
marked this pull request as draft
August 7, 2026 19:25
lkingland
reviewed
Aug 10, 2026
lkingland
left a comment
Member
There was a problem hiding this comment.
Love that this one is starting to show why an MCP server helps do things a simple skill cannot do as elegantly.
Small suggestions around error and exit code handling below:
- Updated documentation to clarify that local operations (run/stop) are allowed even in read-only mode. - Improved the handling of function runs, ensuring that stopping a function with no active run is idempotent and succeeds without error. - Refactored the run registry to support reserving and activating function paths, preventing concurrent run conflicts. - Adjusted the run and run_stop tools to reflect the new behavior and requirements for absolute paths. These changes improve the usability of the MCP server for local function management while maintaining safety in read-only environments.
Ankitsinghsisodya
marked this pull request as ready for review
August 10, 2026 19:59
- Replaced hardcoded temporary paths with a new utility function `testAbsPath` to ensure platform-native absolute paths are used in tests for the 'run' and 'run_stop' tools. - This change enhances compatibility across different operating systems and improves the reliability of function execution in tests. These updates contribute to better path management in the MCP server's local function tools.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds two new MCP tools that let clients start and stop a Function locally through the MCP server, mirroring
func run:run— builds the Function if needed, starts it in the background, and returns once it's ready with itspidandurl. Accepts optionalpath,registry,build, andportparameters. Only one run is allowed per Function path at a time.run_stop— gracefully stops a Function previously started withrun(SIGTERM, then SIGKILL after a grace period), matched by the same absolutepath.Both tools are disabled when the server is running in read-only mode, consistent with
deploy/delete.Implementation details
pkg/mcp/process.go: newprocessStarterabstraction that spawnsfunc run --jsonas a subprocess, parses its stdout for a JSON readiness line (host/port), and returns astopfunc to terminate it. Also introduces arunRegistryto track active runs keyed by function path.pkg/mcp/tools_run.go/pkg/mcp/tools_run_stop.go: tool definitions, input/output schemas, and handlers forrunandrun_stop.pkg/mcp/mock/process_starter.go: mockprocessStarterfor tests, injected via newWithProcessStarterserver option.pkg/mcp/mcp.go: wires up the new tools and default process starter/run registry on the server.pkg/mcp/instructions.md/pkg/mcp/instructions_warning.md: document the new tools' usage/path requirements and note them as disabled in read-only mode.Test plan
make test— new unit tests inpkg/mcp/process_test.go,pkg/mcp/tools_run_test.go, andpkg/mcp/tools_run_stop_test.gocover readonly rejection, duplicate-run rejection, start errors, and stop success/failure paths using the mock process starter.make check