Skip to main content
Glama

analyze_project_with_metadata

Analyze project structure, generate documentation files, and enrich with metadata to create a searchable knowledge base for clear project understanding.

Instructions

Analyze project structure, create initial documentation files, and enhance with metadata/context

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectPathYesPath to the project root directory

Implementation Reference

  • Main execution logic for the 'analyze_project_with_metadata' tool. Initializes .handoff_docs directory, creates default MD files if missing, analyzes content with remark, categorizes, generates metadata, finds related docs, updates search index, adds YAML frontmatter, and returns project status with git info.
        case "analyze_project_with_metadata": {
          const { projectPath } = request.params.arguments as { projectPath: string };
          const docsPath = `${projectPath}/.handoff_docs`;
    
          try {
            // First run the standard analyze_project workflow
            await fs.mkdir(docsPath, { recursive: true });
    
            // Initialize default documentation files if they don't exist
            for (const doc of DEFAULT_DOCS) {
              const filePath = `${docsPath}/${doc}`;
              try {
                await fs.access(filePath);
              } catch {
                const title = doc.replace(".md", "")
                  .split(/[_-]/)
                  .map(word => word.charAt(0).toUpperCase() + word.slice(1))
                  .join(" ");
                await fs.writeFile(filePath, TEMPLATE_CONTENT.replace("{title}", title));
              }
            }
    
            // Reset state
            state = {
              currentFile: null,
              completedFiles: [],
              inProgress: false,
              lastReadFile: null,
              lastReadContent: null,
              continueToNext: false,
              metadata: {},
              contextCache: {},
              templateOverrides: {}
            };
    
            // Clear existing search index
            searchEngine.removeAll();
    
            // Now enhance each file with metadata and context
            for (const doc of DEFAULT_DOCS) {
              const filePath = `${docsPath}/${doc}`;
              const content = await fs.readFile(filePath, "utf8");
    
              // Use unified/remark to analyze content structure
              const analysis = await analyzeContent(content);
    
              // Use enhanced categorization
              const { category, tags } = categorizeContent(doc, content, analysis);
    
              // Generate metadata
              const metadata = {
                title: analysis.title || doc.replace(".md", "")
                  .split(/[_-]/)
                  .map(word => word.charAt(0).toUpperCase() + word.slice(1))
                  .join(" "),
                category,
                tags,
                lastUpdated: new Date().toISOString()
              };
    
              // Update metadata for the file
              await updateMetadata(filePath, metadata);
    
              // Find and update related docs
              const relatedDocs = await findRelatedDocs(doc, projectPath);
              await updateMetadata(filePath, { relatedDocs });
    
              // Update search index with full content and metadata
              updateSearchIndex(doc, content, {
                ...metadata,
                relatedDocs
              });
    
              // Add structured front matter to content
              const enhancedContent = `---
    title: ${metadata.title}
    category: ${metadata.category}
    tags: ${metadata.tags.join(', ')}
    lastUpdated: ${metadata.lastUpdated}
    relatedDocs: ${relatedDocs.join(', ')}
    ---
    
    ${content}`;
    
              // Update file with enhanced content
              await fs.writeFile(filePath, enhancedContent);
            }
    
            // Get project info for additional context
            let gitInfo = {};
            try {
              gitInfo = {
                remoteUrl: execSync("git config --get remote.origin.url", { cwd: projectPath }).toString().trim(),
                branch: execSync("git branch --show-current", { cwd: projectPath }).toString().trim(),
                lastCommit: execSync("git log -1 --format=%H", { cwd: projectPath }).toString().trim()
              };
            } catch {
              // Not a git repository or git not available
            }
    
            return {
              content: [
                {
                  type: "text",
                  text: JSON.stringify({
                    message: "Documentation structure initialized with metadata and context",
                    docsPath,
                    files: DEFAULT_DOCS,
                    metadata: state.metadata,
                    gitInfo,
                    contextCache: {
                      timestamp: state.contextCache.timestamp,
                      ttl: CACHE_TTL
                    }
                  }, null, 2)
                }
              ]
            };
          } catch (error: unknown) {
            const errorMessage = error instanceof Error ? error.message : String(error);
            throw new McpError(
              ErrorCode.InternalError,
              `Error initializing documentation with metadata: ${errorMessage}`
            );
          }
        }
  • src/index.ts:404-417 (registration)
    Tool registration in ListToolsRequestSchema handler, including name, description, and input schema definition.
    {
      name: "analyze_project_with_metadata",
      description: "Analyze project structure, create initial documentation files, and enhance with metadata/context",
      inputSchema: {
        type: "object",
        properties: {
          projectPath: {
            type: "string",
            description: "Path to the project root directory"
          }
        },
        required: ["projectPath"]
      }
    },
  • Input schema definition for the tool, specifying projectPath as required string parameter.
    inputSchema: {
      type: "object",
      properties: {
        projectPath: {
          type: "string",
          description: "Path to the project root directory"
        }
      },
      required: ["projectPath"]
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions actions ('analyze', 'create', 'enhance') but doesn't specify permissions needed, whether files are overwritten, error handling, or output format. For a tool with multiple implied operations, this is insufficient.

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 a single, efficient sentence that front-loads key actions. It uses parallel structure ('analyze...create...enhance') with zero wasted words, making it easy to parse quickly.

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 the complexity implied by multiple operations (analysis, file creation, metadata enhancement), no annotations, and no output schema, the description is incomplete. It lacks details on what 'enhance with metadata/context' entails, file types created, or success/failure indicators.

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?

The schema description coverage is 100%, with the single parameter 'projectPath' well-documented in the schema. The description adds no additional parameter details beyond implying analysis scope, so it meets the baseline for high schema coverage without compensating value.

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 with specific verbs ('analyze', 'create', 'enhance') and resources ('project structure', 'documentation files', 'metadata/context'). It distinguishes from siblings like 'analyze_project' by mentioning documentation creation and metadata enhancement, though it could be more explicit about the differences.

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 like 'analyze_project' or 'analyze_existing_docs'. It lacks explicit context, prerequisites, or exclusions, leaving the agent to infer usage from the purpose alone.

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

Related 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/ryanjoachim/mcp-rtfm'

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