Skip to content

feat: modify env interface with Symbol #2

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
merged 2 commits into from
May 12, 2025
Merged

feat: modify env interface with Symbol #2

merged 2 commits into from
May 12, 2025

Conversation

sunrabbit123
Copy link
Member

This pull request introduces a significant refactor to the handling of environment variables and improves testing for MCP (Model Context Protocol) connections and server interactions. The main changes include replacing the env and envMapper properties with a unified externalEnv property, adding support for required and optional environment variables, and enhancing test coverage with mock implementations and additional assertions.

Refactor of Environment Variable Handling:

  • Replaced env and envMapper with externalEnv in connectMcp and related functions to streamline environment variable management (src/cli.ts, src/index.ts, src/mcp.ts). [1] [2] [3] [4] [5]
  • Introduced RequiredEnv and OptionalEnv symbols to differentiate between mandatory and optional environment variables in StdioMcpConnection (src/mcp.ts).
  • Updated extractEnvFromName to handle required and optional environment variables, logging warnings for missing required variables (src/mcp.ts).

Test Enhancements:

  • Added mocks for StdioClientTransport and improved test coverage for connectMcp, including handling of required/optional environment variables and multiple MCP servers (src/mcp.test.ts). [1] [2] [3]
  • Enhanced createServer tests to include cleanup of resources (e.g., closing clients and servers) and added tests for tool listing and tool call requests (src/server.test.ts). [1] [2] [3]

@sunrabbit123 sunrabbit123 merged commit 10da067 into main May 12, 2025
@sunrabbit123 sunrabbit123 deleted the feat/env branch May 12, 2025 10:34
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