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

Function registerPassthroughTools

packages/hosts/mcp/src/tool-server.ts:1271–1516  ·  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

1269
1270/** Register discovery over the existing APIs, with no catalog work at connection time. */
1271const registerPassthroughTools = <E extends Cause.YieldableError>(
1272 server: McpServer,
1273 tools: McpToolsPort,
1274 connections: McpConnectionsPort,
1275 integrations: McpIntegrationsPort,
1276 run: (
1277 address: ToolAddress,
1278 args: unknown,
1279 extra: McpRequestJoinKeys,
1280 ) => Effect.Effect<McpToolResult, E>,
1281): Effect.Effect<void> =>
1282 Effect.gen(function* () {
1283 const context = yield* Effect.context<never>();
1284 const validator = new CfWorkerJsonSchemaValidator();
1285 const boundary = <A extends McpToolResult, F>(
1286 effect: Effect.Effect<A, F>,
1287 extra: McpRequestJoinKeys,
1288 ) =>
1289 Effect.runPromiseWith(context)(
1290 effect.pipe(
1291 Effect.provideService(
1292 CurrentOrgWriteAccess,
1293 makeOrgWriteAccessState(requestOrgWriteAccess(extra)),
1294 ),
1295 Effect.catchCause((cause) => Effect.succeed(toMcpFailureResult(cause))),
1296 ),
1297 );
1298 yield* Effect.sync(() => {
1299 server.registerTool(
1300 "integrations",
1301 {
1302 description:
1303 "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.",
1304 inputSchema: {
1305 integration: z.string().trim().min(1).optional().describe("Exact integration slug."),
1306 owner: z.enum(["org", "user"]).optional(),
1307 limit: z.number().int().min(1).max(50).default(20),
1308 offset: z.number().int().min(0).default(0),
1309 },
1310 annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false },
1311 },
1312 ({ integration, owner, limit, offset }, extra) =>
1313 boundary(
1314 Effect.gen(function* () {
1315 const [accounts, catalog] = yield* Effect.all([
1316 connections.list(),
1317 integrations.list(),
1318 ]);
1319 const metadata = new Map(catalog.map((item) => [String(item.slug), item]));
1320 const visible = accounts
1321 .flatMap((account) => {
1322 const item = metadata.get(account.integration);
1323 if (
1324 !item ||
1325 (integration !== undefined && account.integration !== integration) ||
1326 (owner !== undefined && account.owner !== owner)
1327 )
1328 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