Skip to main content
Glama

CTX: Context as Code (CaC) tool

by context-hub
MIT License
235
  • Apple
  • Linux
CharTokenCounter.php909 B
<?php declare(strict_types=1); namespace Butschster\ContextGenerator\Lib\TokenCounter; final readonly class CharTokenCounter implements TokenCounterInterface { public function countFile(string $filePath): int { if (\is_dir($filePath)) { return 0; } if (!\file_exists($filePath) || !\is_readable($filePath)) { return 0; } $content = \file_get_contents($filePath); return $content === false ? 0 : \mb_strlen($content); } public function calculateDirectoryCount(array $directory): int { $totalChars = 0; foreach ($directory as $children) { if (\is_array($children)) { $totalChars += $this->calculateDirectoryCount($children); } else { $totalChars += $this->countFile($children); } } return $totalChars; } }

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