-
Notifications
You must be signed in to change notification settings - Fork 61
fix(examples): resolve DIST_DIR path for npm package execution #277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When servers are compiled to dist/server.js and published to npm, `import.meta.dirname` already points to dist/, so joining with "dist" results in dist/dist/ which doesn't exist. This fix detects whether we're running from TypeScript source or compiled JavaScript and adjusts the path accordingly: - From source (server.ts): use dist/ subdirectory - From compiled (dist/server.js): use current directory Fixes ENOENT errors like: "ENOENT: no such file or directory, open '.../dist/dist/mcp-app.html'" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@modelcontextprotocol/ext-apps
@modelcontextprotocol/server-basic-react
@modelcontextprotocol/server-basic-vanillajs
@modelcontextprotocol/server-budget-allocator
@modelcontextprotocol/server-cohort-heatmap
@modelcontextprotocol/server-customer-segmentation
@modelcontextprotocol/server-map
@modelcontextprotocol/server-pdf
@modelcontextprotocol/server-scenario-modeler
@modelcontextprotocol/server-shadertoy
@modelcontextprotocol/server-sheet-music
@modelcontextprotocol/server-system-monitor
@modelcontextprotocol/server-threejs
@modelcontextprotocol/server-transcript
@modelcontextprotocol/server-video-resource
@modelcontextprotocol/server-wiki-explorer
commit: |
The pdf.worker.mjs file wasn't being found when running from npm because bun bundled pdfjs-dist but didn't include the worker file. By marking pdfjs-dist as external, it uses the installed package from node_modules at runtime where the worker is available. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Collaborator
Author
|
{
"mcpServers": {
"basic-react": {
"command": "npx",
"args": ["-y", "https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/server-basic-react@277", "--stdio"]
},
"basic-vanillajs": {
"command": "npx",
"args": ["-y", "https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/server-basic-vanillajs@277", "--stdio"]
},
"budget-allocator": {
"command": "npx",
"args": ["-y", "https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/server-budget-allocator@277", "--stdio"]
},
"cohort-heatmap": {
"command": "npx",
"args": ["-y", "https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/server-cohort-heatmap@277", "--stdio"]
},
"customer-segmentation": {
"command": "npx",
"args": ["-y", "https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/server-customer-segmentation@277", "--stdio"]
},
"map": {
"command": "npx",
"args": ["-y", "https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/server-map@277", "--stdio"]
},
"pdf": {
"command": "npx",
"args": ["-y", "https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/server-pdf@277", "--stdio"]
},
"scenario-modeler": {
"command": "npx",
"args": ["-y", "https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/server-scenario-modeler@277", "--stdio"]
},
"shadertoy": {
"command": "npx",
"args": ["-y", "https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/server-shadertoy@277", "--stdio"]
},
"sheet-music": {
"command": "npx",
"args": ["-y", "https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/server-sheet-music@277", "--stdio"]
},
"system-monitor": {
"command": "npx",
"args": ["-y", "https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/server-system-monitor@277", "--stdio"]
},
"threejs": {
"command": "npx",
"args": ["-y", "https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/server-threejs@277", "--stdio"]
},
"transcript": {
"command": "npx",
"args": ["-y", "https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/server-transcript@277", "--stdio"]
},
"video-resource": {
"command": "npx",
"args": ["-y", "https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/server-video-resource@277", "--stdio"]
},
"wiki-explorer": {
"command": "npx",
"args": ["-y", "https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/server-wiki-explorer@277", "--stdio"]
}
}
} |
antonpk1
approved these changes
Jan 15, 2026
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
ENOENT: no such file or directoryerrors when running servers from npm packagesChanges
1. DIST_DIR path resolution
When servers are compiled to
dist/server.jsand run vianpx,import.meta.dirnamealready points todist/, causingpath.join(import.meta.dirname, "dist")to resolve todist/dist/which doesn't exist.Updated all 20 example servers to detect whether running from TypeScript source or compiled JavaScript:
2. pdf-server pdfjs-dist bundling fix
The
pdf.worker.mjsfile wasn't found when running from npm because bun bundled pdfjs-dist but didn't include the worker file.By marking
pdfjs-distas external in the build, it uses the installed package fromnode_modulesat runtime where the worker is available:Test plan
npm run build:all)🤖 Generated with Claude Code