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

Function resolveSessionMetaForToken

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

Source from the content-addressed store, hash-verified

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

Callers 2

resolveSessionMetaMethod · 0.90

Calls 2

metaFromIdentityFunction · 0.85
organizationFromDatabaseFunction · 0.85

Tested by

no test coverage detected