Skip to content

Commit 04ebe6b

Browse files
committed
fix: MCP server fails to start via npx — symlink + skills.json issues
1. isMain guard: process.argv[1] (symlink path) never matched import.meta.url (real path). Fixed with realpathSync comparison. 2. skills.json not in npm package: prebuild copies marketplace/skills.json to data/ dir, included in package files. 3. Version string bumped from 1.12.0 to 1.16.0. Closes #58
1 parent 24ff833 commit 04ebe6b

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

packages/mcp/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist/
2+
data/

packages/mcp/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
}
1616
},
1717
"files": [
18-
"dist"
18+
"dist",
19+
"data"
1920
],
2021
"scripts": {
22+
"prebuild": "mkdir -p data && cp ../../marketplace/skills.json data/skills.json",
2123
"build": "tsup",
2224
"dev": "tsup --watch",
2325
"typecheck": "tsc --noEmit",

packages/mcp/src/index.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
22
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
33
import { fileURLToPath } from 'node:url';
4+
import { realpathSync } from 'node:fs';
45
import {
56
CallToolRequestSchema,
67
ListToolsRequestSchema,
@@ -22,10 +23,12 @@ async function loadSkills(): Promise<SkillEntry[]> {
2223
const { readFileSync } = await import('node:fs');
2324
const { join, dirname } = await import('node:path');
2425

26+
const pkgDir = dirname(fileURLToPath(import.meta.url));
2527
const possiblePaths = [
28+
join(pkgDir, '..', 'data', 'skills.json'),
29+
join(pkgDir, '..', '..', '..', 'marketplace', 'skills.json'),
30+
join(pkgDir, '..', '..', 'marketplace', 'skills.json'),
2631
join(process.cwd(), 'marketplace', 'skills.json'),
27-
join(dirname(fileURLToPath(import.meta.url)), '..', '..', '..', 'marketplace', 'skills.json'),
28-
join(dirname(fileURLToPath(import.meta.url)), '..', '..', 'marketplace', 'skills.json'),
2932
];
3033

3134
for (const path of possiblePaths) {
@@ -52,7 +55,7 @@ async function loadSkills(): Promise<SkillEntry[]> {
5255
const server = new Server(
5356
{
5457
name: 'skillkit-discovery',
55-
version: '1.12.0',
58+
version: '1.16.0',
5659
},
5760
{
5861
capabilities: {
@@ -212,8 +215,9 @@ async function main() {
212215
console.error('SkillKit Discovery MCP Server running on stdio');
213216
}
214217

215-
const isMain = process.argv[1] === fileURLToPath(import.meta.url);
216-
if (isMain) {
218+
const resolvedArgv = realpathSync(process.argv[1]);
219+
const resolvedModule = fileURLToPath(import.meta.url);
220+
if (resolvedArgv === resolvedModule) {
217221
main().catch((error) => {
218222
console.error('Fatal error:', error);
219223
process.exit(1);

0 commit comments

Comments
 (0)