Skip to main content
Glama
raydollete

Gemini MCP Server for Claude Code

by raydollete

count_gemini_tokens

Calculate token count for Gemini AI prompts to estimate costs and ensure they fit within model context limits.

Instructions

Count the number of tokens in a text string for the configured Gemini model.

Use this tool to:

  • Estimate prompt costs before making queries

  • Ensure prompts fit within model context limits

  • Optimize prompt length for efficiency

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesThe text to count tokens for
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It describes the tool's purpose and use cases but lacks behavioral details such as rate limits, error handling, or whether it's a read-only operation (though implied by 'count'). It adds value by explaining the practical applications but misses some operational context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the core purpose in the first sentence, followed by a bulleted list of use cases that are directly relevant and efficient. Every sentence earns its place without redundancy, making it highly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (single parameter, no output schema, no annotations), the description is mostly complete. It covers purpose, usage, and parameter context, but lacks details on output format or error handling, which would be helpful for full completeness. It's adequate but has minor gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, so the baseline is 3. The description adds value by clarifying that the text is for 'the configured Gemini model,' which provides context beyond the schema's generic 'text to count tokens for.' However, it doesn't detail tokenization specifics or model dependencies, keeping it at 4.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Count the number of tokens') and resource ('text string for the configured Gemini model'), distinguishing it from siblings like list_gemini_models (listing models) and query_gemini (making queries). It avoids tautology by explaining what counting tokens means rather than just restating the name.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly provides three use cases (estimating costs, ensuring context limits, optimizing length), which clearly indicate when to use this tool. It implicitly distinguishes from query_gemini by focusing on pre-query analysis rather than actual querying, though it doesn't explicitly name alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/raydollete/gemini-for-claude-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server