浏览代码

feat(mcp): pass YAML config path to createStore for model resolution

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
JohnRichardEnders 1 月之前
父节点
当前提交
ce0cd64409
共有 1 个文件被更改,包括 12 次插入2 次删除
  1. 12 2
      src/mcp/server.ts

+ 12 - 2
src/mcp/server.ts

@@ -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();