Skip to main content

Crate mcp_usage_tower

Crate mcp_usage_tower 

Source
Expand description

Tower hot path for MCP authentication, caching, and terminal-delivery billing.

Request metadata is classified from the mandatory MCP headers. Bodies are deserialized only for cache keys, durable-task attribution, and the terminal response decision. Response bodies remain streaming: the wrapper observes frames as the client consumes them and records usage only after a terminal JSON-RPC response reaches end-of-stream.

Structs§

DeferredCompletions
Queue of terminal accounting waiting for somewhere to await.
EdgeConfig
Runtime configuration shared by every cloned metering service.
EdgeMetrics
Process-local edge counters.
InMemoryTaskStore
Process-local task attribution for an embedded server.
InMemoryTenantStore
Mutable in-memory tenant table for development and embedded deployments.
MeterLayer
Tower layer that installs MeterService.
MeterService
Service produced by MeterLayer.
MetricsSnapshot
Point-in-time metric values.
OpenTelemetryMetrics
Registration guard for the OpenTelemetry observable instruments.
ProtocolHeaders
Trusted protocol metadata lifted from request headers.
TaskAttribution
Pre-priced durable-task attribution without the original name or URI.
Tenant
Authenticated tenant configuration used by the edge.

Enums§

ClassificationError
Why mandatory MCP request metadata could not be trusted.
EdgeConfigError
Invalid edge configuration.
TaskOriginKind
Non-identifying method category retained for a durable task.
TaskStoreError
A sanitized durable-task store failure.
WeakApiKey
Why an API key was refused as too weak to be safe.

Constants§

API_KEY_HEADER
API-key header accepted in addition to Authorization: Bearer.
METHOD_HEADER
Mirrored JSON-RPC method request header.
MIN_API_KEY_BYTES
Shortest API key accepted by validate_api_key_strength.
NAME_HEADER
Mirrored tool, prompt, or resource name request header.
PROTOCOL_VERSION_HEADER
Standard protocol-version request header.

Traits§

TaskAttributionStore
Persists pre-priced, non-identifying attribution under a durable task ID.
TenantStore
Resolves a presented high-entropy API key without retaining its plaintext.

Functions§

classify_protocol_headers
Validate and classify raw MCP header values.
hash_api_key
SHA-256 lookup hash for an API key.
install_opentelemetry
Register low-cardinality observable counters with an application-owned meter.
validate_api_key_strength
Reject API keys that are obviously too weak to be compared by digest.

Type Aliases§

MeterBody
Response body returned by MeterService.
TaskStoreFuture
Boxed future returned by object-safe task stores.