file-token-size-mcp
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
file-token-size-mcp
An MCP server that calculates estimated token size for files before reading them.
Purpose
Estimate token budgets before reading or delegating file content:
Plan task scope — know file sizes and line counts before deciding how to decompose work
Intelligent reading — decide whether to read entire files or use targeted approaches
Context budgeting — verify content fits within context limits before delegation
Batch planning — estimate total token cost when processing multiple files
Related MCP server: AITree MCP Server
Installation
No installation required. MCP clients run the server directly from the GitHub repository using npx.
Configuration
VS Code (GitHub Copilot)
Add to your VS Code settings.json, or create a .vscode/mcp.json in your workspace root:
macOS / Linux — settings.json:
{
"mcp": {
"servers": {
"file-token-size-mcp": {
"command": "npx",
"args": ["-y", "github:ming86/file-token-size-mcp"]
}
}
}
}Windows — settings.json:
{
"mcp": {
"servers": {
"file-token-size-mcp": {
"command": "cmd",
"args": ["/c", "npx", "-y", "github:ming86/file-token-size-mcp"]
}
}
}
}.vscode/mcp.json (per-project, macOS/Linux):
{
"servers": {
"file-token-size-mcp": {
"command": "npx",
"args": ["-y", "github:ming86/file-token-size-mcp"]
}
}
}.vscode/mcp.json (per-project, Windows):
{
"servers": {
"file-token-size-mcp": {
"command": "cmd",
"args": ["/c", "npx", "-y", "github:ming86/file-token-size-mcp"]
}
}
}GitHub Copilot CLI
The MCP config file is ~/.copilot/mcp-config.json (macOS/Linux) or %USERPROFILE%\.copilot\mcp-config.json (Windows). You can also add servers interactively with /mcp add inside the CLI.
macOS / Linux:
{
"mcpServers": {
"file-token-size-mcp": {
"type": "local",
"command": "npx",
"args": ["-y", "github:ming86/file-token-size-mcp"],
"tools": ["*"]
}
}
}Windows:
{
"mcpServers": {
"file-token-size-mcp": {
"type": "local",
"command": "cmd",
"args": ["/c", "npx", "-y", "github:ming86/file-token-size-mcp"],
"tools": ["*"]
}
}
}Environment Variables
Variable | Default | Description |
|
| Model for token counting. Valid: |
To override the default model (macOS/Linux example; on Windows use "command": "cmd" with "args": ["/c", "npx", ...]):
{
"mcpServers": {
"file-token-size-mcp": {
"command": "npx",
"args": ["-y", "github:ming86/file-token-size-mcp"],
"env": {
"TOKEN_COUNTER_MODEL": "Claude Sonnet 4.5"
}
}
}
}Tool: calculateFilesTokenSize
Input
Parameter | Type | Required | Description |
|
| Yes | Array of absolute file paths to analyze |
Output
Returns an array of result objects per file:
Field | Type | Description |
|
| Absolute path of the analyzed file |
|
| Estimated token count for the configured model |
|
| Character count |
|
| Word count |
|
| File size in bytes |
|
| Total line count |
|
| Error description if file processing failed |
Example
{
"filePaths": ["/path/to/file.ts", "/path/to/another.ts"]
}Response:
[
{
"filePath": "/path/to/file.ts",
"tokens": 298,
"characters": 928,
"words": 81,
"fileSizeBytes": 928,
"totalLines": 38
},
{
"filePath": "/path/to/another.ts",
"tokens": 1024,
"characters": 3200,
"words": 420,
"fileSizeBytes": 3200,
"totalLines": 102
}
]Token Counting
Uses ai-tokenizer with model-specific encodings:
Model | Encoding | Multiplier |
GPT-5 | o200k_base | Per model config |
Claude Sonnet 4.5 | claude | Per model config |
Gemini 2.5 Pro | o200k_base | Per model config |
Binary files are detected automatically and return an error result rather than incorrect token counts.
License
See LICENSE.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Count tokens (o200k/cl100k), truncate to a budget, chunk text for RAG and estimate LLM cost.
Count tokens exactly for any text and see if it fits a 128K, 200K or 1M context window.
Token counting, RAG chunking, truncation, HTML to Markdown and JSON repair
Counts tokens under OpenAI-compatible (tiktoken) encodings, by model or encoding name.
Related MCP Servers
- AlicenseAqualityDmaintenanceEstimates Claude API token counts, per-model cost, and prompt-caching break-even without an API key or network.5MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to generate annotated file trees, retrieve file statistics, list git-changed files, and read file contents from local directories or GitHub repositories.MIT
- AlicenseNot gradedqualityCmaintenanceProvides coding agents with pre-flight cost estimation by analyzing local logs to forecast token usage and quota impact before expensive work, exposing tools for remaining quota, per-task cost estimates, and attempt affordability.MIT
- AlicenseNot gradedqualityBmaintenanceLets AI agents know things about files without reading them, supporting outline, search, slicing, SQL, log clustering, diffs, validation, and extraction for formats like PDF, DOCX, PPTX, XLSX, CSV, logs, and code.MIT