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

Function resolveSessionMetaForToken

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

Source from the content-addressed store, hash-verified

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

Callers 2

resolveSessionMetaMethod · 0.90

Calls 2

metaFromIdentityFunction · 0.85
organizationFromDatabaseFunction · 0.85

Tested by

no test coverage detected