Skip to main content
Glama

update_navigation_order

Modify the navigation order of a document by updating its frontmatter with a specified path and order value. Enhances document organization within the MCP Documentation Service.

Instructions

Update the navigation order of a document by modifying its frontmatter.

Input Schema

NameRequiredDescriptionDefault
orderYes
pathYes

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "order": { "type": "number" }, "path": { "type": "string" } }, "required": [ "path", "order" ], "type": "object" }

Implementation Reference

  • The DocumentHandler.updateNavigationOrder method implements the core logic: validates path, reads file, parses frontmatter, updates 'order' field, reconstructs and writes back the file with success/error response.
    async updateNavigationOrder( docPath: string, order: number ): Promise<ToolResponse> { try { const validPath = await this.validatePath(docPath); // Check if file exists try { await fs.access(validPath); } catch { throw new Error(`File does not exist: ${docPath}`); } // Read the file const content = await fs.readFile(validPath, "utf-8"); // Parse frontmatter const { frontmatter, content: docContent } = parseFrontmatter(content); // Update order in frontmatter frontmatter.order = order; // Reconstruct content with updated frontmatter let frontmatterStr = "---\n"; for (const [key, value] of Object.entries(frontmatter)) { if (Array.isArray(value)) { frontmatterStr += `${key}:\n`; for (const item of value) { frontmatterStr += ` - ${item}\n`; } } else { frontmatterStr += `${key}: ${value}\n`; } } frontmatterStr += "---\n\n"; const updatedContent = frontmatterStr + docContent; // Write updated content await fs.writeFile(validPath, updatedContent, "utf-8"); return { content: [ { type: "text", text: `Successfully updated navigation order for ${docPath} to ${order}`, }, ], metadata: { path: docPath, order, }, }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Error updating navigation order: ${errorMessage}`, }, ], isError: true, }; }
  • Zod schema defining input parameters: path (string) and order (number). Extends base ToolInputSchema.
    export const UpdateNavigationOrderSchema = ToolInputSchema.extend({ path: z.string(), order: z.number(), });
  • src/index.ts:272-277 (registration)
    Tool registration in the listTools handler: defines name, description, and converts schema to JSON schema for MCP.
    { name: "update_documentation_navigation_order", description: "Update the navigation order of a document by modifying its frontmatter.", inputSchema: zodToJsonSchema(UpdateNavigationOrderSchema) as any, },
  • src/index.ts:442-453 (registration)
    Switch case in callToolRequest handler: validates args with schema, calls documentHandler.updateNavigationOrder if valid.
    case "update_documentation_navigation_order": { const parsed = UpdateNavigationOrderSchema.safeParse(args); if (!parsed.success) { throw new Error( `Invalid arguments for update_navigation_order: ${parsed.error}` ); } return await documentHandler.updateNavigationOrder( parsed.data.path, parsed.data.order ); }

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/alekspetrov/mcp-docs-service'

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