Skip to main content
Glama

generate_llm_context

Create comprehensive LLM context documentation for tools, memory systems, and workflows to enable easy reference within projects.

Instructions

Generate a comprehensive LLM context reference file documenting all tools, memory system, and workflows for easy @ reference

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectPathYesPath to the project root directory where LLM_CONTEXT.md will be generated
includeExamplesNoInclude usage examples for tools
formatNoLevel of detail in the generated contextdetailed

Implementation Reference

  • The primary handler function for the 'generate_llm_context' tool. It validates the input parameters, dynamically loads tool definitions from src/index.js, generates comprehensive Markdown content summarizing all tools and system capabilities, writes it to LLM_CONTEXT.md in the project root, and returns a structured MCP response with stats and next steps.
    export async function generateLLMContext(
      params: Partial<GenerateLLMContextInput>,
    ): Promise<any> {
      try {
        // Parse with defaults
        const validated = GenerateLLMContextInputSchema.parse(params);
        const { projectPath, includeExamples, format } = validated;
    
        // Always generate LLM_CONTEXT.md in the project root
        const outputPath = path.join(projectPath, "LLM_CONTEXT.md");
    
        // Get tool definitions dynamically
        const toolDefinitions = await getToolDefinitions();
    
        // Generate the context content
        const content = generateContextContent(
          includeExamples,
          format,
          toolDefinitions,
        );
    
        // Write the file
        await fs.writeFile(outputPath, content, "utf-8");
    
        const metadata = {
          toolVersion: "0.4.1",
          executionTime: 0,
          timestamp: new Date().toISOString(),
        };
    
        return formatMCPResponse({
          success: true,
          data: {
            message: `LLM context file generated successfully at ${outputPath}`,
            path: path.resolve(outputPath),
            stats: {
              totalTools: toolDefinitions.length,
              fileSize: Buffer.byteLength(content, "utf-8"),
              sections: [
                "Overview",
                "Core Tools",
                "README Tools",
                "Memory System",
                "Phase 3 Features",
                "Workflows",
                "Quick Reference",
              ],
            },
          },
          metadata,
          nextSteps: [
            {
              action:
                "Reference this file with @LLM_CONTEXT.md in your LLM conversations",
              priority: "high" as const,
            },
            {
              action: "Regenerate periodically when new tools are added",
              toolRequired: "generate_llm_context",
              priority: "low" as const,
            },
            {
              action: "Use this as a quick reference for DocuMCP capabilities",
              priority: "medium" as const,
            },
          ],
        });
      } catch (error: any) {
        return formatMCPResponse({
          success: false,
          error: {
            code: "GENERATION_ERROR",
            message: `Failed to generate LLM context: ${error.message}`,
          },
          metadata: {
            toolVersion: "0.4.1",
            executionTime: 0,
            timestamp: new Date().toISOString(),
          },
        });
      }
    }
  • Zod schema for input validation of the generate_llm_context tool. Defines required projectPath and optional includeExamples and format parameters.
    export const GenerateLLMContextInputSchema = z.object({
      projectPath: z
        .string()
        .describe(
          "Path to the project root directory where LLM_CONTEXT.md will be generated",
        ),
      includeExamples: z
        .boolean()
        .optional()
        .default(true)
        .describe("Include usage examples for tools"),
      format: z
        .enum(["detailed", "concise"])
        .optional()
        .default("detailed")
        .describe("Level of detail in the generated context"),
    });
  • Helper function to dynamically import and cache the TOOLS array from src/index.js, used by the handler to get all available tool definitions for generating the context file.
    async function getToolDefinitions(): Promise<any[]> {
      if (cachedTools) return cachedTools;
    
      try {
        const indexModule = await import("../index.js");
        cachedTools = indexModule.TOOLS || [];
        return cachedTools;
      } catch (error) {
        console.warn("Could not load TOOLS from index.js:", error);
        return [];
      }
    }
  • Helper function called from src/index.ts to set the cached tool definitions directly, avoiding circular dependency issues.
    /**
     * Set tool definitions for the context generator
     * This is called from src/index.ts when TOOLS array is initialized
     */
    export function setToolDefinitions(tools: any[]) {
      cachedTools = tools;
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool generates a file but doesn't disclose key traits like whether it overwrites existing files, requires specific permissions, has side effects, or handles errors. For a file-generation tool with zero annotation coverage, this is a significant gap 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 a single, efficient sentence that front-loads the core purpose. It avoids unnecessary words and gets straight to the point, though it could be slightly more structured by separating key elements like output format or usage context.

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's complexity (generating a comprehensive reference file) and lack of annotations or output schema, the description is minimally adequate. It states what is generated but misses details like file format (implied as .md), location specifics, or behavioral expectations. This leaves gaps for an agent to fully understand the tool's operation.

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 (projectPath, includeExamples, format) with descriptions. The description doesn't add any meaning beyond what the schema provides, such as explaining the impact of 'includeExamples' or 'format' choices. Baseline 3 is appropriate when the schema does the heavy lifting.

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

Purpose4/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: 'Generate a comprehensive LLM context reference file documenting all tools, memory system, and workflows for easy @ reference.' It specifies the verb 'generate' and the resource 'LLM context reference file,' and mentions what content it documents (tools, memory system, workflows). However, it doesn't explicitly differentiate from sibling tools like 'generate_config' or 'generate_contextual_content,' which slightly limits clarity.

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 provides no guidance on when to use this tool versus alternatives. It doesn't mention any prerequisites, context for usage, or comparisons to sibling tools such as 'generate_config' or 'memory_export.' This lack of explicit when/when-not instructions or alternatives leaves the agent with minimal usage direction.

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/tosin2013/documcp'

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