openclaw-usage-mcp

openclaw-usage-mcp

MCP server that reads local OpenClaw session files to provide token usage and cost data without any network calls or authentication.

Category
Visit Server

README

openclaw-usage-mcp

MCP server that reads local OpenClaw session files for usage and cost data. No network calls or authentication required — it scans the JSONL session files directly from disk.

AI Agent  ──stdio──▶  MCP Server  ──reads──▶  ~/.openclaw/agents/*/sessions/*.jsonl

Tools

Tool Description
get_usage Token counts and costs for a date range, broken down by period and model
list_sessions Sessions with usage breakdown, grouped by period (top-N or all)
get_session_logs Per-message logs for a session: timestamps, token counts, costs, roles

Setup

1. Install dependencies

pip install mcp

2. Configure

The server reads these environment variables:

Variable Default Description
OPENCLAW_AGENTS_DIR ~/.openclaw/agents/ Path to the OpenClaw agents directory containing session files

3. Register with your MCP client

mcporter (recommended with OpenClaw):

mcporter config add usage \
  --command python3 \
  --arg /path/to/server.py \
  --scope home

Claude Code (~/.claude/settings.json):

{
  "mcpServers": {
    "openclaw-usage": {
      "command": "python3",
      "args": ["/path/to/server.py"]
    }
  }
}

How it works

The server scans JSONL session files from the OpenClaw agents directory:

  • Active sessions: ~/.openclaw/agents/*/sessions/*.jsonl
  • Archived (reset) sessions: ~/.openclaw/agents/*/sessions/*.jsonl.reset.*

Each session file contains JSON lines with type: "session" headers, type: "message" entries (with usage/cost data on assistant messages), and type: "model_change" entries for model switches.

The server aggregates token counts and costs per model, per session, and per time period — returning the same structured output format the tools have always used.

Archived .reset.* files are included in scans, so usage from reset sessions is no longer invisible.

Running standalone

python3 server.py

Communicates over stdio using the MCP protocol.

Previous architecture

Earlier versions used the gateway's WebSocket RPC API with Ed25519 device authentication. That code (including device_auth.py) is preserved at tag v0.1.0-gateway-api.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured