detect_environment
Identifies the current environment context by analyzing NODE_ENV, git branches, and project configurations to determine the appropriate settings for secure secret management.
Instructions
Detect the current environment context (wavefunction collapse). Returns the detected environment and its source (NODE_ENV, git branch, project config, etc.).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectPath | No | Project root path for project-scoped secrets |
Implementation Reference
- src/mcp/server.ts:504-513 (registration)Registration of the 'detect_environment' tool within the MCP server.
server.tool( "detect_environment", "Detect the current environment context (wavefunction collapse). Returns the detected environment and its source (NODE_ENV, git branch, project config, etc.).", { projectPath: projectPathSchema, }, async (params) => { const result = collapseEnvironment({ projectPath: params.projectPath ?? process.cwd(), }); - src/core/collapse.ts:96-120 (handler)The implementation of collapseEnvironment which serves as the handler for the 'detect_environment' tool.
export function collapseEnvironment( ctx: CollapseContext = {}, ): CollapseResult | null { if (ctx.explicit) { return { env: ctx.explicit, source: "explicit" }; } const qringEnv = process.env.QRING_ENV; if (qringEnv) { return { env: qringEnv, source: "QRING_ENV" }; } const nodeEnv = process.env.NODE_ENV; if (nodeEnv) { const mapped = mapEnvName(nodeEnv); return { env: mapped, source: "NODE_ENV" }; } const config = readProjectConfig(ctx.projectPath); if (config?.env) { return { env: config.env, source: "project-config" }; } const branch = detectGitBranch(ctx.projectPath); if (branch) {