Skip to main content
Glama
crazyrabbitLTC

Vibe-Coder MCP Server

save_document

Save structured documentation for coding features by specifying feature ID, document type, and file path to organize development workflow.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
featureIdYes
documentTypeYes
filePathNo

Implementation Reference

  • The main handler function for the 'save_document' tool. Validates inputs, checks feature and document existence, maps string to DocumentType enum, and delegates saving to documentStorage helpers based on whether custom filePath is provided.
    async ({ featureId, documentType, filePath }) => {
      try {
        // Check if the feature exists
        const feature = getFeature(featureId);
        if (!feature) {
          throw new Error(`Feature ${featureId} not found`);
        }
        
        // Map the string to DocumentType enum
        let docType: DocumentType;
        if (documentType === 'prd') {
          docType = DocumentType.PRD;
        } else if (documentType === 'implementation-plan') {
          docType = DocumentType.IMPLEMENTATION_PLAN;
        } else {
          throw new Error(`Invalid document type: ${documentType}. Expected 'prd' or 'implementation-plan'`);
        }
        
        // Check if the document exists
        if (!documentStorage.hasDocument(feature.id, docType)) {
          throw new Error(`Document of type ${documentType} not found for feature ${feature.id}`);
        }
        
        let savedPath: string;
        
        // If a custom path was provided, use it; otherwise, save to the default path
        if (filePath) {
          savedPath = await documentStorage.saveDocumentToCustomPath(feature.id, docType, filePath);
        } else {
          savedPath = await documentStorage.saveDocumentToFile(feature.id, docType);
        }
        
        return {
          content: [{
            type: "text",
            text: `Document saved successfully to: ${savedPath}`
          }]
        };
      } catch (error) {
        return {
          content: [{
            type: "text",
            text: `Error saving document: ${error instanceof Error ? error.message : String(error)}`
          }],
          isError: true
        };
      }
    }
  • Zod input schema for the save_document tool parameters: featureId (required), documentType (required, e.g. 'prd'), filePath (optional custom path).
    {
      featureId: z.string().min(1),
      documentType: z.string().min(1),
      filePath: z.string().min(1).optional()
  • Registration of the save_document tool on the MCP server using server.tool(name, inputSchema, handlerFn).
    server.tool(
      "save_document",
      {
        featureId: z.string().min(1),
        documentType: z.string().min(1),
        filePath: z.string().min(1).optional()
      },
      async ({ featureId, documentType, filePath }) => {
        try {
          // Check if the feature exists
          const feature = getFeature(featureId);
          if (!feature) {
            throw new Error(`Feature ${featureId} not found`);
          }
          
          // Map the string to DocumentType enum
          let docType: DocumentType;
          if (documentType === 'prd') {
            docType = DocumentType.PRD;
          } else if (documentType === 'implementation-plan') {
            docType = DocumentType.IMPLEMENTATION_PLAN;
          } else {
            throw new Error(`Invalid document type: ${documentType}. Expected 'prd' or 'implementation-plan'`);
          }
          
          // Check if the document exists
          if (!documentStorage.hasDocument(feature.id, docType)) {
            throw new Error(`Document of type ${documentType} not found for feature ${feature.id}`);
          }
          
          let savedPath: string;
          
          // If a custom path was provided, use it; otherwise, save to the default path
          if (filePath) {
            savedPath = await documentStorage.saveDocumentToCustomPath(feature.id, docType, filePath);
          } else {
            savedPath = await documentStorage.saveDocumentToFile(feature.id, docType);
          }
          
          return {
            content: [{
              type: "text",
              text: `Document saved successfully to: ${savedPath}`
            }]
          };
        } catch (error) {
          return {
            content: [{
              type: "text",
              text: `Error saving document: ${error instanceof Error ? error.message : String(error)}`
            }],
            isError: true
          };
        }
      }
    );
  • Helper function that saves a document to its default file path (computed as documents/{featureId}/{type}.md), ensures directory exists, writes content, updates isSaved metadata.
    public async saveDocumentToFile(featureId: string, type: DocumentType): Promise<string> {
      const document = this.getDocument(featureId, type);
      
      if (!document) {
        throw new Error(`Document not found: ${featureId}:${type}`);
      }
      
      const filePath = document.metadata.filePath!;
      const dirPath = path.dirname(filePath);
      
      await this.ensureDir(dirPath);
      await fs.writeFile(filePath, document.content, 'utf-8');
      
      // Update metadata
      document.metadata.isSaved = true;
      
      return filePath;
    }
  • Helper function that saves a document to a custom file path after validating it (path traversal protection, .md extension, within rootDir), ensures dir, writes content, marks saved.
    public async saveDocumentToCustomPath(
      featureId: string, 
      type: DocumentType, 
      customPath: string
    ): Promise<string> {
      const document = this.getDocument(featureId, type);
      
      if (!document) {
        throw new Error(`Document not found: ${featureId}:${type}`);
      }
      
      const validatedPath = this.validateCustomPath(customPath);
      const dirPath = path.dirname(validatedPath);
      
      await this.ensureDir(dirPath);
      await fs.writeFile(validatedPath, document.content, 'utf-8');
      
      // Don't update metadata.filePath as we want to keep the default path
      // Just mark it as saved
      document.metadata.isSaved = true;
      
      return validatedPath;
    }
Behavior1/5

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

Tool has no description.

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

Conciseness1/5

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

Tool has no description.

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

Completeness1/5

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

Tool has no description.

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

Parameters1/5

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

Tool has no description.

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

Purpose1/5

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

Tool has no description.

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

Usage Guidelines1/5

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

Tool has no description.

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/crazyrabbitLTC/mcp-vibecoder'

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