(executionStack: McpExecutionStackLayer)
| 38 | */ |
| 39 | export const makeMcpBuildServer = |
| 40 | (executionStack: McpExecutionStackLayer): McpBuildServer => |
| 41 | (principal: Principal, options?: McpBuildServerOptions) => |
| 42 | makeExecutionStack(principal.accountId, principal.organizationId, principal.organizationName, { |
| 43 | mcpResource: options?.resource, |
| 44 | }).pipe( |
| 45 | Effect.withSpan("mcp.execution_stack.build"), |
| 46 | Effect.map(({ engine }) => engine), |
| 47 | // Pin browser-handoff URLs to the principal's org slug when present; |
| 48 | // absent slug leaves the service unprovided and the URL stays bare. |
| 49 | principal.organizationSlug !== undefined |
| 50 | ? Effect.provideService(RequestOrgSlug, { slug: principal.organizationSlug }) |
| 51 | : (effect) => effect, |
| 52 | Effect.provide(executionStack), |
| 53 | Effect.mapError((cause) => new McpEngineBuildError({ cause })), |
| 54 | Effect.flatMap((engine) => |
| 55 | createExecutorMcpServer({ engine, ...(options ?? {}) }).pipe( |
| 56 | Effect.withSpan("mcp.server.create"), |
| 57 | Effect.map((mcpServer) => ({ mcpServer, engine })), |
| 58 | ), |
| 59 | ), |
| 60 | ); |
| 61 | |
| 62 | /** |
| 63 | * The standard console `McpErrorReporter` seam: route an orchestration defect |
no test coverage detected