Skip to main content
Glama

env_set_default

Set an environment as the default for its group, automatically activating it when you enter a project.

Instructions

Marca un entorno como el default de su grupo. El default se activa automaticamente al entrar al proyecto.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesNombre del entorno a marcar como default

Implementation Reference

  • The 'env_set_default' tool handler: validates the environment exists, checks it belongs to a group, sets it as the group default via storage.setGroupDefault, and clears active sessions for the group so the new default takes effect immediately.
    server.tool(
      'env_set_default',
      'Marca un entorno como el default de su grupo. El default se activa automaticamente al entrar al proyecto.',
      {
        name: z.string().describe('Nombre del entorno a marcar como default'),
      },
      async (params) => {
        try {
          const env = await storage.getEnvironment(params.name)
          if (!env) {
            return { content: [{ type: 'text' as const, text: `Error: Entorno '${params.name}' no encontrado` }], isError: true }
          }
          if (!env.group) {
            return { content: [{ type: 'text' as const, text: `Error: El entorno '${params.name}' es global y no pertenece a ningun grupo. Solo los entornos de un grupo pueden ser default.` }], isError: true }
          }
          await storage.setGroupDefault(env.group, params.name)
          // Limpiar todas las sesiones activas del grupo para que el nuevo default tome efecto inmediato
          await storage.clearGroupSessionActives(env.group)
          return {
            content: [{ type: 'text' as const, text: `Entorno '${params.name}' marcado como default del grupo '${env.group}'` }],
          }
        } catch (error) {
          const message = error instanceof Error ? error.message : String(error)
          return { content: [{ type: 'text' as const, text: `Error: ${message}` }], isError: true }
        }
      },
    )
  • Input schema for env_set_default: requires a 'name' string describing the environment to mark as default.
    {
      name: z.string().describe('Nombre del entorno a marcar como default'),
    },
  • Registration of 'env_set_default' tool on the MCP server via server.tool() inside registerEnvironmentTools.
    server.tool(
      'env_set_default',
      'Marca un entorno como el default de su grupo. El default se activa automaticamente al entrar al proyecto.',
      {
        name: z.string().describe('Nombre del entorno a marcar como default'),
      },
      async (params) => {
        try {
          const env = await storage.getEnvironment(params.name)
          if (!env) {
            return { content: [{ type: 'text' as const, text: `Error: Entorno '${params.name}' no encontrado` }], isError: true }
          }
          if (!env.group) {
            return { content: [{ type: 'text' as const, text: `Error: El entorno '${params.name}' es global y no pertenece a ningun grupo. Solo los entornos de un grupo pueden ser default.` }], isError: true }
          }
          await storage.setGroupDefault(env.group, params.name)
          // Limpiar todas las sesiones activas del grupo para que el nuevo default tome efecto inmediato
          await storage.clearGroupSessionActives(env.group)
          return {
            content: [{ type: 'text' as const, text: `Entorno '${params.name}' marcado como default del grupo '${env.group}'` }],
          }
        } catch (error) {
          const message = error instanceof Error ? error.message : String(error)
          return { content: [{ type: 'text' as const, text: `Error: ${message}` }], isError: true }
        }
      },
    )
  • Storage.setGroupDefault: loads the group, validates the environment belongs to it, sets group.default to envName, and persists the group.
    async setGroupDefault(groupName: string, envName: string): Promise<void> {
      const group = await this.getGroup(groupName)
      if (!group) {
        throw new Error(`Grupo '${groupName}' no encontrado`)
      }
      const env = await this.getEnvironment(envName)
      if (!env) {
        throw new Error(`Entorno '${envName}' no encontrado`)
      }
      if (env.group !== groupName) {
        throw new Error(`El entorno '${envName}' no pertenece al grupo '${groupName}'`)
      }
      group.default = envName
      group.updatedAt = new Date().toISOString()
      await this.saveGroup(group)
    }
  • Storage.clearGroupSessionActives: clears all project-level active environment entries for scopes belonging to the specified group, ensuring the new default takes effect immediately.
    async clearGroupSessionActives(groupName: string): Promise<void> {
      const group = await this.getGroup(groupName)
      if (!group) return
      const projectEnvs = await this.getProjectEnvs()
      let changed = false
      for (const key of Object.keys(projectEnvs)) {
        const normalized = key.replace(/\\/g, '/')
        for (const scope of group.scopes) {
          if (normalized === scope || normalized.startsWith(scope + '/')) {
            delete projectEnvs[key]
            changed = true
            break
          }
        }
      }
      if (changed) {
        await this.writeJson(this.projectEnvsFile, projectEnvs)
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must carry the full burden. It describes the core behavior (marking as default and auto-activation) but omits side effects, prerequisites, error handling, or return value information.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description consists of two concise sentences, front-loaded with the main action. No unnecessary words or repetition.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple, single-parameter tool with no output schema, the description covers purpose and effect. However, it lacks behavioral details (e.g., reversibility, permissions) that would be helpful given no annotations.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% (the single parameter has a description). The tool description does not add additional meaning beyond what the schema already provides, so a baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool marks an environment as the default of its group, with a specific verb ('Marca') and resource ('entorno'). It also explains the consequence (automatic activation), making it distinct from siblings.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies a use case (setting a default that activates automatically), but does not explicitly compare to alternatives like env_set or env_switch, nor state when not to use this tool.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/cocaxcode/api-testing-mcp'

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