MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / executeCode

Function executeCode

packages/hosts/mcp/src/tool-server.ts:767–810  ·  view source on GitHub ↗
(code: string)

Source from the content-addressed store, hash-verified

765 ).pipe(Effect.withSpan("mcp.host.create_server"));
766
767 const executeCode = (code: string): Effect.Effect<McpToolResult, E> =>
768 Effect.gen(function* () {
769 debugLog("execute.call", {
770 elicitationMode: elicitationMode.mode,
771 elicitationSupport: getElicitationSupport(server),
772 clientCapabilities: server.server.getClientCapabilities() ?? null,
773 codeLength: code.length,
774 });
775 if (elicitationMode.mode === "native") {
776 const result = yield* engine.execute(code, {
777 onElicitation: makeMcpElicitationHandler(server, debugLog),
778 });
779 return toMcpResult(result);
780 }
781 const outcome = yield* engine.executeWithPause(code);
782 debugLog("execute.paused_flow_result", {
783 status: outcome.status,
784 executionId: outcome.status === "paused" ? outcome.execution.id : undefined,
785 interactionKind:
786 outcome.status === "paused"
787 ? pausedInteractionKind(outcome.execution.elicitationContext.request)
788 : undefined,
789 });
790 if (outcome.status === "paused") {
791 const deadline = pauseDeadline();
792 yield* Effect.annotateCurrentSpan({
793 "mcp.execute.paused": true,
794 "mcp.execute.paused_execution_id": outcome.execution.id,
795 "mcp.execute.pause_source": "execute",
796 });
797 yield* onExecutionPaused(outcome.execution.id, deadline);
798 return elicitationMode.mode === "browser"
799 ? yield* requireUserResumeApproval(outcome.execution.id)
800 : toMcpPausedResult(formatPausedExecution(outcome.execution, { deadline }));
801 }
802 return toMcpResult(outcome.result);
803 }).pipe(
804 Effect.withSpan("mcp.host.tool.execute", {
805 attributes: {
806 "mcp.tool.name": "execute",
807 "mcp.execute.code_length": code.length,
808 },
809 }),
810 );
811
812 const resumeExecution = (
813 executionId: string,

Callers 1

createExecutorMcpServerFunction · 0.70

Calls 11

formatPausedExecutionFunction · 0.90
debugLogFunction · 0.85
getElicitationSupportFunction · 0.85
toMcpResultFunction · 0.85
pausedInteractionKindFunction · 0.85
pauseDeadlineFunction · 0.85
onExecutionPausedFunction · 0.85
toMcpPausedResultFunction · 0.85
executeMethod · 0.65

Tested by

no test coverage detected