We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/debugmcpdev/mcp-debugger'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
environment-impl.ts.shadow.md•1.69 KiB
# src/implementations/environment-impl.ts
@source-hash: d509c4dea5c4799a
@generated: 2026-02-10T00:41:45Z
## Purpose
Production implementation of the environment abstraction layer that provides controlled access to Node.js process environment variables and file system context.
## Key Components
### ProcessEnvironment Class (L11-41)
- **Core Role**: Concrete implementation of `IEnvironment` interface for production use
- **Pattern**: Snapshot pattern - captures environment state at construction time for consistency
- **Constructor (L14-18)**: Creates immutable snapshot of `process.env` to prevent mid-execution changes from affecting behavior
### Key Methods
- **get() (L23-25)**: Retrieves specific environment variable from internal snapshot
- **getAll() (L30-33)**: Returns defensive copy of all environment variables to prevent external mutation
- **getCurrentWorkingDirectory() (L38-40)**: Direct wrapper around `process.cwd()` for real-time working directory
## Dependencies
- `IEnvironment` from `@debugmcp/shared` - interface contract this class fulfills
## Architectural Decisions
1. **Immutable Snapshot Strategy**: Environment variables are captured once at construction rather than live-read, ensuring consistent behavior throughout object lifetime
2. **Defensive Copying**: All returned data structures are copies to prevent external modification of internal state
3. **Mixed Consistency Model**: Environment variables are snapshotted (consistent), but working directory is live (current)
## Critical Invariants
- Environment variable access is always consistent with construction-time state
- Internal snapshot remains immutable after construction
- All external data access is through defensive copies