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

Function propsForPrincipal

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

Source from the content-addressed store, hash-verified

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

Callers 1

makeCloudMcpAgentHandlerFunction · 0.70

Calls 6

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

Tested by

no test coverage detected