Skip to main content
Glama

CTX: Context as Code (CaC) tool

by context-hub
MIT License
235
  • Apple
  • Linux
DocumentConfigMerger.php1.71 kB
<?php declare(strict_types=1); namespace Butschster\ContextGenerator\Document; use Butschster\ContextGenerator\Application\Logger\LoggerPrefix; use Butschster\ContextGenerator\Config\Import\Merger\AbstractConfigMerger; use Butschster\ContextGenerator\Config\Import\Source\ImportedConfig; #[LoggerPrefix(prefix: 'document-merger')] final readonly class DocumentConfigMerger extends AbstractConfigMerger { public function getConfigKey(): string { return 'documents'; } protected function performMerge(array $mainSection, array $importedSection, ImportedConfig $importedConfig): array { // Index main documents by output path for efficient lookups $indexedDocuments = []; foreach ($mainSection as $document) { if (!isset($document['outputPath'])) { continue; } $indexedDocuments[$document['outputPath']] = $document; } // Process each imported document foreach ($importedSection as $document) { if (!isset($document['outputPath'])) { $this->logger->warning('Skipping document without outputPath', [ 'document' => $document, 'path' => $importedConfig->path, ]); continue; } $outputPath = $document['outputPath']; $indexedDocuments[$outputPath] = $document; $this->logger->debug('Merged document', [ 'outputPath' => $outputPath, 'path' => $importedConfig->path, ]); } // Convert back to numerically indexed array return \array_values($indexedDocuments); } }

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/context-hub/generator'

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