Skip to main content
Glama

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
NameRequiredDescriptionDefault
projectPathNoProject root path for project-scoped secrets

Implementation Reference

  • 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(),
        });
  • 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) {

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/I4cTime/quantum_ring'

If you have feedback or need assistance with the MCP directory API, please join our Discord server