get_document_path
Retrieve the file path for specific documentation based on feature ID and document type, streamlining access to critical project resources within structured coding workflows.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| documentType | Yes | ||
| featureId | Yes |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"documentType": {
"minLength": 1,
"type": "string"
},
"featureId": {
"minLength": 1,
"type": "string"
}
},
"required": [
"featureId",
"documentType"
],
"type": "object"
}
Implementation Reference
- src/mcp-server.ts:631-682 (registration)Registers the 'get_document_path' MCP tool with name, input schema, and inline handler function.server.tool( "get_document_path", { featureId: z.string().min(1), documentType: z.string().min(1) }, async ({ featureId, documentType }) => { 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}`); } // Get the default file path for the document const filePath = documentStorage.getDefaultFilePath(feature.id, docType); // Get the document to check if it's been saved const document = documentStorage.getDocument(feature.id, docType); return { content: [{ type: "text", text: `Document path: ${filePath}\nSaved to disk: ${document?.metadata.isSaved ? 'Yes' : 'No'}` }] }; } catch (error) { return { content: [{ type: "text", text: `Error retrieving document path: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } );
- src/mcp-server.ts:637-681 (handler)The core handler function that validates inputs, maps document type, retrieves the default file path using documentStorage, and returns the path along with save status.async ({ featureId, documentType }) => { 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}`); } // Get the default file path for the document const filePath = documentStorage.getDefaultFilePath(feature.id, docType); // Get the document to check if it's been saved const document = documentStorage.getDocument(feature.id, docType); return { content: [{ type: "text", text: `Document path: ${filePath}\nSaved to disk: ${document?.metadata.isSaved ? 'Yes' : 'No'}` }] }; } catch (error) { return { content: [{ type: "text", text: `Error retrieving document path: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } }
- src/mcp-server.ts:633-636 (schema)Zod schema defining input parameters: featureId (string, min 1) and documentType (string, min 1).{ featureId: z.string().min(1), documentType: z.string().min(1) },
- src/document-storage.ts:306-308 (helper)Public helper method that returns the default file path for a document by delegating to private getDocumentPath.public getDefaultFilePath(featureId: string, type: DocumentType): string { return this.getDocumentPath(featureId, type); }
- src/document-storage.ts:113-117 (helper)Private helper method that constructs the actual file path: rootDir/featureId/{type}.mdprivate getDocumentPath(featureId: string, type: DocumentType): string { const featureDir = path.join(this.options.rootDir, featureId); const filename = `${type}.md`; return path.join(featureDir, filename); }