create_document
Create new markdown documents with structured metadata for project management in Helios-9, supporting requirements, designs, technical specs, and meeting notes.
Instructions
Create a new document with markdown content and optional frontmatter metadata
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | Project ID to associate the document with (required) | |
| title | Yes | The title of the document | |
| content | Yes | The markdown content of the document (can include YAML frontmatter) | |
| document_type | Yes | The type of document being created | |
| metadata | No | Additional metadata for the document |
Implementation Reference
- src/tools/documents.ts:154-186 (handler)The main handler function for the 'create_document' tool. It validates input using CreateDocumentSchema, performs content analysis, creates the document using supabaseService.createDocument, logs the action, and returns the created 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` } })
- src/tools/documents.ts:29-35 (schema)Zod schema used for validating and parsing the input arguments in the create_document handler.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() })
- src/tools/documents.ts:119-152 (registration)MCPTool object defining the 'create_document' tool, including its name, description, and detailed inputSchema for the MCP protocol.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'] } }
- src/tools/documents.ts:1346-1358 (registration)Exported handlers object that maps tool names to their handler functions, including 'create_document' to createDocument. 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 }