Skip to content

Conversation

@jonathannorris
Copy link
Member

@jonathannorris jonathannorris commented Aug 29, 2025

Summary

Adds a utility to measure AI token usage for MCP tool descriptions and schemas, plus docs and scripts to run it.

What’s included

  • Add scripts/measureMcpTokens.ts to compute token counts with gpt-tokenizer and @anthropic-ai/tokenizer
  • Add yarn script: yarn measure:mcp-tokens
  • Update mcp-worker/README.md with run instructions and current totals
  • Add dev deps: @anthropic-ai/tokenizer@^0.0.4, gpt-tokenizer@^3.0.1
  • Update yarn.lock

Usage

yarn install && yarn measure:mcp-tokens
  • Counts include tool description and inputSchema (output schemas are excluded unless ENABLE_OUTPUT_SCHEMAS=true).

Current totals (latest run)

  • Anthropic: 10,428
  • OpenAI: 10,746

Comment on lines +80 to +82
const d = t.description ?? ''
const i = t.inputSchema ? JSON.stringify(t.inputSchema) : ''
const o = t.outputSchema ? JSON.stringify(t.outputSchema) : ''
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the variable names could be more verbose. not blocking

Base automatically changed from feat-update-tool-descriptions to feat-cleanup-mcp-tool-types September 5, 2025 11:45
@jonathannorris jonathannorris merged commit 69d9ed0 into feat-cleanup-mcp-tool-types Sep 5, 2025
8 checks passed
@jonathannorris jonathannorris deleted the chore-measure-token-size branch September 5, 2025 11:46
jonathannorris added a commit that referenced this pull request Sep 5, 2025
* feat: update project tool descriptions

* feat: update MCP tool descriptions

* chore: add MCP token measurement script and docs
jonathannorris added a commit that referenced this pull request Sep 5, 2025
* feat: cleanup mcp tool types

* feat: update action enum

* feat: update project tool descriptions (#506)

* feat: update project tool descriptions

* feat: update MCP tool descriptions

* chore: add MCP token measurement script and docs (#507)

* feat: update project tool descriptions

* feat: update MCP tool descriptions

* chore: add MCP token measurement script and docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants