From a7b2d617a3c53d9b047d7cd73ef3270e521e8475 Mon Sep 17 00:00:00 2001 From: bendtherules Date: Tue, 14 Apr 2026 18:24:33 +0530 Subject: [PATCH] refactor(mcp-server): resolve STORAGE_DIR to absolute path using __dirname MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Import path and fileURLToPath for path resolution. - Rename imported STORAGE_DIR to STORAGE_DIR_REL. - Compute STORAGE_DIR as an absolute path relative to the script’s directory. --- src/mcp-server.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/mcp-server.ts b/src/mcp-server.ts index 19eaa67..37ed06a 100644 --- a/src/mcp-server.ts +++ b/src/mcp-server.ts @@ -1,9 +1,12 @@ #!/usr/bin/env bun + /** * Ask262 MCP Server * Provides MCP-compatible tools for exploring the ECMAScript specification. */ +import path from "node:path"; +import { fileURLToPath } from "node:url"; import * as lancedbSdk from "@lancedb/lancedb"; import { OllamaEmbeddings } from "@langchain/ollama"; import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; @@ -31,7 +34,15 @@ import { sectionContentToolMetadata, sectionContentToolName, } from "./agent-tools/index.js"; -import { EMBEDDING_MODEL, STORAGE_DIR } from "./constants.js"; +import { + EMBEDDING_MODEL, + STORAGE_DIR as STORAGE_DIR_REL, +} from "./constants.js"; + +// Resolve storage path relative to this script's directory +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const STORAGE_DIR = path.resolve(__dirname, "..", STORAGE_DIR_REL); // #region MCP Types