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

Function startHarness

apps/local/src/mcp-oauth.test.ts:79–143  ·  view source on GitHub ↗
(tmpDir: string)

Source from the content-addressed store, hash-verified

77}
78
79const startHarness = async (tmpDir: string): Promise<Harness> => {
80 const plugins = [
81 mcpPlugin({ dangerouslyAllowStdioMCP: false }),
82 fileSecretsPlugin({ directory: tmpDir }),
83 ] as const;
84 const sqlite = await createSqliteFumaDb({
85 tables: collectTables(),
86 namespace: "executor_local_test",
87 path: join(tmpDir, "data.db"),
88 });
89
90 const executor = await Effect.runPromise(
91 createExecutor({
92 tenant: Tenant.make(`test-${randomBytes(4).toString("hex")}`),
93 subject: Subject.make("local"),
94 db: sqlite.db,
95 plugins,
96 onElicitation: "accept-all",
97 oauthEndpointUrlPolicy: { allowHttp: true },
98 // EXPLICIT OAuth callback — required now that the localhost default is
99 // gone; the local daemon serves `/api/oauth/callback` on the web origin.
100 redirectUri: "http://localhost:4788/api/oauth/callback",
101 }),
102 );
103
104 const engine = createExecutionEngine({
105 executor,
106 codeExecutor: makeQuickJsExecutor(),
107 });
108
109 const TestObservability = observabilityMiddleware(TestApi);
110
111 const TestApiBase = HttpApiBuilder.layer(TestApi).pipe(
112 Layer.provide(CoreHandlers),
113 Layer.provide(McpHandlers),
114 Layer.provide(TestObservability),
115 Layer.provide(ErrorCaptureLive),
116 );
117
118 const pluginExtensions = Layer.succeed(McpExtensionService)(executor.mcp);
119
120 const { handler: webHandler, dispose: disposeHandler } = HttpRouter.toWebHandler(
121 TestApiBase.pipe(
122 Layer.provideMerge(pluginExtensions),
123 Layer.provideMerge(Layer.succeed(ExecutorService)(executor)),
124 Layer.provideMerge(Layer.succeed(ExecutionEngineService)(engine)),
125 Layer.provideMerge(HttpServer.layerServices),
126 Layer.provideMerge(Layer.succeed(HttpRouter.RouterConfig)({ maxParamLength: 1000 })),
127 ),
128 );
129
130 return {
131 fetch: ((input: RequestInfo | URL, init?: RequestInit) =>
132 webHandler(
133 input instanceof Request ? input : new Request(input, init),
134 )) as typeof globalThis.fetch,
135 dispose: async () => {
136 await Effect.runPromise(Effect.ignore(Effect.tryPromise(() => disposeHandler())));

Callers 1

mcp-oauth.test.tsFile · 0.70

Calls 9

createSqliteFumaDbFunction · 0.90
createExecutorFunction · 0.90
createExecutionEngineFunction · 0.90
makeQuickJsExecutorFunction · 0.90
observabilityMiddlewareFunction · 0.90
fileSecretsPluginFunction · 0.85
collectTablesFunction · 0.85
toStringMethod · 0.80
closeMethod · 0.65

Tested by

no test coverage detected