| 213 | // check; an unknown slug authorizes nothing. Ids pass straight through — |
| 214 | // `authorizeOrganization` verifies live WorkOS membership either way. |
| 215 | const resolveOrgSelector = (selector: string) => |
| 216 | selector.startsWith("org_") |
| 217 | ? Effect.succeed(selector) |
| 218 | : Effect.gen(function* () { |
| 219 | const users = yield* UserStoreService; |
| 220 | const org = yield* users.use("getOrganizationBySlug", (s) => |
| 221 | s.getOrganizationBySlug(selector), |
| 222 | ); |
| 223 | return org?.id ?? null; |
| 224 | }); |
| 225 | |
| 226 | export const McpOrganizationAuthLive = Layer.succeed(McpOrganizationAuth)({ |
| 227 | authorize: (accountId, organizationSelector) => |