Repository navigation
feat(mcp): passthrough invoke calls the tool directly, without a dynamic worker - #36
Merged
Merged
Conversation
…mic worker invoke used to run generated one-line code through engine.execute, which starts a new sandbox (a billed dynamic worker on Cloudflare) only to RPC back into the host. ExecutionEngine now has a required call(address, args) member that runs the same tool invoker in the host and returns the same ExecuteResult shape, so policy, approval, credentials, error mapping and result rendering stay the same. Decorators (gate, rate limit, usage, analytics, promise facade, read-only platform engine) forward and count it like execute. passthroughCallCode is removed.
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.
What changes for users
Passthrough
invoke(the tool Skywardin uses for every integration call) now calls the tool directly in the host. It no longer starts a new Cloudflare Dynamic Worker for each call.isError, same error texts for blocked tools, invalid arguments, declined approvals and plugin defects.invokecreated one billed Dynamic Worker (executor-<random UUID>). That was about 19% of our billed Dynamic Workers (measured Oct 15-21).Why it is safe
Policy, approval, credentials and the real upstream call already ran in the host through the tool invoker. The Dynamic Worker only ran a server-generated one-line script (
return await tools["x"](args)) withglobalOutbound: nullthat called back into the host. It isolated nothing. Upstream v2 has the same design (a directcalltool).How
ExecutionEngine.call(address, args, { onElicitation }): required member, runsmakeExecutorToolInvokerin anmcp.executespan (mcp.execute.mode: "direct"), mapsExecutionToolErrorto the sametool_errorresult the sandbox returned.tool-server.ts: invoke usesengine.call. Visibility check, schema validation, elicitation,toPassthroughResultunchanged.passthroughCallCoderemoved.call(analytics, promise surface, execution-stack middleware, cloud gate/usage/rate limit) and 13 test stub engines.Behaviour differences
invoke.tool_blockeddetails now serialize withaddress/pattern(structured clone used to drop them). Message text unchanged.executor.code.execspans no longer appear forinvoke.Tests
engine.call: success + toolPaths, block policy, declined approval, opaque plugin defect, binary result; each with a code executor that dies if called.createExecutionEnginewith a throwing code executor: ToolFile renders the same JSON text and structuredContent.Verified against production with a before/after benchmark (13 read-only tools, error cases, concurrency stress); results in the Skyward PR.