Skip to content
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

feat: Add Support for Absolute Paths in MCP Server Configuration to Resolve NVM Issues (#64) #136

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

twlhitesh
Copy link

@twlhitesh twlhitesh commented Jan 6, 2025

Summary

This PR addresses Issue #64, which highlights a problem where MCP servers fail to work with Node Version Manager (NVM) due to incorrect Node version usage. The solution introduces the use of absolute paths for the Node executable and server script, ensuring compatibility in NVM environments. Additionally, documentation has been updated to guide users through this configuration.

Motivation and Context

When using NVM, the standard installation and usage instructions for MCP servers fail because the app attempts to use an incorrect Node version, leading to execution errors. This change:

  • Resolves compatibility issues with NVM by enforcing the use of absolute paths.
  • Ensures the correct Node version is always used.
  • Improves overall stability and user experience.

How Has This Been Tested?

  • Tested on multiple environments with NVM to verify the use of absolute paths prevents Node version conflicts.
  • Confirmed that the updated configuration works with various MCP server setups, including Puppeteer-based servers.
  • Validated the installation and runtime behavior using the updated documentation.

Breaking Changes

Yes, users must update their config.json to include absolute paths for the Node executable and server script. The updated documentation provides clear instructions for this transition.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional Context

Example Updated Configuration:

{
  "mcpServers": {
    "puppeteer": {
      "command": "/Users/username/.nvm/versions/node/v22.11.0/bin/node",
      "args": [
        "/Users/username/.nvm/versions/node/v22.11.0/lib/node_modules/@modelcontextprotocol/server-puppeteer/dist/index.js"
      ]
    }
  }
}

Update MCP server configuration to work with NVM by using absolute paths for Node executable and server script.

* **src/mcp/cli/cli.py**
  - Update `_build_uv_command` to handle absolute paths for Node executable and server script.
  - Modify `dev` command to use absolute paths instead of `npx`.
  - Adjust `install` command to use absolute paths for Node executable and server script.

* **src/mcp/cli/claude.py**
  - Update `update_claude_config` to use absolute paths for Node executable and server script.

* **README.md**
  - Update documentation to reflect new configuration method using absolute paths.

* **examples/servers/simple-prompt/README.md**
  - Include instructions for using absolute paths for the Node executable and server script.

* **examples/servers/simple-resource/README.md**
  - Include instructions for using absolute paths for the Node executable and server script.

* **.nvmrc**
  - Add a `.nvmrc` file to specify the desired Node version.
Fix Node version handling in MCP server configuration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant