Skip to main content
Glama

generate_code

Generate or modify code in AICre8 projects using AI. Write files, install packages, and update projects based on prompts.

Instructions

Send a prompt to generate or modify code in an AICre8 project using AI. The AI will write files, install packages, and update the project. Costs 1 credit per call.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYesProject ID (UUID or url_id)
promptYesWhat to build or change
chat_modeNoMode: "build" generates code (default), "discuss" for conversation only

Implementation Reference

  • The generateCode method in AICre8Client class handles the core logic: makes a POST request to /projects/{projectId}/generate endpoint, handles SSE stream response by reading chunks and returning the full accumulated result text.
    async generateCode(
      projectId: string,
      params: { prompt: string; chat_mode?: 'build' | 'discuss' },
    ): Promise<string> {
      const url = `${this.baseUrl}/projects/${projectId}/generate`;
    
      const res = await fetch(url, {
        method: 'POST',
        headers: this.headers,
        body: JSON.stringify(params),
      });
    
      if (!res.ok) {
        const error = await res.json().catch(() => ({ error: res.statusText }));
        throw new Error(
          `AICre8 API error ${res.status}: ${(error as any).error || res.statusText}`,
        );
      }
    
      // The response is an SSE stream — consume it and return the full text
      const reader = res.body?.getReader();
    
      if (!reader) {
        throw new Error('No response body');
      }
    
      const decoder = new TextDecoder();
      let result = '';
    
      while (true) {
        const { done, value } = await reader.read();
    
        if (done) {
          break;
        }
    
        result += decoder.decode(value, { stream: true });
      }
    
      return result;
    }
  • src/index.ts:86-112 (registration)
    Tool registration with MCP server using server.tool(). Registers 'generate_code' with description, Zod schema for inputs (project_id, prompt, chat_mode), and async handler that calls client.generateCode() and returns the result as text content.
    // ── Tool: generate_code ──
    
    server.tool(
      'generate_code',
      'Send a prompt to generate or modify code in an AICre8 project using AI. The AI will write files, install packages, and update the project. Costs 1 credit per call.',
      {
        project_id: z.string().describe('Project ID (UUID or url_id)'),
        prompt: z.string().describe('What to build or change'),
        chat_mode: z
          .enum(['build', 'discuss'])
          .optional()
          .describe('Mode: "build" generates code (default), "discuss" for conversation only'),
      },
      async (params) => {
        try {
          const result = await client.generateCode(params.project_id, {
            prompt: params.prompt,
            chat_mode: params.chat_mode,
          });
          return {
            content: [{ type: 'text' as const, text: result }],
          };
        } catch (err: any) {
          return { content: [{ type: 'text' as const, text: `Error: ${err.message}` }], isError: true };
        }
      },
    );
  • Zod schema defining the input parameters for generate_code tool: project_id (required string), prompt (required string), and chat_mode (optional enum of 'build' or 'discuss').
    {
      project_id: z.string().describe('Project ID (UUID or url_id)'),
      prompt: z.string().describe('What to build or change'),
      chat_mode: z
        .enum(['build', 'discuss'])
        .optional()
        .describe('Mode: "build" generates code (default), "discuss" for conversation only'),
    },
Behavior4/5

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

With no annotations provided, the description carries the full burden and adds valuable behavioral context beyond basic functionality: it discloses that the tool 'will write files, install packages, and update the project' and includes cost information ('Costs 1 credit per call'), though it lacks details on error handling or rate limits.

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 appropriately sized and front-loaded, with two concise sentences that efficiently convey the tool's purpose, actions, and cost without any wasted words, making it easy for an agent to parse quickly.

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?

Given the tool's complexity (AI-driven code generation with side effects) and no annotations or output schema, the description is mostly complete: it covers purpose, actions, and cost. However, it lacks details on return values or error conditions, which could help an agent handle responses better.

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%, so the schema already documents all three parameters. The description does not add any parameter-specific details beyond what the schema provides, such as examples for the prompt or project_id formats, resulting in a baseline score 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 the tool's purpose with specific verbs ('generate or modify code') and resources ('AICre8 project using AI'), distinguishing it from siblings like create_project or write_file by focusing on AI-driven code generation rather than manual file operations or project management.

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 clear context for when to use this tool ('Send a prompt to generate or modify code') and mentions a cost implication ('Costs 1 credit per call'), but it does not explicitly state when not to use it or name alternatives like write_file for manual edits, leaving some guidance gaps.

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/AICre8dev/mcp-server'

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