Skip to main content
Glama

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
NameRequiredDescriptionDefault
docFileYesName of the documentation file
metadataYesMetadata to update
projectPathYesPath to the project root directory

Implementation Reference

  • 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}`
        );
      }
    }
  • 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"]
      }
    },
  • 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"]
      }
    },
Install Server

Other Tools

Related Tools

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/ryanjoachim/mcp-rtfm'

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