refactor(mcp-server): resolve STORAGE_DIR to absolute path using __dirname

- 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.
This commit is contained in:
2026-04-14 18:24:33 +05:30
parent d608a62fa4
commit a7b2d617a3
+12 -1
View File
@@ -1,9 +1,12 @@
#!/usr/bin/env bun #!/usr/bin/env bun
/** /**
* Ask262 MCP Server * Ask262 MCP Server
* Provides MCP-compatible tools for exploring the ECMAScript specification. * 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 * as lancedbSdk from "@lancedb/lancedb";
import { OllamaEmbeddings } from "@langchain/ollama"; import { OllamaEmbeddings } from "@langchain/ollama";
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
@@ -31,7 +34,15 @@ import {
sectionContentToolMetadata, sectionContentToolMetadata,
sectionContentToolName, sectionContentToolName,
} from "./agent-tools/index.js"; } 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 // #region MCP Types