update_metadata
Modify metadata for documentation files in a project, including title, category, and tags, to enhance organization and searchability within the mcp-rtfm knowledge base.
Instructions
Update metadata for a documentation file
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| docFile | Yes | Name of the documentation file | |
| metadata | Yes | Metadata to update | |
| projectPath | Yes | Path to the project root directory |
Implementation Reference
- src/index.ts:1092-1123 (handler)MCP CallTool handler for 'update_metadata': extracts parameters, verifies file existence, calls updateMetadata helper, and returns JSON response with updated metadata.case "update_metadata": { const { projectPath, docFile, metadata } = request.params.arguments as { projectPath: string; docFile: string; metadata: Partial<DocMetadata>; }; try { const filePath = `${projectPath}/.handoff_docs/${docFile}`; await fs.access(filePath); // Verify file exists await updateMetadata(filePath, metadata); return { content: [ { type: "text", text: JSON.stringify({ message: "Metadata updated successfully", file: docFile, metadata: state.metadata[docFile] }, null, 2) } ] }; } catch (error: unknown) { const errorMessage = error instanceof Error ? error.message : String(error); throw new McpError( ErrorCode.InternalError, `Error updating metadata: ${errorMessage}` ); } }
- src/index.ts:530-556 (schema)Input schema definition for the update_metadata tool, including parameters projectPath, docFile, and metadata object.{ name: "update_metadata", description: "Update metadata for a documentation file", inputSchema: { type: "object", properties: { projectPath: { type: "string", description: "Path to the project root directory" }, docFile: { type: "string", description: "Name of the documentation file" }, metadata: { type: "object", description: "Metadata to update", properties: { title: { type: "string" }, category: { type: "string" }, tags: { type: "array", items: { type: "string" } } } } }, required: ["projectPath", "docFile", "metadata"] } },
- src/index.ts:197-204 (helper)Helper function that updates the global state.metadata for a document by merging provided partial metadata and setting lastUpdated timestamp.const updateMetadata = async (filePath: string, metadata: Partial<DocMetadata>) => { const fileName = filePath.split('/').pop() as string; state.metadata[fileName] = { ...state.metadata[fileName], ...metadata, lastUpdated: new Date().toISOString() } as DocMetadata; };
- src/index.ts:530-556 (registration)Tool registration entry in the ListTools response, defining name, description, and inputSchema.{ name: "update_metadata", description: "Update metadata for a documentation file", inputSchema: { type: "object", properties: { projectPath: { type: "string", description: "Path to the project root directory" }, docFile: { type: "string", description: "Name of the documentation file" }, metadata: { type: "object", description: "Metadata to update", properties: { title: { type: "string" }, category: { type: "string" }, tags: { type: "array", items: { type: "string" } } } } }, required: ["projectPath", "docFile", "metadata"] } },