associate_document_with_initiative
Link a document to an initiative by providing the initiative ID and document ID.
Instructions
Link an existing document to an initiative
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| initiative_id | Yes | The initiative ID to associate the document with | |
| document_id | Yes | The document ID to associate with the initiative |
Implementation Reference
- src/tools/initiatives.ts:549-568 (handler)The main handler function for associate_document_with_initiative. Validates inputs with Zod (initiative_id and document_id as UUIDs), logs the operation, calls the API client to create the association, and returns a success response.
export const associateDocumentWithInitiative = requireAuth(async (args: any) => { const { initiative_id, document_id } = z.object({ initiative_id: z.string().uuid(), document_id: z.string().uuid() }).parse(args) logger.info('Associating document with initiative', { initiative_id, document_id }) // Call the API to create the association const response = await supabaseService.associateDocumentWithInitiative(initiative_id, document_id) logger.info('Document associated with initiative successfully') return { success: true, message: `Document successfully associated with initiative`, initiative_id, document_id } }) - src/tools/initiatives.ts:528-547 (schema)The MCP tool definition (MCPTool object) including the name, description, and input JSON Schema for associate_document_with_initiative. Defines initiative_id and document_id as required UUID strings.
export const associateDocumentWithInitiativeTool: MCPTool = { name: 'associate_document_with_initiative', description: 'Link an existing document to an initiative', inputSchema: { type: 'object', properties: { initiative_id: { type: 'string', format: 'uuid', description: 'The initiative ID to associate the document with' }, document_id: { type: 'string', format: 'uuid', description: 'The document ID to associate with the initiative' } }, required: ['initiative_id', 'document_id'] } } - src/tools/initiatives.ts:626-626 (registration)Tool registration: associateDocumentWithInitiativeTool is exported in the initiativeTools object.
associateDocumentWithInitiativeTool, - src/tools/initiatives.ts:640-640 (registration)Handler registration: the associateDocumentWithInitiative handler is mapped to the name 'associate_document_with_initiative' in the initiativeHandlers export object.
associate_document_with_initiative: associateDocumentWithInitiative, - src/lib/api-client.ts:566-574 (helper)The API client helper method that makes the actual HTTP POST request to /api/mcp/initiatives/{initiativeId}/documents to associate a document with an initiative.
async associateDocumentWithInitiative(initiativeId: string, documentId: string): Promise<any> { const response = await this.request<{ success: boolean }>(`/api/mcp/initiatives/${initiativeId}/documents`, { method: 'POST', body: JSON.stringify({ document_id: documentId }), }) logger.info(`Document ${documentId} associated with initiative ${initiativeId}`) return response }