Skip to main content
Glama
jakedx6
by jakedx6

create_document

Create markdown documents with optional metadata for project management in Helios-9. Specify title, content type, and project association to organize requirements, designs, technical specs, or meeting notes.

Instructions

Create a new document with markdown content and optional frontmatter metadata

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYesProject ID to associate the document with (required)
titleYesThe title of the document
contentYesThe markdown content of the document (can include YAML frontmatter)
document_typeYesThe type of document being created
metadataNoAdditional metadata for the document

Implementation Reference

  • The handler function for the 'create_document' MCP tool. Validates input using CreateDocumentSchema, performs content analysis, creates the document via supabaseService, and returns the document with analysis results.
    export const createDocument = requireAuth(async (args: any) => { const documentData = CreateDocumentSchema.parse(args) logger.info('Creating new document', { project_id: documentData.project_id, title: documentData.title, document_type: documentData.document_type }) // Parse frontmatter and analyze content const contentAnalysis = analyzeDocumentContentHelper(documentData.content, documentData.document_type) // Validate that project_id is provided if (!documentData.project_id) { throw new Error('project_id is required for document creation') } const document = await supabaseService.createDocument({ project_id: documentData.project_id, title: documentData.title, content: documentData.content, document_type: documentData.document_type // Removed format and metadata as they don't exist in the database schema }) logger.info('Document created successfully', { document_id: document.id, title: document.title }) return { document, content_analysis: contentAnalysis, message: `Document "${document.title}" created successfully` } })
  • Zod schema used internally by the create_document handler to parse and validate input arguments.
    const CreateDocumentSchema = z.object({ project_id: z.string().uuid().optional(), title: z.string().min(1).max(500), content: z.string(), document_type: z.enum(['requirement', 'design', 'technical', 'meeting_notes', 'other']), metadata: z.record(z.any()).optional() })
  • MCPTool registration object for 'create_document', defining name, description, and input schema for the tool.
    export const createDocumentTool: MCPTool = { name: 'create_document', description: 'Create a new document with markdown content and optional frontmatter metadata', inputSchema: { type: 'object', properties: { project_id: { type: 'string', format: 'uuid', description: 'Project ID to associate the document with (required)' }, title: { type: 'string', minLength: 1, maxLength: 500, description: 'The title of the document' }, content: { type: 'string', description: 'The markdown content of the document (can include YAML frontmatter)' }, document_type: { type: 'string', enum: ['requirement', 'design', 'technical', 'meeting_notes', 'other'], description: 'The type of document being created' }, metadata: { type: 'object', description: 'Additional metadata for the document' } }, required: ['title', 'content', 'document_type', 'project_id'] } }
  • Object exporting handlers by name, including create_document mapped to its handler function. Used by other modules to invoke the tool.
    export const documentHandlers = { list_documents: listDocuments, create_document: createDocument, get_document: getDocument, update_document: updateDocument, search_documents: searchDocuments, get_document_context: getDocumentContext, add_document_collaborator: addDocumentCollaborator, analyze_document_content: analyzeDocumentContent, get_document_collaboration: getDocumentCollaboration, generate_document_template: generateDocumentTemplate, bulk_document_operations: bulkDocumentOperations }
  • Helper function called by create_document handler to analyze the document content, extracting metrics like word count, headings, links, and AI readiness score.
    function analyzeDocumentContentHelper(content: string, documentType: string): object { // Parse frontmatter if present const frontmatterMatch = content.match(/^---\n([\s\S]*?)\n---/) const hasFrontmatter = !!frontmatterMatch // Extract plain content (without frontmatter) const plainContent = hasFrontmatter ? content.replace(/^---\n[\s\S]*?\n---\n/, '') : content // Basic content analysis const words = plainContent.split(/\s+/).filter(w => w.length > 0) const lines = plainContent.split('\n') const headings = (plainContent.match(/^#+\s+.+$/gm) || []).length const codeBlocks = (plainContent.match(/```[\s\S]*?```/g) || []).length const links = (plainContent.match(/\[([^\]]+)\]\([^)]+\)/g) || []).length const internalLinks = (plainContent.match(/\[\[([^\]]+)\]\]/g) || []).length return { word_count: words.length, line_count: lines.length, character_count: plainContent.length, heading_count: headings, code_block_count: codeBlocks, link_count: links, internal_link_count: internalLinks, has_frontmatter: hasFrontmatter, estimated_read_time: Math.ceil(words.length / 200), // 200 words per minute content_complexity: calculateContentComplexity(plainContent, documentType), ai_readiness_score: calculateAIReadinessScore(content, hasFrontmatter) } }

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/jakedx6/helios9-MCP-Server'

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