Skip to content

Ongoing discussion: How do we estimate token cost for mcp requests and responses #55

@brettimus

Description

@brettimus

Long talk in the office with @flenter about estimating token cost. Here are the notes

Certain mcp methods have a relatively straightforward cost ("tokens") associated with them. For instance:

  • tools/call request: the LLM had to produce tokens to call the tool. this token count is of course dependent on the LLM
  • tools/call response: the LLM will read the tokens returned in the content block(s)
  • resources/read response: the LLM will add the document to context
  • prompts/get response: the prompt result will be passed to the LLM

Other mcp methods clearly have no cost associated with them:

  • ping
  • initialize
  • notifications/initialized
  • prompts/list req/res: the list of prompts is requested by the mcp client, and stored as application-level state. not injected into the llm's context
  • prompts/get request: this is executed by the client, but not the llm

Other mcp methods are ambiguous:

  • resources/list req/res: this could be initiated at the application level, or (in the instance of Claude Code) the LLM might have a tool to read MCP resources
  • resources/read request: same as above

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions