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

Function openSession

apps/cloud/src/mcp-session.e2e.node.test.ts:133–168  ·  view source on GitHub ↗
(
  organizationId: string,
  options: BuildOptions & { readonly caps?: ClientCapabilities } = {},
)

Source from the content-addressed store, hash-verified

131// them connected to an in-memory MCP client. Shaped as an acquireRelease so
132// the transport teardown is guaranteed when the test scope closes.
133const openSession = (
134 organizationId: string,
135 options: BuildOptions & { readonly caps?: ClientCapabilities } = {},
136) =>
137 Effect.acquireRelease(
138 Effect.gen(function* () {
139 const executor = yield* buildScopedExecutor(organizationId, `Org ${organizationId}`, options);
140 const engine = createExecutionEngine({ executor, codeExecutor: makeQuickJsExecutor() });
141 const mcpServer = yield* createExecutorMcpServer({
142 engine,
143 elicitationMode: options.elicitationMode ? { mode: options.elicitationMode } : undefined,
144 });
145 const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
146 const client = new Client(
147 { name: "cloud-e2e-test", version: "1.0.0" },
148 { capabilities: options.caps ?? ELICITATION_CAPS },
149 );
150 yield* Effect.promise(() => mcpServer.connect(serverTransport));
151 yield* Effect.promise(() => client.connect(clientTransport));
152 return { client, clientTransport, serverTransport };
153 }),
154 ({ clientTransport, serverTransport }) =>
155 Effect.all(
156 [
157 Effect.tryPromise({
158 try: () => clientTransport.close(),
159 catch: (cause) => cause,
160 }).pipe(Effect.ignore),
161 Effect.tryPromise({
162 try: () => serverTransport.close(),
163 catch: (cause) => cause,
164 }).pipe(Effect.ignore),
165 ],
166 { discard: true },
167 ),
168 ).pipe(Effect.map(({ client }) => ({ client })));
169
170const nextOrgId = (() => {
171 let seq = 0;

Callers 1

Calls 6

createExecutionEngineFunction · 0.90
makeQuickJsExecutorFunction · 0.90
createExecutorMcpServerFunction · 0.90
buildScopedExecutorFunction · 0.85
connectMethod · 0.65
closeMethod · 0.65

Tested by

no test coverage detected