env_rename
Rename an environment in your API testing setup; if it is currently active, the reference updates automatically.
Instructions
Renombra un entorno existente. Si es el entorno activo, actualiza la referencia.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Nombre actual del entorno | |
| new_name | Yes | Nuevo nombre para el entorno |
Implementation Reference
- src/tools/environment.ts:306-335 (handler)Handler for env_rename tool. Receives {name, new_name}, calls storage.renameEnvironment(), and returns success/error message.
server.tool( 'env_rename', 'Renombra un entorno existente. Si es el entorno activo, actualiza la referencia.', { name: z.string().describe('Nombre actual del entorno'), new_name: z.string().describe('Nuevo nombre para el entorno'), }, async (params) => { try { await storage.renameEnvironment(params.name, params.new_name) return { content: [ { type: 'text' as const, text: `Entorno '${params.name}' renombrado a '${params.new_name}'`, }, ], } } catch (error) { const message = error instanceof Error ? error.message : String(error) return { content: [{ type: 'text' as const, text: `Error: ${message}` }], isError: true, } } }, ) // ── env_delete ── - src/tools/environment.ts:309-312 (schema)Input schema for env_rename: name (current name) and new_name (new name), both strings.
{ name: z.string().describe('Nombre actual del entorno'), new_name: z.string().describe('Nuevo nombre para el entorno'), }, - src/lib/storage.ts:300-338 (helper)Storage helper renameEnvironment() that validates existence of old env, no conflict with new name, renames the JSON file, updates project-envs references, and updates group default if needed.
async renameEnvironment(oldName: string, newName: string): Promise<void> { const env = await this.getEnvironment(oldName) if (!env) { throw new Error(`Entorno '${oldName}' no encontrado`) } const existing = await this.getEnvironment(newName) if (existing) { throw new Error(`Ya existe un entorno con el nombre '${newName}'`) } env.name = newName env.updatedAt = new Date().toISOString() await this.createEnvironment(env) await unlink(join(this.environmentsDir, `${this.sanitizeName(oldName)}.json`)) // Actualizar project-envs const projectEnvs = await this.getProjectEnvs() let changed = false for (const [project, envName] of Object.entries(projectEnvs)) { if (envName === oldName) { projectEnvs[project] = newName changed = true } } if (changed) { await this.writeJson(this.projectEnvsFile, projectEnvs) } // Actualizar default del grupo si era el default if (env.group) { const group = await this.getGroup(env.group) if (group?.default === oldName) { group.default = newName group.updatedAt = new Date().toISOString() await this.saveGroup(group) } } } - src/tools/environment.ts:306-307 (registration)Registration of 'env_rename' tool via server.tool() inside registerEnvironmentTools().
server.tool( 'env_rename', - src/server.ts:64-64 (registration)Top-level registration: registerEnvironmentTools(server, storage) is called in server.ts to register all environment tools including env_rename.
registerEnvironmentTools(server, storage)