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

Function registerPassthroughTools

packages/hosts/mcp/src/tool-server.ts:1265–1510  ·  view source on GitHub ↗
(
  server: McpServer,
  tools: McpToolsPort,
  connections: McpConnectionsPort,
  integrations: McpIntegrationsPort,
  run: (
    address: ToolAddress,
    args: unknown,
    extra: McpRequestJoinKeys,
  ) => Effect.Effect<McpToolResult, E>,
)

Source from the content-addressed store, hash-verified

1263
1264/** Register discovery over the existing APIs, with no catalog work at connection time. */
1265const registerPassthroughTools = <E extends Cause.YieldableError>(
1266 server: McpServer,
1267 tools: McpToolsPort,
1268 connections: McpConnectionsPort,
1269 integrations: McpIntegrationsPort,
1270 run: (
1271 address: ToolAddress,
1272 args: unknown,
1273 extra: McpRequestJoinKeys,
1274 ) => Effect.Effect<McpToolResult, E>,
1275): Effect.Effect<void> =>
1276 Effect.gen(function* () {
1277 const context = yield* Effect.context<never>();
1278 const validator = new CfWorkerJsonSchemaValidator();
1279 const boundary = <A extends McpToolResult, F>(
1280 effect: Effect.Effect<A, F>,
1281 extra: McpRequestJoinKeys,
1282 ) =>
1283 Effect.runPromiseWith(context)(
1284 effect.pipe(
1285 Effect.provideService(
1286 CurrentOrgWriteAccess,
1287 makeOrgWriteAccessState(requestOrgWriteAccess(extra)),
1288 ),
1289 Effect.catchCause((cause) => Effect.succeed(toMcpFailureResult(cause))),
1290 ),
1291 );
1292 yield* Effect.sync(() => {
1293 server.registerTool(
1294 "integrations",
1295 {
1296 description:
1297 "List connected integrations and accounts visible to you. Returns integration descriptions, account labels, exact search filters, and last recorded health (null means unchecked). One item per account; use nextOffset for more. Does not load tool schemas or check credentials.",
1298 inputSchema: {
1299 integration: z.string().trim().min(1).optional().describe("Exact integration slug."),
1300 owner: z.enum(["org", "user"]).optional(),
1301 limit: z.number().int().min(1).max(50).default(20),
1302 offset: z.number().int().min(0).default(0),
1303 },
1304 annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false },
1305 },
1306 ({ integration, owner, limit, offset }, extra) =>
1307 boundary(
1308 Effect.gen(function* () {
1309 const [accounts, catalog] = yield* Effect.all([
1310 connections.list(),
1311 integrations.list(),
1312 ]);
1313 const metadata = new Map(catalog.map((item) => [String(item.slug), item]));
1314 const visible = accounts
1315 .flatMap((account) => {
1316 const item = metadata.get(account.integration);
1317 if (
1318 !item ||
1319 (integration !== undefined && account.integration !== integration) ||
1320 (owner !== undefined && account.owner !== owner)
1321 )
1322 return [];

Callers 1

createExecutorMcpServerFunction · 0.85

Calls 9

getValidatorMethod · 0.95
parseToolAddressFunction · 0.90
boundaryFunction · 0.85
passthroughInputSchemaFunction · 0.85
validateFunction · 0.85
syncMethod · 0.65
listMethod · 0.65
getMethod · 0.65
runFunction · 0.50

Tested by

no test coverage detected