Skip to main content
Glama
debugg-ai

Debugg AI MCP

Official
by debugg-ai

Create Project Environment

create_environment

Create a new environment for a DebuggAI project by providing a name and URL. Optionally add a description, target a different project, or seed login credentials in the same call.

Instructions

Create a new environment under a DebuggAI project. Both name and url are required (backend rejects standard environments without a URL). Optional description. Defaults to the project resolved from the current git repo; pass projectUuid to target a different project (get UUIDs via search_projects).

OPTIONAL credentials seed: pass credentials: [{label, username, password, role?}] to create login credentials alongside the environment in a single call. Each cred is created best-effort; failures go to credentialWarnings without blocking env creation. Passwords are write-only and NEVER returned.

Returns the created environment's uuid (and the seeded credentials, if any). Reference the env uuid when running check_app_in_browser.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesShort label for the environment (e.g. "staging", "production"). Required.
urlYesBase URL for the environment (e.g. https://staging.example.com). Required.
descriptionNoOptional: free-text description.
projectUuidNoOptional: UUID of the target project. Defaults to the project resolved from the current git repo.

Implementation Reference

  • Tool factory that builds the 'create_environment' Tool object with name, title, description, and inputSchema (name/url required, description/projectUuid optional).
    export function buildCreateEnvironmentTool(): Tool {
      return {
        name: 'create_environment',
        title: 'Create Project Environment',
        description: DESCRIPTION,
        inputSchema: {
          type: 'object',
          properties: {
            name: {
              type: 'string',
              description: 'Short label for the environment (e.g. "staging", "production"). Required.',
              minLength: 1,
            },
            url: {
              type: 'string',
              description: 'Base URL for the environment (e.g. https://staging.example.com). Required.',
            },
            description: {
              type: 'string',
              description: 'Optional: free-text description.',
            },
            projectUuid: {
              type: 'string',
              description: 'Optional: UUID of the target project. Defaults to the project resolved from the current git repo.',
            },
          },
          required: ['name', 'url'],
          additionalProperties: false,
        },
      };
    }
    
    export function buildValidatedCreateEnvironmentTool(): ValidatedTool {
      const tool = buildCreateEnvironmentTool();
      return {
        ...tool,
        inputSchema: CreateEnvironmentInputSchema,
        handler: createEnvironmentHandler,
      };
    }
  • Main handler that creates a DebuggAI environment: resolves projectUuid from input or git repo, calls client.createEnvironment, optionally seeds credentials, and returns the result.
    export async function createEnvironmentHandler(
      input: CreateEnvironmentInput,
      _context: ToolContext,
    ): Promise<ToolResponse> {
      const start = Date.now();
      logger.toolStart('create_environment', {
        name: input.name,
        hasUrl: !!input.url,
        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) {
            const payload = {
              error: 'NoProjectResolved',
              message: 'No git repo detected and no projectUuid provided. Pass projectUuid (get it from search_projects) or invoke from a directory with a git origin.',
            };
            return { content: [{ type: 'text', text: JSON.stringify(payload, null, 2) }], isError: true };
          }
          const project = await client.findProjectByRepoName(repoName);
          if (!project) {
            const payload = {
              error: 'NoProjectResolved',
              message: `No DebuggAI project found for repo "${repoName}". Pass projectUuid explicitly.`,
            };
            return { content: [{ type: 'text', text: JSON.stringify(payload, null, 2) }], isError: true };
          }
          projectUuid = project.uuid;
        }
    
        const env = await client.createEnvironment(projectUuid, {
          name: input.name,
          url: input.url,
          description: input.description,
        });
    
        const payload: Record<string, any> = {
          created: true,
          projectUuid,
          environment: env,
        };
    
        // Optional credentials seed: best-effort per-cred. Success goes to
        // credentials[]; failure goes to credentialWarnings[] (never blocks env creation).
        if (input.credentials && input.credentials.length > 0) {
          const created: Array<{ uuid: string; label: string; username: string; role: string | null; environmentUuid: string }> = [];
          const warnings: Array<{ label: string; error: string }> = [];
          for (const seed of input.credentials) {
            try {
              const cred = await client.createCredential(projectUuid, env.uuid, {
                label: seed.label,
                username: seed.username,
                password: seed.password,
                role: seed.role,
              });
              // Defensive: drop any stray password from the response shape
              created.push({
                uuid: cred.uuid,
                label: cred.label,
                username: cred.username,
                role: cred.role ?? null,
                environmentUuid: cred.environmentUuid,
              });
            } catch (err: any) {
              warnings.push({
                label: seed.label,
                error: err?.message ?? String(err),
              });
            }
          }
          payload.credentials = created;
          if (warnings.length > 0) payload.credentialWarnings = warnings;
        }
    
        logger.toolComplete('create_environment', Date.now() - start);
        return { content: [{ type: 'text', text: JSON.stringify(payload, null, 2) }] };
      } catch (error) {
        logger.toolError('create_environment', error as Error, Date.now() - start);
        throw handleExternalServiceError(error, 'DebuggAI', 'create_environment');
      }
    }
  • Zod schema and TypeScript type for CreateEnvironmentInput, including optional credentials array with CredentialSeedSchema.
    export const CreateEnvironmentInputSchema = z.object({
      name: z.string().min(1, 'name is required'),
      url: z.string().url('url is required for standard environments'),
      description: z.string().optional(),
      projectUuid: z.string().uuid().optional(),
      credentials: z.array(CredentialSeedSchema).optional(),
    }).strict();
    export type CreateEnvironmentInput = z.infer<typeof CreateEnvironmentInputSchema>;
  • Factory that wraps the base tool with the Zod-validated schema and wires it to the handler.
    export function buildValidatedCreateEnvironmentTool(): ValidatedTool {
      const tool = buildCreateEnvironmentTool();
      return {
        ...tool,
        inputSchema: CreateEnvironmentInputSchema,
        handler: createEnvironmentHandler,
      };
    }
  • Service-layer method that POSTs to the DebuggAI API to create an environment under a project.
    public async createEnvironment(
      projectUuid: string,
      input: { name: string; url?: string; description?: string },
    ): Promise<{ uuid: string; name: string; url: string; isActive: boolean }> {
      if (!this.tx) throw new Error('Client not initialized — call init() first');
      const body: Record<string, any> = { name: input.name };
      if (input.url) body.url = input.url;
      if (input.description) body.description = input.description;
      const response = await this.tx.post<any>(
        `api/v1/projects/${projectUuid}/environments/`,
        body,
      );
      return {
        uuid: response.uuid,
        name: response.name,
        url: response.url || response.activeUrl || '',
        isActive: response.isActive,
      };
    }
Behavior4/5

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

With no annotations, the description carries full burden and does well: it states that backend rejects standard environments without a URL, credentials are created best-effort with failures in credentialWarnings, passwords are write-only and never returned. It also mentions return values (uuid and credentials). However, it omits details like idempotency, rate limits, or error handling.

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

Conciseness3/5

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

The description is three paragraphs and somewhat verbose, but each sentence adds value. However, it could be more concise, especially the second paragraph about credentials.

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?

Given the tool has 4 params, no output schema, and no annotations, the description covers purpose, behavior, usage, and return values. However, the phantom 'credentials' parameter creates a gap, and the return structure is vague (just 'uuid and credentials'). It's adequate but not fully complete.

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

Parameters2/5

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

The input schema has 100% coverage for its parameters, so baseline is 3. The description adds meaning for name/url (required), projectUuid (defaults to current repo), but it also introduces a 'credentials' parameter that is not in the schema (additionalProperties: false). This inconsistency misleads agents, reducing the score.

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 'Create a new environment under a DebuggAI project', specifies the required fields (name and url), optional description, project targeting via projectUuid, and even details the credentials seed feature. It effectively distinguishes the tool from siblings by referencing search_projects for UUIDs and check_app_in_browser for using the environment UUID.

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 explains when to use the tool (create environment), defaults (project from current git repo), and how to target a different project using search_projects. It also describes the credentials seed option and its best-effort behavior. However, it does not explicitly state when not to use this tool or mention alternatives for credential management.

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