From ace2b580585117e462f0d198357bcb2cbb4d968e Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 3 Jun 2026 18:27:15 -0700 Subject: [PATCH] Fix Glama MCP startup --- Dockerfile | 2 +- packages/mcp/src/index.ts | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 16586e3..eb0aee4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,4 +2,4 @@ # introspection checks. Installs the published package and launches the stdio server. FROM node:22-slim RUN npm install -g @espanol/mcp -ENTRYPOINT ["espanol-mcp"] +ENTRYPOINT ["node", "/usr/local/lib/node_modules/@espanol/mcp/dist/index.js"] diff --git a/packages/mcp/src/index.ts b/packages/mcp/src/index.ts index 712759c..838e545 100644 --- a/packages/mcp/src/index.ts +++ b/packages/mcp/src/index.ts @@ -11,7 +11,8 @@ * - Bilingual document creation (create_bilingual_doc) */ -import { readFileSync } from "node:fs"; +import { readFileSync, realpathSync } from "node:fs"; +import { pathToFileURL } from "node:url"; import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; import { registerDocsTools } from "./tools/docs.js"; @@ -76,8 +77,22 @@ async function main(): Promise { // No need to log anything as stdout/stderr are used for the protocol } +function isCurrentFileEntrypoint(): boolean { + const entrypoint = process.argv[1]; + + if (!entrypoint) { + return false; + } + + try { + return import.meta.url === pathToFileURL(realpathSync(entrypoint)).href; + } catch { + return import.meta.url === pathToFileURL(entrypoint).href; + } +} + // Start the server if this file is run directly -if (import.meta.url === `file://${process.argv[1]}`) { +if (isCurrentFileEntrypoint()) { main().catch((error) => { const message = error instanceof Error ? error.message : String(error); console.error(JSON.stringify({ level: "fatal", error: "MCP_STARTUP_FAILED", message }));