Skip to content

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.

Notifications You must be signed in to change notification settings

Intro0siddiqui/token-counter-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

token-counter-server MCP Server

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.

Features

Tools

  • count_tokens - Count the number of tokens in a file or directory.
    • Takes path (string) as a required parameter, which can be a file or directory path.
    • Takes file_pattern (string) as an optional parameter, which is a glob pattern to filter files (e.g., '*.ts').

Development

Install dependencies:

npm install

Build the server:

npm run build

For development with auto-rebuild:

npm run watch

Installation

To use with Claude Desktop, add the server config:

On MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json On Windows: %APPDATA%/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "token-counter-server": {
      "command": "/path/to/token-counter-server/build/index.js"
    }
  }
}

Debugging

Since MCP servers communicate over stdio, debugging can be challenging. We recommend using the MCP Inspector, which is available as a package script:

npm run inspector

The Inspector will provide a URL to access debugging tools in your browser.

About

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.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published