usage

package
v0.1.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package usage counts MCP tool calls in a database next to the index. The index is rebuilt when its schema changes; this file is not. Nothing here is sent anywhere.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EstimateSaved

func EstimateSaved(tool string, responseBytes int, fileBytes int64) int

EstimateSaved returns how many response bytes were smaller than the files the result points at. Tools outside readInstead return 0.

func Format

func Format(rep Report, dollarsPerMillion float64) string

Format renders a report for the stats command.

func ResultStats

func ResultStats(structured any) (responseBytes int, empty bool, files []string)

ResultStats reads a tool's structured result: response size, whether the useful lists are empty, and the file paths it names.

Types

type Recorder

type Recorder struct {
	// contains filtered or unexported fields
}

Recorder appends one row per tool call.

func Open

func Open(path string) (*Recorder, error)

Open opens (and creates) the usage database at path.

func (*Recorder) Close

func (r *Recorder) Close() error

func (*Recorder) Middleware

func (r *Recorder) Middleware(sizes func(paths []string) (int64, error)) mcp.Middleware

Middleware records tools/call responses. sizes returns the total indexed size of the named files.

func (*Recorder) Record

func (r *Recorder) Record(tool string, responseBytes int, empty bool, savedBytes int)

Record stores one tool call. saved is an estimated number of bytes the agent did not have to read. Failures are ignored: accounting must not break a tool call.

func (*Recorder) SessionLine

func (r *Recorder) SessionLine(dollarsPerMillion float64) string

SessionLine is one log line for the calls recorded since Open.

func (*Recorder) Since

func (r *Recorder) Since(t time.Time) (Report, error)

Since summarizes calls at or after t. The zero time means all calls.

type Report

type Report struct {
	Calls  int
	Bytes  int
	Saved  int
	Empty  int
	ByTool map[string]int
}

Report is a total over a time window.

func (Report) SavedTokens

func (r Report) SavedTokens() int

SavedTokens estimates tokens of source the responses stood in for.

func (Report) Tokens

func (r Report) Tokens() int

Tokens estimates how many tokens the responses cost to read.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL