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

Function resolveSessionMetaForToken

apps/cloud/src/mcp/session-meta.ts:183–209  ·  view source on GitHub ↗
(
  token: McpSessionInit,
  storedMeta: SessionMeta | null,
)

Source from the content-addressed store, hash-verified

181 * base Durable Object only offers a matching one), or `null`.
182 */
183export const resolveSessionMetaForToken = (
184 token: McpSessionInit,
185 storedMeta: SessionMeta | null,
186): Effect.Effect<
187 SessionMeta,
188 McpSessionMetaUnavailableError | OrganizationNotFoundError,
189 UserStoreService | WorkOSClient
190> =>
191 Effect.gen(function* () {
192 const fromProps = token.organizationName;
193 if (fromProps) {
194 yield* Effect.annotateCurrentSpan(SESSION_META_SOURCE_ATTRIBUTE, "props");
195 return metaFromIdentity(token, { name: fromProps, slug: token.organizationSlug });
196 }
197
198 if (storedMeta?.organizationName) {
199 yield* Effect.annotateCurrentSpan(SESSION_META_SOURCE_ATTRIBUTE, "stored");
200 return metaFromIdentity(token, {
201 name: storedMeta.organizationName,
202 slug: storedMeta.organizationSlug,
203 });
204 }
205
206 yield* Effect.annotateCurrentSpan(SESSION_META_SOURCE_ATTRIBUTE, "database");
207 const organization = yield* organizationFromDatabase(token.organizationId);
208 return metaFromIdentity(token, organization);
209 });

Callers 2

resolveSessionMetaMethod · 0.90

Calls 2

metaFromIdentityFunction · 0.85
organizationFromDatabaseFunction · 0.85

Tested by

no test coverage detected