Serena usage statistics from log files
Serena is an MCP server that gives AI coding agents semantic understanding of your codebase. Instead of reading raw files, the agent can navigate symbols, find references, rename across the project, and use language-server-backed tools -- all through the Model Context Protocol. I use it with Claude Code, where it runs as a local MCP server alongside each session.
Serena writes detailed logs to ~/.serena/logs/, organized by date.
Each session produces a text file containing timestamps, tool calls with parameters, results, and execution times.
There is no built-in way to get usage statistics from these logs, but the format is structured enough that a simple Python script can extract useful insights.
I asked Claude Code to build one, and after a few iterations this is what came out.
The log format
Each log file corresponds to one MCP server session.
The filename encodes the start time and process ID: mcp_20260325-175343_2802043.txt.
Inside, every line follows Python's standard logging format:
INFO 2026-03-25 17:54:45,042 [MainThread] mcp.server.lowlevel.server:_handle_request:720 - Processing request of type CallToolRequest INFO 2026-03-25 17:54:45,043 [MainThread] serena.task_executor:issue_task:192 - Scheduling Task-2:ReadMemoryTool INFO 2026-03-25 17:54:45,046 [Task-2:ReadMemoryTool] serena.tools.tools_base:_log_tool_application:222 - read_memory: memory_name='some-memory-name' INFO 2026-03-25 17:54:45,047 [Task-2:ReadMemoryTool] serena.task_executor:stop:336 - Task-2:ReadMemoryTool completed in 0.001 seconds
Each tool call goes through the same lifecycle: CallToolRequest -> Scheduling Task-N:ToolName -> parameters logged -> result logged -> completed in X seconds.
A handful of regular expressions is enough to extract tool names, timestamps, durations, and result sizes from this.
What the script reports
Sessions where Serena started but no tool was ever called are filtered out -- these are just idle MCP server instances.
Overview and daily activity:
============================================================ Serena Usage Overview ============================================================ Total sessions: 15 (63 idle skipped) Total tool calls: 94 Serena versions: 0.1.4 (44 builds) ============================================================ Sessions per Day ============================================================ 2026-03-22 2 sessions 6 tool calls ###### 2026-03-25 4 sessions 44 tool calls ############################################
Tool usage -- which Serena tools are called most often, with average and maximum execution times.
GetSymbolsOverview and FindSymbol dominate, which makes sense -- they are the primary way an agent explores code structure before diving into specifics.
============================================================ Tool Usage (top 20) ============================================================ GetSymbolsOverview 28 avg 0.064s max 0.354s ############################ FindSymbol 27 avg 0.077s max 0.638s ########################### SearchForPattern 17 avg 0.229s max 2.940s ################# ListDir 9 avg 0.007s max 0.029s ######### FindFile 9 avg 0.010s max 0.027s #########
Result sizes -- since every tool result is logged, the script can measure the character count per response.
This approximates how much context window each tool consumes.
FindSymbol and SearchForPattern are the expensive ones, while GetSymbolsOverview stays compact at ~360 chars per call.
============================================================ Result Sizes (context window cost) ============================================================ Total result data: 135.4k chars FindSymbol 73.6k total avg 2.7k max 16.6k (27 calls) SearchForPattern 47.3k total avg 2.8k max 24.2k (17 calls) GetSymbolsOverview 10.2k total avg 363 max 3.4k (28 calls) ListDir 3.0k total avg 335 max 1.6k (9 calls)
The script also reports projects, session durations, language server startup times (Vue: 4s avg, Python: 0.3s), failed tool calls (9% failure rate, mostly FindSymbol hitting missing files), and hourly activity.


