Skip to main content

Module mcp

Module mcp 

Source
Expand description

originlm mcp: the built-in Model Context Protocol server.

Newline-delimited JSON-RPC 2.0 over stdio (the MCP stdio transport). It serves read-only tools over the same native service the broker uses, so usage numbers come from the provider adapters’ own quota probes (Claude Code get_usage, Codex account/rateLimits/read), never from estimates. The handshake mirrors the SDK’s createCachedUsageMcp: initialize, then notifications/initialized, then tools/list / tools/call.

Structs§

McpServer

Enums§

ProbeOutcome

Constants§

CLIENT
USAGE_SOURCES
Providers whose adapters can report plan quota, and the grant that turns the read on. Claude Code and Codex are granted by default; the others are listed with the flags that enable them. Every other detected provider has no usage source in OriginLM today and is listed as such.

Functions§

collect_usage
Discover (when asked), probe every granted connection of wanted, and shape the snapshot into the usage report. Shared by the MCP usage tool and the originlm usage / olm usage command so both show the same numbers.
detail_codes
Diagnostic codes an adapter appended to an error message as [A,B].
friendly_label
Claude Code’s limits[] rows carry a raw kind (session, weekly_all, weekly_scoped · <model>). Name the ones whose meaning is established — the session bucket is the same one the adapter’s keyed path labels “5-hour session” — and keep any other provider label unchanged.
history_text
Readable local token totals (usage_history tool, usage --history).
provider_filter
Optional providers narrowing: ids OriginLM discovery knows, else an error.
providers_report
Shape the snapshot into the providers result. Pure, for tests.
serve
Serve MCP over a byte stream until EOF.
tool_definitions
usage_report
Shape the projected snapshot into the usage result. Pure, for tests.
usage_terminal
Terminal rendering for originlm usage / olm usage: one block per account with aligned window rows, then every detected provider that has no reading, each with its reason. Reset times are shown in offset (the caller’s local zone).
usage_text
The human-readable side of the usage result.