Skip to main content
Glama

lmstudio_count_tokens

Read-only

Count tokens in text using a loaded model's own tokenizer and compare the result with its context length, so you can verify prompts fit before sending them.

Instructions

Count tokens in a text using a loaded model's own tokenizer, and compare with its context length.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "text": "<text>"
    },
    "name": "lmstudio_count_tokens"
  }
}

Input Schema

NameRequiredDescriptionDefault
textYes
modelNoLoaded identifier or key. Default: any loaded LLM.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A3.8/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true and openWorldHint=false, so safety is covered. The description adds real behavioral context beyond that: results depend on a *loaded* model's own tokenizer (so counts vary by model), and the response includes a comparison against the model's context length. It does not say what happens when no model is loaded, which would have made this a 5.

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?

A single sentence with the primary action front-loaded and the secondary comparison clause trailing. No filler or redundant restatement of the name.

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?

For a simple two-parameter read-only tool with no output schema, the description covers purpose, the model dependency, and the comparison output. The remaining gap — behavior when no model is loaded, or how the comparison is presented — is minor.

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

Parameters3/5

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

Schema coverage is 50% — the "model" parameter is documented in the schema (loaded identifier or key, default any loaded LLM) while "text" is not. The description reinforces that the model must be loaded and that its tokenizer is what counts, adding modest meaning, but it adds nothing about the text parameter or tokenizer edge cases.

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

Purpose4/5

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

The description gives a specific verb and resource ("count tokens in a text") plus a distinguishing mechanism ("a loaded model's own tokenizer") and a secondary capability ("compare with its context length"). This clearly separates it from siblings like lmstudio_chat or lmstudio_estimate_memory, though it never explicitly names a sibling to route against.

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

Usage Guidelines3/5

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

Usage is only implied: the tokenizer/context-length framing suggests the tool is for checking whether text fits a model's context before sending it. There is no explicit when-to-use statement, no stated preconditions, and no guidance on when to prefer this over other sizing tools.

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