Skip to main content
Glama

generate_project

Create project specifications and generate file structures from user prompts. Automatically produces MCP file proposals for documentation and project setup.

Instructions

Generate a project spec and return MCP create_file/edit_file proposals. Set allowWrite=true to write files.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYes
allowWriteNo

Implementation Reference

  • The handler function for generating a project. It generates file structure and contents using LLM calls, saves run artifacts if enabled, and either proposes file creations (dry-run) or materializes them to disk.
    async function generateProject(userPrompt, { allowWrite = false, saveRun = true } = {}) {
      const ts = new Date().toISOString().replace(/[:.]/g, '-');
      const runDir = path.resolve(process.cwd(), '.runs');
      if (saveRun && !fs.existsSync(runDir)) fs.mkdirSync(runDir, { recursive: true });
    
      const structure = await generateStructure(userPrompt, ts);
      const filesMap = await generateContents(userPrompt, structure, ts);
    
      const proposals = proposeCreatesFromFiles(filesMap);
    
      if (saveRun) {
        const artifact = { timestamp: ts, params: { model: config.model }, structure, files: Object.keys(filesMap) };
        fs.writeFileSync(path.join(runDir, `${ts}.json`), JSON.stringify(artifact, null, 2));
      }
    
      if (!allowWrite) return proposals;
      return materialize(filesMap, { allowWrite: true });
    }
  • Registers the generateProject function by exporting it from the orchestrator module, allowing it to be imported and used (e.g., in CLI).
    module.exports = { generateStructure, generateContents, generateProject };
  • Helper function to generate the project file/folder structure using an LLM call and validate it against a schema.
    async function generateStructure(userPrompt, runId) {
      const systemPrompt = fs.readFileSync(config.systemPromptPath, 'utf8');
      const llmCall = config.provider === 'openai' ? callOpenAI : callAnthropic;
      const text = await llmCall({
        systemPrompt,
        userPrompt: buildStructureUserPrompt(userPrompt),
        model: config.model,
        temperature: config.temperature,
        timeoutMs: config.timeoutMs,
        maxRetries: config.maxRetries,
        baseDelayMs: config.baseDelayMs
      });
      if (typeof text !== 'string') {
        throw new Error('Model response was not text');
      }
      writeRunText(runId, 'structure.raw', text);
      const json = extractJson(text);
      // Normalize: keep only file paths and ensure empty content for structure step
      const files = json && json.files && typeof json.files === 'object' ? Object.keys(json.files) : [];
      const normalized = {
        folders: Array.isArray(json.folders) ? json.folders : ['specs', 'docs'],
        files: files.reduce((acc, p) => { acc[p] = ""; return acc; }, {})
      };
      const ok = validateStructure(normalized);
      if (!ok) throw new Error('Structure JSON failed validation: ' + ajv.errorsText(validateStructure.errors));
      return normalized;
    }
  • Helper function to generate file contents in batches using LLM calls and validate.
    async function generateContents(userPrompt, structure, runId) {
      const systemPrompt = fs.readFileSync(config.systemPromptPath, 'utf8');
      const allPaths = Object.keys(structure.files || {});
      const batches = chunkArray(allPaths, 3);
      const merged = {};
      for (let i = 0; i < batches.length; i++) {
        const prompt = buildContentBatchPrompt(userPrompt, batches[i]);
        const llmCall2 = config.provider === 'openai' ? callOpenAI : callAnthropic;
        const text = await llmCall2({
          systemPrompt,
          userPrompt: prompt,
          model: config.model,
          temperature: config.temperature,
          timeoutMs: config.timeoutMs,
          maxRetries: config.maxRetries,
          baseDelayMs: config.baseDelayMs
        });
        if (typeof text !== 'string') {
          throw new Error('Model response was not text');
        }
        writeRunText(runId, `files.batch-${i + 1}.raw`, text);
        const json = extractJson(text);
        const ok = validateFiles(json);
        if (!ok) throw new Error('Files JSON failed validation: ' + ajv.errorsText(validateFiles.errors));
        Object.assign(merged, json.files);
      }
      return merged;
    }
  • Helper to materialize (write) the generated files to disk or return proposals.
    async function materialize(filesMap, { allowWrite = false } = {}) {
      const results = [];
      for (const [filePath, content] of Object.entries(filesMap)) {
        results.push(createFile(filePath, content, { allowWrite }));
      }
      return results;
    }
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses that the tool returns MCP create_file/edit_file proposals and requires 'allowWrite=true' for writing files, adding some behavioral context. However, it doesn't cover aspects like rate limits, error handling, or what happens if 'allowWrite' is false, leaving gaps in transparency.

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

Conciseness4/5

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

The description is brief and front-loaded, stating the main action in the first part. Both sentences are relevant, with no wasted words, making it efficient. However, it could be slightly more structured to separate purpose from usage instructions.

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

Completeness2/5

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

Given no annotations, no output schema, and low schema coverage, the description is incomplete. It lacks details on the generated project spec's format, what the proposals entail, error conditions, or return values. For a tool with two parameters and behavioral complexity, this leaves significant gaps in understanding.

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?

Schema description coverage is 0%, so the description must compensate. It explains that 'allowWrite' controls file writing, adding meaning beyond the schema. However, it doesn't describe the 'prompt' parameter's purpose or format, leaving one of the two parameters undocumented. This partial compensation is insufficient for full clarity.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the tool generates a project spec and returns MCP proposals, which provides a basic purpose. However, it's somewhat vague about what a 'project spec' entails and doesn't specify the format or content of the generated spec. No sibling tools exist for comparison, so differentiation isn't applicable.

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

Usage Guidelines2/5

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

The description mentions setting 'allowWrite=true to write files,' which implies usage for file creation, but provides no guidance on when to use this tool versus alternatives or any prerequisites. It lacks explicit when/when-not instructions or context for appropriate use cases.

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/Huxley-Brown/Project-Setup-MCP-Project'

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