|
|
@@ -18,6 +18,7 @@ import { WebStandardStreamableHTTPServerTransport }
|
|
|
from "@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";
|
|
|
import { isInitializeRequest } from "@modelcontextprotocol/sdk/types.js";
|
|
|
import { z } from "zod";
|
|
|
+import { existsSync } from "fs";
|
|
|
import {
|
|
|
createStore,
|
|
|
extractSnippet,
|
|
|
@@ -28,6 +29,7 @@ import {
|
|
|
type ExpandedQuery,
|
|
|
type IndexStatus,
|
|
|
} from "../index.js";
|
|
|
+import { getConfigPath } from "../collections.js";
|
|
|
|
|
|
// =============================================================================
|
|
|
// Types for structured content
|
|
|
@@ -536,7 +538,11 @@ Intent-aware lex (C++ performance, not sports):
|
|
|
// =============================================================================
|
|
|
|
|
|
export async function startMcpServer(): Promise<void> {
|
|
|
- const store = await createStore({ dbPath: getDefaultDbPath() });
|
|
|
+ const configPath = getConfigPath();
|
|
|
+ const store = await createStore({
|
|
|
+ dbPath: getDefaultDbPath(),
|
|
|
+ ...(existsSync(configPath) ? { configPath } : {}),
|
|
|
+ });
|
|
|
const server = await createMcpServer(store);
|
|
|
const transport = new StdioServerTransport();
|
|
|
await server.connect(transport);
|
|
|
@@ -557,7 +563,11 @@ export type HttpServerHandle = {
|
|
|
* Binds to localhost only. Returns a handle for shutdown and port discovery.
|
|
|
*/
|
|
|
export async function startMcpHttpServer(port: number, options?: { quiet?: boolean }): Promise<HttpServerHandle> {
|
|
|
- const store = await createStore({ dbPath: getDefaultDbPath() });
|
|
|
+ const configPath = getConfigPath();
|
|
|
+ const store = await createStore({
|
|
|
+ dbPath: getDefaultDbPath(),
|
|
|
+ ...(existsSync(configPath) ? { configPath } : {}),
|
|
|
+ });
|
|
|
|
|
|
// Pre-fetch default collection names for REST endpoint
|
|
|
const defaultCollectionNames = await store.getDefaultCollectionNames();
|