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

Function executePassthroughCall

packages/hosts/mcp/src/tool-server.ts:1990–2040  ·  view source on GitHub ↗
(
      address: ToolAddress,
      args: unknown,
      extra: McpRequestJoinKeys,
    )

Source from the content-addressed store, hash-verified

1988 // The client approves the generic destructive tool; upstream prompts use
1989 // native elicitation, or fail with an actionable result when unsupported.
1990 const executePassthroughCall = (
1991 address: ToolAddress,
1992 args: unknown,
1993 extra: McpRequestJoinKeys,
1994 ): Effect.Effect<McpToolResult, E> =>
1995 Effect.gen(function* () {
1996 yield* startMarker("mcp.host.tool.execute.start", {
1997 "mcp.tool.id": String(address),
1998 "mcp.tool.mode": "passthrough",
1999 "executor.tool.address": address,
2000 });
2001 const { url: supportsUrl } = getElicitationSupport(server);
2002 const native = makeMcpElicitationHandler(server, extra.requestId, debugLog);
2003 const { form: supportsForm } = getElicitationSupport(server);
2004 // Set when the tool asked the user for something this client cannot
2005 // relay. The handler has no error channel (a non-accept is a decline
2006 // to the executor), so the request is kept here and the whole call is
2007 // reported as unanswerable below — with what was asked, URL included —
2008 // instead of as "declined by the user", which nobody did.
2009 let unanswerable: ElicitationRequest | undefined;
2010 const onElicitation: ElicitationHandler = (ctx) => {
2011 // Every invoke is advertised as destructive, so the client's native
2012 // approval covers the selected ID and arguments, even if policy changed.
2013 // Tool-raised prompts still require their own response below.
2014 if (ctx.source === "policy") {
2015 return Effect.succeed({ action: "accept" as const, content: {} });
2016 }
2017 // Anything the tool itself asked for goes to the client natively
2018 // when it can take it; the native bridge already turns a URL
2019 // request into a form for form-only clients.
2020 if (supportsForm || (supportsUrl && Predicate.isTagged(ctx.request, "UrlElicitation"))) {
2021 return native(ctx);
2022 }
2023 unanswerable = ctx.request;
2024 return Effect.succeed({ action: "decline" as const });
2025 };
2026 const outcome = yield* engine.execute(passthroughCallCode(address, args), {
2027 onElicitation,
2028 });
2029 if (unanswerable) return elicitationUnsupportedResult(String(address), unanswerable);
2030 return toPassthroughResult(outcome);
2031 }).pipe(
2032 Effect.withSpan("mcp.host.tool.execute", {
2033 attributes: {
2034 "mcp.tool.id": String(address),
2035 "mcp.tool.mode": "passthrough",
2036 "executor.integration": parseToolAddress(String(address))?.integration,
2037 },
2038 }),
2039 Effect.annotateSpans(joinKeyAttributes(extra)),
2040 );
2041
2042 // --- tools ---
2043

Callers

nothing calls this directly

Calls 9

passthroughCallCodeFunction · 0.90
parseToolAddressFunction · 0.90
startMarkerFunction · 0.85
getElicitationSupportFunction · 0.85
toPassthroughResultFunction · 0.85
joinKeyAttributesFunction · 0.85
executeMethod · 0.65

Tested by

no test coverage detected