Creating a token-aware system to manage the context window for LLMs is a sophisticated approach to optimizing multi-agent workflows. It correctly identifies a key bottleneck in current AI-powered development systems. This is a TypeScript-based MCP server that provides a tool for counting tokens in files and directories.
Config is the same across clients — only the file and path differ.
{
"mcpServers": {
"token-counter-server": {
"command": "/path/to/your/cloned/repo/token-counter-server/build/index.js"
}
}
}Are you the author?
Add this badge to your README to show your security score and help users find safe servers.
Creating a token-aware system to manage the context window for LLMs is a sophisticated approach to optimizing multi-agent workflows. It correctly identifies a key bottleneck in current AI-powered development systems.
Run this in your terminal to verify the server starts. Then let us know if it worked — your result helps other developers.
npx -y 'npm' 2>&1 | head -1 && echo "✓ Server started successfully"
After testing, let us know if it worked:
Five weighted categories — click any category to see the underlying evidence.
Packing does not respect root-level ignore files in workspaces
### Impact `npm pack` ignores root-level `.gitignore` & `.npmignore` file exclusion directives when run in a workspace or with a workspace flag (ie. `--workspaces`, `--workspace=<name>`). Anyone who has run `npm pack` or `npm publish` with workspaces, as of [v7.9.0](https://github.com/npm/cli/releases/tag/v7.9.0) & [v7.13.0](https://github.com/npm/cli/releases/tag/v7.13.0) respectively, may be affected and have published files into the npm registry they did not intend to include. ### Patch - Up
Incorrect Permission Assignment for Critical Resource in NPM
An issue was discovered in an npm 5.7.0 2018-02-21 pre-release (marked as "next: 5.7.0" and therefore automatically installed by an "npm upgrade -g npm" command, and also announced in the vendor's blog without mention of pre-release status). It might allow local users to bypass intended filesystem access restrictions because ownerships of /etc and /usr directories are being changed unexpectedly, related to a "correctMkdir" issue.
Local Privilege Escalation in npm
Affected versions of `npm` use predictable temporary file names during archive unpacking. If an attacker can create a symbolic link at the location of one of these temporary file names, the attacker can arbitrarily write to any file that the user which owns the `npm` process has permission to write to, potentially resulting in local privilege escalation. ## Recommendation Update to version 1.3.3 or later.
npm CLI exposing sensitive information through logs
Versions of the npm CLI prior to 6.14.6 are vulnerable to an information exposure vulnerability through log files. The CLI supports URLs like `<protocol>://[<user>[:<password>]@]<hostname>[:<port>][:][/]<path>`. The password value is not redacted and is printed to stdout and also to any generated log files.
npm Vulnerable to Global node_modules Binary Overwrite
Versions of the npm CLI prior to 6.13.4 are vulnerable to a Global node_modules Binary Overwrite. It fails to prevent existing globally-installed binaries to be overwritten by other package installations. For example, if a package was installed globally and created a `serve` binary, any subsequent installs of packages that also create a `serve` binary would overwrite the first binary. This will not overwrite system binaries but only binaries put into the global node_modules directory. This b
Click any tool to inspect its schema.
sample.txtA sample text file to test token counting.
resources/sample.txt
Count tokens in a single fileCan you count the tokens in src/index.ts?
Count tokens in a directory with a filterHow many tokens are in the src directory, only counting .ts files?
Be the first to review
Have you used this server?
Share your experience — it helps other developers decide.
Sign in to write a review.
Others in ai-ml / developer-tools
XcodeBuildMCP provides tools for Xcode project management, simulator management, and app utilities.
Context7 Platform -- Up-to-date code documentation for LLMs and AI code editors
Copy/paste detector for programming source code, supports 223 formats. AI-ready with token-efficient reporter, skill and MCP server.
A Model Context Protocol (MCP) server and CLI that provides tools for agent use when working on iOS and macOS projects.
MCP Security Weekly
Get CVE alerts and security updates for Token Counter Server and similar servers.
Start a conversation
Ask a question, share a tip, or report an issue.
Sign in to join the discussion.
Creating a token-aware system to manage the context window for LLMs is a sophisticated approach to optimizing multi-agent workflows. It correctly identifies a key bottleneck in current AI-powered development systems.
This is a TypeScript-based MCP server that provides a tool for counting tokens in files and directories.
To get started, you first need to clone the repository and build the server from the source code.
Clone the repository to your local machine:
git clone https://github.com/intro0siddiqui/token-counter-server.git
Navigate into the directory:
cd token-counter-server
Install dependencies and build the project:
npm install
npm run build
After this step, the server is ready to be used. You can now configure your MCP client (like Claude Desktop) to use it.
You have two options for configuring your client:
You can point your client directly to the built server file. This is the simplest method and doesn't require any global system changes.
In your claude_desktop_config.json, use the full path to build/index.js inside the directory you just cloned.
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%/Claude/claude_desktop_config.json{
"mcpServers": {
"token-counter-server": {
"command": "/path/to/your/cloned/repo/token-counter-server/build/index.js"
}
}
}
Remember to replace /path/to/your/cloned/repo with the actual, absolute path on your system.
If you prefer to use a simple token-counter-server command without typing the full path, you can install the server as a global command.
Important: You must be inside the token-counter-server directory (the one you cloned) before running this command.
Install globally from the local source:
npm install -g .
This command creates a symbolic link on your system that points to the server executable.
Configure your client with the simple command:
Now you can use token-counter-server in your client configuration:
{
"mcpServers": {
"token-counter-server": {
"command": "token-counter-server"
}
}
}
This server provides the following tool:
count_tokens: Counts the number of tokens in a file or directory.
path (string, required): The path to the file or directory.file_pattern (string, optional): A glob pattern to filter files (e.g., *.ts).Here are some example prompts you can use:
Count tokens in a single file:
"Can you count the tokens in
src/index.ts?"
Count tokens in a directory with a filter:
"How many tokens are in the
srcdirectory, only counting.tsfiles?"
You can find these and other examples in the prompts/ directory.
This MCP includes sample files for testing and demonstration purposes.
resources/sample.txt: A sample text file to test token counting.npm installnpm run buildnpm run watchTo debug the server, you can use the MCP Inspector:
npm run inspector
This will provide a browser-based interface to inspect the communication between the client and the server.