Skip to main content
Glama
ContentAssemblyStrategyFactory.ts1.49 kB
import { HierarchicalAssemblyStrategy } from "./strategies/HierarchicalAssemblyStrategy"; import { MarkdownAssemblyStrategy } from "./strategies/MarkdownAssemblyStrategy"; import type { ContentAssemblyStrategy } from "./types"; /** * Creates the appropriate assembly strategy based on content MIME type. * * @param mimeType The MIME type of the content (optional) * @returns The appropriate strategy instance */ export function createContentAssemblyStrategy( mimeType?: string | null, ): ContentAssemblyStrategy { // Default to MarkdownAssemblyStrategy for unknown or missing MIME types if (!mimeType) { return new MarkdownAssemblyStrategy(); } // Try each strategy to see which one can handle the content type const strategies = [new HierarchicalAssemblyStrategy(), new MarkdownAssemblyStrategy()]; for (const strategy of strategies) { if (strategy.canHandle(mimeType)) { return strategy; } } // Default fallback to MarkdownAssemblyStrategy return new MarkdownAssemblyStrategy(); } /** * Gets a human-readable name for the strategy that would be selected. * Useful for logging and debugging. */ export function getStrategyName(mimeType?: string): string { if (!mimeType) { return "MarkdownAssemblyStrategy (default)"; } const hierarchicalStrategy = new HierarchicalAssemblyStrategy(); if (hierarchicalStrategy.canHandle(mimeType)) { return "HierarchicalAssemblyStrategy"; } return "MarkdownAssemblyStrategy"; }

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

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