Skip to main content
Glama

docs-mcp-server

MarkdownMetadataExtractorMiddleware.ts956 B
import type { ContentProcessorMiddleware, MiddlewareContext } from "./types"; /** * Middleware to extract the title (first H1 heading) from Markdown content. */ export class MarkdownMetadataExtractorMiddleware implements ContentProcessorMiddleware { /** * Processes the context to extract the title from Markdown. * @param context The current processing context. * @param next Function to call the next middleware. */ async process(context: MiddlewareContext, next: () => Promise<void>): Promise<void> { try { let title = "Untitled"; const match = context.content.match(/^#\s+(.*)$/m); if (match?.[1]) { title = match[1].trim(); } context.metadata.title = title; } catch (error) { context.errors.push( new Error( `Failed to extract metadata from Markdown: ${error instanceof Error ? error.message : String(error)}`, ), ); } await next(); } }

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/arabold/docs-mcp-server'

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