Skip to main content
Glama

env_set_group

Assigns or changes the group of an existing API environment. Use an empty string to make the environment global.

Instructions

Asigna o cambia el grupo de un entorno existente. Para sacarlo a global, pasar group vacío "".

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
environmentYesNombre del entorno
groupYesNombre del grupo. Cadena vacía "" para hacerlo global

Implementation Reference

  • Main tool handler for 'env_set_group'. Registers the tool on the MCP server, parses the 'environment' and 'group' params, auto-creates the group if it doesn't exist (when groupName is non-empty), then calls storage.setEnvironmentGroup() to assign the environment to the group (or make it global with empty string). Returns a success/error message.
    // ── env_set_group ──
    server.tool(
      'env_set_group',
      'Asigna o cambia el grupo de un entorno existente. Para sacarlo a global, pasar group vacío "".',
      {
        environment: z.string().describe('Nombre del entorno'),
        group: z.string().describe('Nombre del grupo. Cadena vacía "" para hacerlo global'),
      },
      async (params) => {
        try {
          const groupName = params.group || null
    
          // Si el grupo no existe, crearlo
          if (groupName) {
            const existing = await storage.getGroup(groupName)
            if (!existing) {
              await storage.createGroup(groupName)
            }
          }
    
          await storage.setEnvironmentGroup(params.environment, groupName)
    
          const msg = groupName
            ? `Entorno '${params.environment}' asignado al grupo '${groupName}'`
            : `Entorno '${params.environment}' ahora es global (sin grupo)`
          return { content: [{ type: 'text' as const, text: msg }] }
        } catch (error) {
          const message = error instanceof Error ? error.message : String(error)
          return { content: [{ type: 'text' as const, text: `Error: ${message}` }], isError: true }
        }
      },
    )
  • Schema definition for env_set_group inputs: expects 'environment' (string) and 'group' (string, where empty string makes it global). Uses Zod for validation.
    'env_set_group',
    'Asigna o cambia el grupo de un entorno existente. Para sacarlo a global, pasar group vacío "".',
    {
      environment: z.string().describe('Nombre del entorno'),
      group: z.string().describe('Nombre del grupo. Cadena vacía "" para hacerlo global'),
    },
  • Registration of the 'env_set_group' tool via server.tool() inside registerEnvironmentTools(). The tool is named 'env_set_group' with Spanish-language description.
    // ── env_set_group ──
    server.tool(
      'env_set_group',
      'Asigna o cambia el grupo de un entorno existente. Para sacarlo a global, pasar group vacío "".',
      {
        environment: z.string().describe('Nombre del entorno'),
        group: z.string().describe('Nombre del grupo. Cadena vacía "" para hacerlo global'),
      },
      async (params) => {
        try {
          const groupName = params.group || null
    
          // Si el grupo no existe, crearlo
          if (groupName) {
            const existing = await storage.getGroup(groupName)
            if (!existing) {
              await storage.createGroup(groupName)
            }
          }
    
          await storage.setEnvironmentGroup(params.environment, groupName)
    
          const msg = groupName
            ? `Entorno '${params.environment}' asignado al grupo '${groupName}'`
            : `Entorno '${params.environment}' ahora es global (sin grupo)`
          return { content: [{ type: 'text' as const, text: msg }] }
        } catch (error) {
          const message = error instanceof Error ? error.message : String(error)
          return { content: [{ type: 'text' as const, text: `Error: ${message}` }], isError: true }
        }
      },
    )
  • storage.setEnvironmentGroup() helper: loads the environment by name, clears its old group's default if needed, sets the new group (or undefined for global), and persists.
    async setEnvironmentGroup(envName: string, groupName: string | null): Promise<void> {
      const env = await this.getEnvironment(envName)
      if (!env) {
        throw new Error(`Entorno '${envName}' no encontrado`)
      }
    
      // Si tenia grupo y era el default, limpiar
      if (env.group) {
        const oldGroup = await this.getGroup(env.group)
        if (oldGroup?.default === envName) {
          oldGroup.default = undefined
          oldGroup.updatedAt = new Date().toISOString()
          await this.saveGroup(oldGroup)
        }
      }
    
      env.group = groupName ?? undefined
      env.updatedAt = new Date().toISOString()
      const filePath = join(this.environmentsDir, `${this.sanitizeName(envName)}.json`)
      await this.writeJson(filePath, env)
    }
  • storage.createGroup() and storage.getGroup() helpers used by the handler to auto-create groups if they don't exist.
    async createGroup(name: string): Promise<EnvironmentGroup> {
      await this.ensureDir('groups')
      const existing = await this.getGroup(name)
      if (existing) {
        throw new Error(`El grupo '${name}' ya existe`)
      }
      const now = new Date().toISOString()
      const group: EnvironmentGroup = { name, scopes: [], createdAt: now, updatedAt: now }
      await this.saveGroup(group)
      return group
    }
    
    async getGroup(name: string): Promise<EnvironmentGroup | null> {
      const filePath = join(this.groupsDir, `${this.sanitizeName(name)}.json`)
      return this.readJson<EnvironmentGroup>(filePath)
    }
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 discloses the core action and the empty string behavior, but lacks information on side effects (e.g., overwriting existing group, required permissions, error conditions). This is insufficient for a mutation tool.

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 is a single sentence that efficiently conveys the core functionality and a key usage note. No redundant or unnecessary text.

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

Completeness4/5

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

Considering the tool has only two parameters and no output schema, the description covers the main use case and an important special case. However, it could mention prerequisites (e.g., environment must exist) or error handling. Still, for a simple tool, it is fairly complete.

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

Parameters4/5

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

The input schema already has descriptions for both parameters (100% coverage), so the baseline is 3. The description adds value by explaining the special case of passing an empty string for 'group' to make the environment global, which is not fully captured in the schema description. This provides additional meaning.

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 verb 'asigna o cambia' (assigns or changes) and resource 'grupo de un entorno existente' (group of an existing environment). It also explains the special case of making an environment global. The purpose is distinct from sibling tools like env_group_create or env_set.

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 when to use this tool (to set/change the group of an environment) but does not explicitly state when not to use it or provide alternatives. The special case for making global is mentioned, but no comparison with other group-related tools is given.

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