Fetches and aggregates time tracking data from Toggl API with intelligent Fibery entity reference parsing, user filtering, and smart caching capabilities
Toggl MCP Server
A FastMCP-based Model Context Protocol (MCP) server that fetches and aggregates Toggl time tracking data with intelligent Fibery entity reference parsing and caching.
Features
Time Entry Aggregation: Fetch and aggregate time entries from Toggl API
Fibery Entity Parsing: Automatically extract Fibery entity references from Toggl descriptions (#ID [DB] [TYPE])
Caching: Smart caching with SQLite index and JSON file storage (1-hour TTL)
Rate Limiting: Exponential backoff handling for Toggl API rate limits
User Filtering: Optional filtering by single user or retrieve all workspace users
Date Range Validation: Enforces ISO 8601 format and max 7-day ranges per request
Installation
Prerequisites
Python 3.11+
uv (package manager)
Setup
Clone the repository:
Create virtual environment:
Install dependencies:
Configure environment:
Configuration
Create a .env
file in the project root with your Toggl credentials:
Get your credentials:
API Token: Available at https://track.toggl.com/app/profile
Workspace ID: Available in Toggl settings or API responses
Using with Claude Code
Option 1: Project-Local Integration (Recommended)
The easiest way is to add the MCP server to your project's .mcp.json
file:
Replace /path/to/toggl-mcp-custom
with the actual path to this project.
Claude Code will automatically discover and use this server. The tools will be available in your conversations.
Option 2: Global Integration
To use this server across all projects, add it to your global MCP config:
macOS/Linux:
Then add to ~/.config/claude-code/mcp.json
:
Using in Other Projects
To add this MCP server to another project:
Copy the
cat > /path/to/other-project/.mcp.json << 'EOF' { "mcpServers": { "toggl": { "command": "/path/to/toggl-mcp-custom/.venv/bin/python", "args": ["-m", "toggl_mcp.server"], "cwd": "/path/to/toggl-mcp-custom" } } } EOFUpdate the paths to point to your toggl-mcp-custom installation
Restart Claude Code - it will automatically discover the server
Running the Server Manually
If you want to run the server directly:
The server will start and expose two MCP tools:
1. get_workspace_users()
Lists all users in the Toggl workspace.
Response:
2. get_toggl_aggregated_data(start_date, end_date, user_id=None)
Fetches and aggregates time entries for a date range.
Parameters:
start_date
(string): ISO 8601 format (YYYY-MM-DD), e.g., "2025-10-06"end_date
(string): ISO 8601 format, must be >= start_date and <= start_date + 7 daysuser_id
(optional string): Filter by single user ID
Response:
Description Parsing
The server automatically parses Toggl entry descriptions to extract Fibery entity references.
Format: "Description text #ID [DATABASE] [TYPE] [PROJECT]"
Examples:
"Design UI #456 [Scrum] [Task] [Moneyball]"
→ Matched entity"#123 [Dev]"
→ Minimal matched entity"Team meeting"
→ Unmatched activity
Parsing Rules:
Extracts the rightmost
#ID
if multiple existCaptures first 3 bracket values as DATABASE, TYPE, and PROJECT
Text before #ID becomes the description
Architecture
Services
CacheService: Manages caching with MD5 hash keys, SQLite index, and JSON file storage
TogglService: Handles Toggl API client with HTTP Basic Auth and rate limiting
ParserService: Parses descriptions to extract Fibery entity references
AggregatorService: Groups and aggregates time entries by user and entity
Models
User: Toggl workspace user
TimeEntry: Raw Toggl time entry
ParsedEntry: Entry with extracted metadata
UserAggregation: Aggregated data for single user
AggregatedData: Complete aggregated response
Testing
Run unit tests:
Test coverage:
26 unit tests covering:
Description parsing (7 tests)
Data aggregation (5 tests)
Cache operations (5 tests)
Date validation and utilities (9 tests)
Project Structure
Performance Considerations
Rate Limiting
Toggl API limit: 3 requests per second
Exponential backoff on 429 (rate limit) responses:
Attempt 1: 60 seconds
Attempt 2: 120 seconds
Attempt 3: 240 seconds
After 3 retries: failure
Caching
Default TTL: 1 hour
Cache keys: MD5 hash of date range + optional user_id
Storage: SQLite index + JSON files
Automatic cleanup of expired entries on retrieval
Date Range Limits
Maximum range: 7 days per request
For larger ranges, make multiple requests and aggregate client-side
Day-by-day pagination to optimize API efficiency
Error Handling
The server returns structured error responses with error codes:
INVALID_DATE_FORMAT
— Dates not in ISO 8601 formatINVALID_DATE_RANGE
— end_date < start_dateDATE_RANGE_EXCEEDS_LIMIT
— Range exceeds 7 daysUSER_NOT_FOUND
— User ID not found in workspaceAPI_ERROR
— Toggl API errorSERVICE_NOT_INITIALIZED
— Services not properly initializedINTERNAL_ERROR
— Server error
Development
Adding New Features
Add models to
models.py
Implement service methods
Write unit tests in
tests/
Update MCP tool in
server.py
Running Tests
License
MIT
Support
For issues or questions, please refer to the implementation specification in /docs/features/1-initial-implementation/IMPLEMENTATION.md
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Enables fetching and analyzing Toggl time tracking data with intelligent parsing of Fibery entity references from task descriptions. Features smart caching, user filtering, and aggregated reporting to help track time spent on specific projects and entities.