fix: improve basePath resolution for npx execution support #116
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.
Problem
Fixes #101 - MCP servers created with mcp-framework fail when executed via
npx
with the error "Server does not support tools (required for tools/list)".The issue occurs because the current
MCPServer.resolveBasePath()
method usesdirname(process.argv[1])
which points to different locations when running via:npm run start
(works) ✅npx package-name
(fails) ❌Solution
Updated
MCPServer.resolveBasePath()
to use the same intelligent resolution strategy asBaseLoader
:process.cwd() + '/dist'
process.argv[1]
with intelligentdist/
detectionChanges Made
existsSync
import from 'fs'resolveBasePath()
method with multi-stage resolution logicbasePath
configsTesting
✅ Verified fix works with both execution methods:
npm run start
- continues to worknpx package-name
- now works correctlyBenefits
basePath
workarounds needednpx
distribution