Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions bin/mcp-server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,22 @@ const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const ROOT = join(__dirname, "..");

function resolveMcpEntry(rootDir = ROOT) {
/**
* @param {string} [rootDir] - project root directory (defaults to package root)
* @param {(path: string) => boolean} [existsSyncFn] - injectable fs.existsSync
* for testing; defaults to the real existsSync
* @returns {string|null} resolved absolute path to the MCP server entry, or null
*/
export function resolveMcpEntry(rootDir = ROOT, existsSyncFn = existsSync) {
const candidates = [
// Preferred distributable JS entry (npm publish artifact)
join(rootDir, "app", "open-sse", "mcp-server", "server.js"),
// Preferred distributable JS entry (npm publish artifact, built by prepublish.ts)
join(rootDir, "dist", "open-sse", "mcp-server", "server.js"),
Comment on lines +20 to +21

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

According to the Repository Style Guide (Rule 9), changing production code in bin/ requires including or updating tests. Please add or update tests (e.g., under tests/unit/) to verify that resolveMcpEntry correctly resolves the dist/ path.

References
  1. Always include tests when changing production code (src/, open-sse/, electron/, bin/). (link)

// Local workspace TypeScript source fallback
join(rootDir, "open-sse", "mcp-server", "server.ts"),
];

for (const entry of candidates) {
if (existsSync(entry)) return entry;
if (existsSyncFn(entry)) return entry;
}
return null;
}
Expand All @@ -32,7 +38,7 @@ export async function startMcpCli(rootDir = ROOT) {
const mcpEntry = resolveMcpEntry(rootDir);
if (!mcpEntry) {
throw new Error(
"MCP server entrypoint not found. Expected app/open-sse/mcp-server/server.js or open-sse/mcp-server/server.ts."
"MCP server entrypoint not found. Expected dist/open-sse/mcp-server/server.js or open-sse/mcp-server/server.ts."
);
}

Expand Down
Loading