Skip to main content
Glama
debugg-ai

Debugg AI MCP

Official
by debugg-ai

Delete Environment

delete_environment

Delete an environment by UUID, removing associated credentials and resources. Optionally specify a project UUID; defaults to the current git repository.

Instructions

Delete an environment by UUID. Returns {deleted: true, uuid}. Destructive — cascades per backend behavior (credentials under the env are typically removed). Defaults to the project resolved from the current git repo; pass projectUuid to target a different project. Returns isError:true with NotFound when the uuid doesn't exist or was already deleted.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
uuidYesUUID of the environment to delete. Required.
projectUuidNoOptional: UUID of the target project. Defaults to git-auto-detect.

Implementation Reference

  • Main handler function that executes the delete_environment tool logic. Resolves project UUID (from input or git repo), calls client.deleteEnvironment(), and returns {deleted: true, uuid} or a NotFound error response.
    export async function deleteEnvironmentHandler(
      input: DeleteEnvironmentInput,
      _context: ToolContext,
    ): Promise<ToolResponse> {
      const start = Date.now();
      logger.toolStart('delete_environment', { uuid: input.uuid, projectUuid: input.projectUuid });
    
      try {
        const client = new DebuggAIServerClient(config.api.key);
        await client.init();
    
        let projectUuid = input.projectUuid;
        if (!projectUuid) {
          const repoName = detectRepoName();
          if (!repoName) return notFound(input.uuid, 'no git repo detected and no projectUuid provided');
          const project = await client.findProjectByRepoName(repoName);
          if (!project) return notFound(input.uuid, `no project found for repo "${repoName}"`);
          projectUuid = project.uuid;
        }
    
        try {
          await client.deleteEnvironment(projectUuid, input.uuid);
          logger.toolComplete('delete_environment', Date.now() - start);
          return {
            content: [{ type: 'text', text: JSON.stringify({ deleted: true, uuid: input.uuid }, null, 2) }],
          };
        } catch (err: any) {
          if (err?.statusCode === 404 || err?.response?.status === 404) {
            return notFound(input.uuid, `backend returned 404 for project ${projectUuid}`);
          }
          throw err;
        }
      } catch (error) {
        logger.toolError('delete_environment', error as Error, Date.now() - start);
        throw handleExternalServiceError(error, 'DebuggAI', 'delete_environment');
      }
    }
  • Zod schema and TypeScript type for the DeleteEnvironmentInput. Validates uuid (required UUID string) and optional projectUuid.
    export const DeleteEnvironmentInputSchema = z.object({
      uuid: z.string().uuid(),
      projectUuid: z.string().uuid().optional(),
    }).strict();
    export type DeleteEnvironmentInput = z.infer<typeof DeleteEnvironmentInputSchema>;
  • tools/index.ts:83-96 (registration)
    Tool registration: buildDeleteEnvironmentTool() and buildValidatedDeleteEnvironmentTool() are called and registered in the toolRegistry map by name.
      toolRegistry.clear();
      for (const v of validated) toolRegistry.set(v.name, v);
    }
    
    export function getTools(): Tool[] {
      if (!_tools) initTools(null);
      return _tools!;
    }
    
    export function getTool(name: string): ValidatedTool | undefined {
      if (!_validatedTools) initTools(null);
      return toolRegistry.get(name);
    }
  • Service-layer helper that performs the HTTP DELETE request to the backend API endpoint api/v1/projects/{projectUuid}/environments/{envUuid}/.
    public async deleteEnvironment(projectUuid: string, envUuid: string): Promise<void> {
      if (!this.tx) throw new Error('Client not initialized — call init() first');
      await this.tx.delete(`api/v1/projects/${projectUuid}/environments/${envUuid}/`);
    }
  • Tool definition file: exports buildDeleteEnvironmentTool() (raw Tool with name 'delete_environment', description, and inputSchema) and buildValidatedDeleteEnvironmentTool() (wraps the tool with Zod schema and handler).
    import { Tool } from '@modelcontextprotocol/sdk/types.js';
    import { DeleteEnvironmentInputSchema, ValidatedTool } from '../types/index.js';
    import { deleteEnvironmentHandler } from '../handlers/deleteEnvironmentHandler.js';
    
    const DESCRIPTION = `Delete an environment by UUID. Returns {deleted: true, uuid}. Destructive — cascades per backend behavior (credentials under the env are typically removed). Defaults to the project resolved from the current git repo; pass projectUuid to target a different project. Returns isError:true with NotFound when the uuid doesn't exist or was already deleted.`;
    
    export function buildDeleteEnvironmentTool(): Tool {
      return {
        name: 'delete_environment',
        title: 'Delete Environment',
        description: DESCRIPTION,
        inputSchema: {
          type: 'object',
          properties: {
            uuid: { type: 'string', description: 'UUID of the environment to delete. Required.' },
            projectUuid: { type: 'string', description: 'Optional: UUID of the target project. Defaults to git-auto-detect.' },
          },
          required: ['uuid'],
          additionalProperties: false,
        },
      };
    }
    
    export function buildValidatedDeleteEnvironmentTool(): ValidatedTool {
      const tool = buildDeleteEnvironmentTool();
      return { ...tool, inputSchema: DeleteEnvironmentInputSchema, handler: deleteEnvironmentHandler };
    }
Behavior4/5

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

No annotations are present, so the description carries the full burden. It explicitly states 'Destructive', describes cascading deletion of credentials, and details error handling (NotFound). Missing permissions or reversibility details, but it is fairly transparent for a delete operation.

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 4 front-loaded sentences with no fluff. Each sentence adds essential information: operation, return, destructiveness, project scoping, and error behavior.

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

Completeness5/5

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

Given the low complexity (2 params, no output schema), the description covers the operation comprehensively, including side effects, error handling, and optional parameter usage. No obvious gaps.

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?

Both parameters are documented in the schema with 100% coverage. The description adds value by explaining the default behavior of projectUuid (git auto-detect) and the return format. This is above the baseline of 3.

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 'Delete an environment by UUID', providing a specific verb and resource. It distinguishes itself from sibling tools like delete_project, delete_test_case, and delete_test_suite by focusing on environments.

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

Usage Guidelines4/5

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

The description provides good context on project resolution via projectUuid and defaults to git repo. However, it does not explicitly mention when to avoid using this tool or suggest alternatives like update_environment.

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/debugg-ai/debugg-ai-mcp'

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