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
5 changes: 5 additions & 0 deletions .changeset/pink-items-deliver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@lynx-js/docs-mcp-server": patch
---

Fix Windows startup error.
12 changes: 10 additions & 2 deletions packages/mcp-servers/docs-mcp-server/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.
import { readFile } from 'node:fs/promises';
import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';

import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
Expand Down Expand Up @@ -37,8 +39,14 @@ import { fetch } from 'undici';

const debug = createDebug('lynx-docs-mcp');

const pkgPath = findPackage.up({ cwd: new URL('.', import.meta.url).pathname });
const pkg = JSON.parse(await readFile(pkgPath!, 'utf-8')) as {
const moduleDirPath = dirname(fileURLToPath(import.meta.url));
const pkgPath = findPackage.up({ cwd: moduleDirPath });

if (!pkgPath) {
throw new Error(`Failed to locate package.json from ${moduleDirPath}`);
}

const pkg = JSON.parse(await readFile(pkgPath, 'utf-8')) as {
version: string;
name: string;
description: string;
Expand Down
Loading