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

Function propsForPrincipal

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

Source from the content-addressed store, hash-verified

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

Callers 1

makeCloudMcpAgentHandlerFunction · 0.70

Calls 4

readElicitationModeFunction · 0.85
readArtifactsEnabledFunction · 0.85
readSearchToolsEnabledFunction · 0.85

Tested by

no test coverage detected