Skip to main content
Glama

CTX: Context as Code (CaC) tool

by context-hub
MIT License
235
  • Apple
  • Linux
GithubFileInfo.php2.11 kB
<?php declare(strict_types=1); namespace Butschster\ContextGenerator\Source\Github; use Symfony\Component\Finder\SplFileInfo; /** * GitHub file information wrapper * * Extends SplFileInfo to provide GitHub-specific metadata */ final class GithubFileInfo extends SplFileInfo { private ?string $fetchedContent = null; /** * Create a new GitHub file info instance * * @param string $relativePath Relative path * @param string $relativePathname Relative pathname * @param array<string, mixed> $metadata GitHub file metadata */ public function __construct( string $relativePath, string $relativePathname, private readonly array $metadata, private readonly \Closure $content, ) { parent::__construct($relativePath, $relativePath, $relativePathname); } /** * Get the file content */ #[\Override] public function getContents(): string { if ($this->fetchedContent) { return $this->fetchedContent; } return \call_user_func($this->content); } /** * Get the file size */ public function getSize(): int { return $this->metadata['size'] ?? 0; } /** * Get the file type */ public function getType(): string { return $this->metadata['type'] ?? 'file'; } /** * Check if the file is a directory */ public function isDir(): bool { return $this->getType() === 'dir'; } /** * Get the file URL on GitHub */ public function getGithubUrl(): string { return $this->metadata['html_url'] ?? ''; } /** * Get the file API URL */ public function getApiUrl(): string { return $this->metadata['url'] ?? ''; } /** * Get the raw file URL */ public function getRawUrl(): string { return $this->metadata['download_url'] ?? ''; } /** * Get the file SHA */ public function getSha(): string { return $this->metadata['sha'] ?? ''; } }

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