token-counter-server MCP Serverのロゴ

token-counter-server MCP Server

コミュニティ
Intro0siddiqui

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.

公開者Intro0siddiqui
リポジトリtoken-counter-server
言語JavaScript
フォーク
2
スター
8
利用可能なツール
0
通信方式stdio
カテゴリ
ライセンスMIT
リンク
  • ツールをAIワークフローに接続

    token-counter-server MCP Serverは、対応するAIクライアントやAIエージェントから利用できるMCP機能を提供します。

  • 利用可能なツール(0個)

    呼び出し可能なアクションを以下で確認できます。サーバーから提供されている場合は、名前や説明も表示されます。

  • コピーして使える設定

    セットアップ用の設定例を使って、お好みのMCPクライアントにこのサーバーを設定できます。

  • オープンソースプロジェクトの注目度

    リンク先のリポジトリには8件のスターと2件のフォークがあります。

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.

Installation

To get started, you first need to clone the repository and build the server from the source code.

Step 1: Clone and Build

  1. Clone the repository to your local machine:

    bash
    git clone https://github.com/intro0siddiqui/token-counter-server.git
  2. Navigate into the directory:

    bash
    cd token-counter-server
  3. Install dependencies and build the project:

    bash
    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.

Step 2: Configure Your Client

You have two options for configuring your client:

Option A: Use the Full Path (Simple)

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.

  • MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%/Claude/claude_desktop_config.json
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.

Option B: Make the Command Globally Available (Advanced)

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.

  1. Install globally from the local source:

    bash
    npm install -g .

    This command creates a symbolic link on your system that points to the server executable.

  2. Configure your client with the simple command: Now you can use token-counter-server in your client configuration:

    json
    {
      "mcpServers": {
        "token-counter-server": {
          "command": "token-counter-server"
        }
      }
    }

Tools Included

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).

Prompts

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 src directory, only counting .ts files?"

You can find these and other examples in the prompts/ directory.

Resources

This MCP includes sample files for testing and demonstration purposes.

  • resources/sample.txt: A sample text file to test token counting.

Development

  • Install dependencies: npm install
  • Build: npm run build
  • Watch for changes: npm run watch

Debugging

To debug the server, you can use the MCP Inspector:

bash
npm run inspector

This will provide a browser-based interface to inspect the communication between the client and the server.

インストール

TypingMind
前提条件:

Node.js 18+

{
  "mcpServers": {
    "intro0siddiqui-token-counter-server": {
      "command": "",
      "args": []
    }
  }
}

token-counter-server MCP ServerのMCPを複数のAIモデルで活用

TypingMindはワークスペース単位でMCPツールに接続します。そのため、一度token-counter-server MCP Serverに接続すれば、モデルごとに個別に設定することなく、TypingMind内のさまざまなAIモデルで利用できます。 このMCPは、デバイス上のTypingMind MCPコネクタを通じてローカルで動作します。

ローカルコネクタのセットアップガイド

MCPサーバーが、お使いのコンピューター上のローカルファイル、アプリ、非公開リソースにアクセスする必要がある場合は、この方法を使います。

1

MCP設定を開く

TypingMindで「設定」→「詳細設定」→「Model Context Protocol」の順に進み、「コネクタを設定」を選択してください。

  1. ブラウザでTypingMindを開いてください。
  2. 設定アイコンをクリックしてください。
  3. 「詳細設定」に移動してください。
  4. 「Model Context Protocol」セクションを開いてください。
  5. 「コネクタを設定」をクリックし、「このデバイス」を選択してください。
「このデバイス」が選択されたTypingMindのMCPコネクタ設定画面
2

コネクタのコマンドを実行

「このデバイス」を選択し、TypingMindからコマンドをコピーしてターミナルで実行してください。MCPの使用中は、プロセスを実行したままにしてください。

  1. TypingMindに表示されるセットアップコマンドをコピーしてください。
  2. macOSではターミナルを、WindowsではWindows Terminalを開いてください。
  3. コマンドを貼り付けて実行してください。
  4. ターミナルで続行の確認を求められた場合は、パッケージのインストールを承認してください。
  5. MCPツールの使用中は、ターミナルウィンドウを開いたまま、プロセスの実行を継続してください。
3

token-counter-server MCP Serverをサーバーとして追加

コネクタのステータスが「準備完了」になったら、「サーバーを編集」をクリックし、MCPサーバーの設定を貼り付けてください。

  1. コネクタのステータスが「準備完了」になるまでお待ちください。
  2. 「サーバーを編集」をクリックしてください。
  3. token-counter-server MCP ServerのMCPサーバー設定を貼り付けてください。
  4. サーバー一覧を保存してください。
  5. コネクタのステータスが「準備完了」のままか確認するには、画面を更新してください。
稼働中のサーバーと「サーバーを編集」ボタンが表示されたTypingMindのMCP設定画面
{
  "mcpServers": {
    "intro0siddiqui-token-counter-server": {
      "command": "npx",
      "args": [
        "-y",
        "token-counter-server"
      ]
    }
  }
}
4

複数のモデルで同じ接続を使用

サーバー一覧を保存し、「プラグイン」を開いてtoken-counter-server MCP ServerのMCPツールを有効にしてください。その後、TypingMindで対応するAIモデルを選択し、チャットでツールを使うか、AIエージェントに割り当ててください。

  1. TypingMindの「プラグイン」ページを開いてください。
  2. token-counter-server MCP ServerのMCPツールを有効にしてください。
  3. チャットを開始し、使用するAIモデルを選択してください。
  4. MCPツールをチャットで使うか、AIエージェントに割り当ててください。
  5. MCPに再接続することなく、必要に応じて別のAIモデルに切り替えられます。
選択したAIモデルと有効なMCPツールを使用したTypingMindのチャット
token-counter-server MCP Serverを使ってこのタスクを手伝ってもらえますか?
token-counter-server MCP Server
はい、読みました。
token-counter-server MCP Serverで調べた結果をお伝えします。

よくある質問

token-counter-server MCP Server MCPサーバーは何に使いますか?

token-counter-server MCP Serverは、対応するAIクライアントを外部ツールやコンテキストに接続するためのMCPサーバーです。TypingMindでは、このMCPサーバーを一度追加するだけで、AIワークスペース内でそのツールを利用できるようになります。

TypingMindでは、複数のAIモデルでtoken-counter-server MCP Server MCPを利用できますか?

はい。TypingMindはワークスペース単位でMCPツールに接続するため、モデルごとにMCPサーバーを設定する必要はありません。Claude、ChatGPT、Geminiや、TypingMindで設定したその他のAIモデルでtoken-counter-server MCP Serverを利用できます。

TypingMindでtoken-counter-server MCP Server MCPを使うメリットは何ですか?

TypingMindは、複数のAIモデル、プロンプト、プラグイン、AIエージェント、APIキー、MCPツールを1つのワークスペースにまとめられる、LLMチャット向けのトップクラスのフロントエンドです。token-counter-server MCP Serverを接続すると、TypingMindでチャットのワークフローを整理しながら、お好みのモデルでそのMCPツールを利用できます。

token-counter-server MCP Server MCPをTypingMindに接続するにはどうすればよいですか?

token-counter-server MCP ServerはTypingMindのローカルMCPコネクタ経由で動作します。MCPサーバーがコンピューター上のローカルファイル、デスクトップアプリ、コマンドラインツール、プライベートリソースにアクセスする必要がある場合に最適です。

TypingMindでtoken-counter-server MCP Server MCPのどのようなツールを利用できますか?

token-counter-server MCP ServerはMCP機能を提供しています。TypingMindのプラグインページで有効にすると、チャットで使用したり、AIエージェントに割り当てたりできます。

token-counter-server MCP Server MCPを使うには、APIキーをTypingMindと共有する必要がありますか?

いいえ。TypingMindはローカルファーストの設計で、モデルプロバイダー、APIキー、プロンプト、MCP設定をご自身で管理できます。token-counter-server MCP Serverで認証が必要な場合は、接続の作成時に、そのMCPサーバーに必要なヘッダー、OAuth設定、またはローカル設定を追加してください。

関連するMCPサーバー

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇