MCPcopy
hub / github.com/inkeep/open-knowledge / startWithAssets

Function startWithAssets

packages/server/src/mcp-mount.test.ts:304–325  ·  view source on GitHub ↗
(contentDir: string)

Source from the content-addressed store, hash-verified

302 }
303
304 async function startWithAssets(contentDir: string): Promise<{ port: number }> {
305 const httpServer = createServer();
306 const filter = {
307 isPathIgnored: (rel: string) => rel.startsWith('.ok/') || rel === 'excluded.png',
308 };
309 const mount = mountMcpAndApi({
310 httpServer,
311 hocuspocus,
312 log,
313 contentAssetMiddleware: createAssetServeMiddleware({
314 contentFilter: filter,
315 contentSirv: sirv(contentDir, { dev: true, dotfiles: false }),
316 inlineExtensions: INLINE_RENDERABLE_EXTENSIONS,
317 assetExtensions: ASSET_EXTENSIONS,
318 blocklistExtensions: EXECUTABLE_BLOCKLIST_EXTENSIONS,
319 }),
320 });
321 const port = await getFreeLoopbackPort();
322 await new Promise<void>((resolve) => httpServer.listen(port, '127.0.0.1', () => resolve()));
323 servers.push({ httpServer, mount });
324 return { port };
325 }
326
327 test('serves a content asset with inline disposition + nosniff', async () => {
328 const contentDir = makeContentDir();

Callers 1

mcp-mount.test.tsFile · 0.85

Calls 6

mountMcpAndApiFunction · 0.90
getFreeLoopbackPortFunction · 0.90
createServerFunction · 0.85
listenMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected