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

Function propsForPrincipal

apps/cloud/src/mcp/agent-handler.ts:170–197  ·  view source on GitHub ↗
(
  request: Request,
  principal: Extract<AuthOutcome, { readonly _tag: "Authenticated" }>["principal"],
  resource: McpResource,
)

Source from the content-addressed store, hash-verified

168};
169
170const propsForPrincipal = (
171 request: Request,
172 principal: Extract<AuthOutcome, { readonly _tag: "Authenticated" }>["principal"],
173 resource: McpResource,
174): Effect.Effect<McpSessionProps> =>
175 Effect.gen(function* () {
176 const propagation = yield* currentPropagationHeaders(request);
177 return {
178 session: {
179 organizationId: principal.organizationId,
180 // The org record the live membership check resolved microseconds ago,
181 // handed to the session DO so it never opens a connection of its own to
182 // re-read it. An unnamed org (no auth plane could resolve one) is
183 // omitted rather than sent empty, so the DO can tell "not carried" from
184 // "carried, and blank".
185 ...(principal.organizationName ? { organizationName: principal.organizationName } : {}),
186 ...(principal.organizationSlug ? { organizationSlug: principal.organizationSlug } : {}),
187 ...sessionOrgRoleMetadata(principal),
188 userId: principal.accountId,
189 elicitationMode: readElicitationMode(request),
190 artifactsEnabled: readArtifactsEnabled(request),
191 searchToolsEnabled: readSearchToolsEnabled(request),
192 resource,
193 webOrigin: new URL(request.url).origin,
194 },
195 propagation,
196 };
197 });
198
199export const makeCloudMcpAgentHandler = () => {
200 const serveOptions = {

Callers 1

makeCloudMcpAgentHandlerFunction · 0.70

Calls 5

sessionOrgRoleMetadataFunction · 0.90
readElicitationModeFunction · 0.85
readArtifactsEnabledFunction · 0.85
readSearchToolsEnabledFunction · 0.85

Tested by

no test coverage detected