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

Function executeCode

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

Source from the content-addressed store, hash-verified

638 ).pipe(Effect.withSpan("mcp.host.create_server"));
639
640 const executeCode = (code: string): Effect.Effect<McpToolResult, E> =>
641 Effect.gen(function* () {
642 debugLog("execute.call", {
643 elicitationMode: elicitationMode.mode,
644 elicitationSupport: getElicitationSupport(server),
645 clientCapabilities: server.server.getClientCapabilities() ?? null,
646 codeLength: code.length,
647 });
648 if (elicitationMode.mode === "native") {
649 const result = yield* engine.execute(code, {
650 onElicitation: makeMcpElicitationHandler(server, debugLog),
651 });
652 return toMcpResult(result);
653 }
654 const outcome = yield* engine.executeWithPause(code);
655 debugLog("execute.paused_flow_result", {
656 status: outcome.status,
657 executionId: outcome.status === "paused" ? outcome.execution.id : undefined,
658 interactionKind:
659 outcome.status === "paused"
660 ? pausedInteractionKind(outcome.execution.elicitationContext.request)
661 : undefined,
662 });
663 if (outcome.status === "paused") {
664 yield* Effect.annotateCurrentSpan({
665 "mcp.execute.paused": true,
666 "mcp.execute.paused_execution_id": outcome.execution.id,
667 "mcp.execute.pause_source": "execute",
668 });
669 yield* onExecutionPaused(outcome.execution.id);
670 }
671 return outcome.status === "completed"
672 ? toMcpResult(outcome.result)
673 : elicitationMode.mode === "browser"
674 ? yield* requireUserResumeApproval(outcome.execution.id)
675 : toMcpPausedResult(formatPausedExecution(outcome.execution));
676 }).pipe(
677 Effect.withSpan("mcp.host.tool.execute", {
678 attributes: {
679 "mcp.tool.name": "execute",
680 "mcp.execute.code_length": code.length,
681 },
682 }),
683 );
684
685 const resumeExecution = (
686 executionId: string,

Callers 1

createExecutorMcpServerFunction · 0.70

Calls 10

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

Tested by

no test coverage detected