Skip to content

Conversation

@samhvw8
Copy link
Contributor

@samhvw8 samhvw8 commented Jun 2, 2025

  • Replace manual PATH and HOME env var handling with getDefaultEnvironment()
  • Improves consistency and reliability of MCP client environment setup
  • Leverages SDK's built-in environment configuration

Related GitHub Issue

Closes: #4257

Description

Test Procedure

Type of Change

  • 🐛 Bug Fix: Non-breaking change that fixes an issue.
  • New Feature: Non-breaking change that adds functionality.
  • 💥 Breaking Change: Fix or feature that would cause existing functionality to not work as expected.
  • ♻️ Refactor: Code change that neither fixes a bug nor adds a feature.
  • 💅 Style: Changes that do not affect the meaning of the code (white-space, formatting, etc.).
  • 📚 Documentation: Updates to documentation files.
  • ⚙️ Build/CI: Changes to the build process or CI configuration.
  • 🧹 Chore: Other changes that don't modify src or test files.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Code Quality:
    • My code adheres to the project's style guidelines.
    • There are no new linting errors or warnings (npm run lint).
    • All debug code (e.g., console.log) has been removed.
  • Testing:
    • New and/or updated tests have been added to cover my changes.
    • All tests pass locally (npm test).
    • The application builds successfully with my changes.
  • Branch Hygiene: My branch is up-to-date (rebased) with the main branch.
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Changeset: A changeset has been created using npm run changeset if this PR includes user-facing changes or dependency updates.
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

Documentation Updates

Additional Notes

Get in Touch


Important

Refactor McpHub.ts to use getDefaultEnvironment() for MCP client environment setup, replacing manual PATH and HOME handling.

  • Environment Setup:
    • Replaces manual PATH and HOME environment variable handling with getDefaultEnvironment() in McpHub.ts.
    • Enhances consistency and reliability of MCP client environment setup.
  • Imports:
    • Adds getDefaultEnvironment to imports from @modelcontextprotocol/sdk/client/stdio.js.

This description was created by Ellipsis for e91bfbcd1a96c81c591ffb6b65db6430e9d7da64. You can customize this summary. It will automatically update as commits are pushed.

@samhvw8 samhvw8 requested review from cte and mrubens as code owners June 2, 2025 15:48
@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Jun 2, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Jun 3, 2025
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Jun 3, 2025
- Replace manual PATH and HOME env var handling with getDefaultEnvironment()
- Improves consistency and reliability of MCP client environment setup
- Leverages SDK's built-in environment configuration
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make sure everything works well, we should consider adding a test case in src/services/mcp/__tests__/McpHub.test.ts that specifically verifies the connectToServer method correctly passes the environment from getDefaultEnvironment() (along with any custom configInjected.env) to the StdioClientTransport constructor for stdio-type servers. This could involve spying on the StdioClientTransport constructor or examining the arguments it receives.

This would provide explicit confirmation that McpHub correctly utilizes the SDK's environment function as intended.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jun 3, 2025
@daniel-lxs
Copy link
Member

daniel-lxs commented Jun 3, 2025

This looks good, for reference here's the function being used from the SDK, it correctly injects HOME and PATH and correctly handles the OS specific ones:

https://github.com/modelcontextprotocol/typescript-sdk/blob/590d4841373fc4eb86ecc9079834353a98cb84a3/src/client/stdio.ts#L66

@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Needs Review] in Roo Code Roadmap Jun 3, 2025
@samhvw8
Copy link
Contributor Author

samhvw8 commented Jun 3, 2025

This looks good, for reference here's the function being used from the SDK, it correctly injects HOME and PATH and correctly handles the OS specific ones:

https://github.com/modelcontextprotocol/typescript-sdk/blob/590d4841373fc4eb86ecc9079834353a98cb84a3/src/client/stdio.ts#L66

thanks for clarify for me :D

@mrubens mrubens merged commit 467c52f into RooCodeInc:main Jun 4, 2025
13 checks passed
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jun 4, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Jun 4, 2025
@samhvw8 samhvw8 deleted the fix/mcp branch June 5, 2025 00:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer PR - Needs Review size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

MCP running missing env

3 participants