Skip to main content

MCP Server for extracting Time Doctor time tracking data via AI assistants

Project description

Time Doctor MCP

MCP Server for extracting Time Doctor time tracking data via AI assistants.

Buy Me A Coffee

What It Does

Fetches time tracking reports from Time Doctor and returns them as CSV data. Integrates with AI assistants via the Model Context Protocol (MCP).

Supports:

  • ๐Ÿค– Claude Desktop & Claude Code
  • ๐ŸŽฏ Cursor IDE
  • โœจ Google Gemini CLI
  • ๐Ÿ’ป VS Code with GitHub Copilot

Features:

  • ๐Ÿš€ Single-session scraping (login once, get multiple dates)
  • ๐Ÿ“… Works with any date range (1 day to 365+ days)
  • ๐Ÿ“Š Returns CSV data as text (no file system issues)
  • โฑ๏ธ Parses Time Doctor's "3h 50m" format
  • ๐Ÿ“ฆ Aggregates duplicate tasks
  • โœ… Includes TOTAL row

Installation Methods

Option A: Using uvx (Easiest - No Installation Required)

The simplest way to use Time Doctor MCP is with uvx, which automatically downloads the package from PyPI and runs it locally without manual installation:

Claude Desktop/Code:

{
  "mcpServers": {
    "timedoctor": {
      "command": "uvx",
      "args": ["timedoctor-mcp"],
      "env": {
        "TD_EMAIL": "your-email@example.com",
        "TD_PASSWORD": "your-password",
        "TD_BASE_URL": "https://2.timedoctor.com",
        "HEADLESS": "true"
      }
    }
  }
}

Prerequisites:

  1. Install uv: brew install uv (macOS) or see uv installation

  2. Install Playwright browsers (one-time setup):

    uvx --with playwright playwright install chromium
    

    This downloads the Chromium browser binaries needed for web scraping (~130MB). You only need to run this once.

That's it! No cloning, no virtual environments, no setup scripts. Just add the configuration and restart your AI assistant.

Option B: Clone & Install (For Development)

# Clone the repository
git clone https://github.com/frifster/timedoctor-mcp.git
cd timedoctor-mcp

# Install UV (fastest method)
brew install uv

# Run setup
./setup-with-uv.sh

2. Configure Credentials

Create .env in the project root:

nano .env

Add your Time Doctor credentials:

TD_EMAIL=your-email@example.com
TD_PASSWORD=your-password
TD_BASE_URL=https://2.timedoctor.com
HEADLESS=true

3. Add to Claude Desktop/Code

Edit your Claude MCP configuration:

macOS:

open ~/Library/Application\ Support/Claude/claude_desktop_config.json

Windows:

notepad %APPDATA%\Claude\claude_desktop_config.json

Linux:

nano ~/.config/Claude/claude_desktop_config.json

Add this configuration (replace <PATH_TO_REPO> with your actual path):

Option A: Credentials in JSON

{
  "mcpServers": {
    "timedoctor": {
      "command": "<PATH_TO_REPO>/.venv/bin/python",
      "args": ["<PATH_TO_REPO>/src/mcp_server.py"],
      "env": {
        "TD_EMAIL": "your-email@example.com",
        "TD_PASSWORD": "your-password",
        "TD_BASE_URL": "https://2.timedoctor.com",
        "HEADLESS": "true"
      }
    }
  }
}

Option B: Load from .env (Recommended)

{
  "mcpServers": {
    "timedoctor": {
      "command": "<PATH_TO_REPO>/.venv/bin/python",
      "args": ["<PATH_TO_REPO>/src/mcp_server.py"]
    }
  }
}

Example paths:

  • macOS: /Users/yourname/timedoctor-mcp/.venv/bin/python
  • Linux: /home/yourname/timedoctor-mcp/.venv/bin/python
  • Windows: C:\Users\yourname\timedoctor-mcp\.venv\Scripts\python.exe

4. Restart Claude

Completely quit and reopen Claude Desktop/Code.

Alternative MCP Clients

This MCP server also works with other AI assistants that support the Model Context Protocol:

Cursor IDE

Edit your Cursor MCP configuration file:

macOS/Linux:

nano ~/.cursor/mcp.json

Windows:

notepad %USERPROFILE%\.cursor\mcp.json

Using uvx (easiest):

{
  "mcpServers": {
    "timedoctor": {
      "command": "uvx",
      "args": ["timedoctor-mcp"],
      "env": {
        "TD_EMAIL": "your-email@example.com",
        "TD_PASSWORD": "your-password",
        "TD_BASE_URL": "https://2.timedoctor.com",
        "HEADLESS": "true"
      }
    }
  }
}

Using local installation (for development):

{
  "mcpServers": {
    "timedoctor": {
      "command": "<PATH_TO_REPO>/.venv/bin/python",
      "args": ["<PATH_TO_REPO>/src/mcp_server.py"],
      "env": {
        "TD_EMAIL": "your-email@example.com",
        "TD_PASSWORD": "your-password",
        "TD_BASE_URL": "https://2.timedoctor.com",
        "HEADLESS": "true"
      }
    }
  }
}

Note: You can also create a project-specific configuration at .cursor/mcp.json in your project root.

Restart Cursor after saving the configuration.

Google Gemini CLI

Edit your Gemini CLI settings:

macOS/Linux:

nano ~/.gemini/settings.json

Windows:

notepad %USERPROFILE%\.gemini\settings.json

Using uvx (easiest):

{
  "mcpServers": {
    "timedoctor": {
      "command": "uvx",
      "args": ["timedoctor-mcp"],
      "env": {
        "TD_EMAIL": "your-email@example.com",
        "TD_PASSWORD": "your-password",
        "TD_BASE_URL": "https://2.timedoctor.com",
        "HEADLESS": "true"
      },
      "timeout": 600000
    }
  }
}

Using local installation (for development):

{
  "mcpServers": {
    "timedoctor": {
      "command": "<PATH_TO_REPO>/.venv/bin/python",
      "args": ["<PATH_TO_REPO>/src/mcp_server.py"],
      "env": {
        "TD_EMAIL": "your-email@example.com",
        "TD_PASSWORD": "your-password",
        "TD_BASE_URL": "https://2.timedoctor.com",
        "HEADLESS": "true"
      },
      "timeout": 600000
    }
  }
}

Optional settings:

  • timeout: Request timeout in milliseconds (default: 600,000ms)
  • trust: Set to true to skip tool confirmations

Restart Gemini CLI after saving the configuration.

VS Code / GitHub Copilot

Create or edit the MCP configuration file:

Workspace-specific (recommended):

mkdir -p .vscode
nano .vscode/mcp.json

User-wide (all workspaces):

  • macOS: ~/Library/Application Support/Code/User/mcp.json
  • Linux: ~/.config/Code/User/mcp.json
  • Windows: %APPDATA%\Code\User\mcp.json

Using uvx (easiest):

{
  "servers": {
    "timedoctor": {
      "type": "stdio",
      "command": "uvx",
      "args": ["timedoctor-mcp"],
      "env": {
        "TD_EMAIL": "your-email@example.com",
        "TD_PASSWORD": "your-password",
        "TD_BASE_URL": "https://2.timedoctor.com",
        "HEADLESS": "true"
      }
    }
  }
}

Using local installation (for development):

{
  "servers": {
    "timedoctor": {
      "type": "stdio",
      "command": "<PATH_TO_REPO>/.venv/bin/python",
      "args": ["<PATH_TO_REPO>/src/mcp_server.py"],
      "env": {
        "TD_EMAIL": "your-email@example.com",
        "TD_PASSWORD": "your-password",
        "TD_BASE_URL": "https://2.timedoctor.com",
        "HEADLESS": "true"
      }
    }
  }
}

Using .env file with local installation:

{
  "servers": {
    "timedoctor": {
      "type": "stdio",
      "command": "<PATH_TO_REPO>/.venv/bin/python",
      "args": ["<PATH_TO_REPO>/src/mcp_server.py"],
      "envFile": "<PATH_TO_REPO>/.env"
    }
  }
}

Enable in GitHub Copilot:

  1. Open VS Code Command Palette (Cmd+Shift+P or Ctrl+Shift+P)
  2. Run MCP: Add Server to configure via UI
  3. Or manually edit .vscode/mcp.json as shown above
  4. In Copilot Chat, click the tools icon to see available MCP servers

Restart VS Code after saving the configuration.

Usage

Get data for date range:

Get my Time Doctor data from August 25 to September 5

Today's data:

Show me my Time Doctor hours for today

Last week:

Get my Time Doctor data for the last 7 days

Custom analysis:

Get my Time Doctor data from last month and tell me which project took the most time

Claude will receive CSV data like:

Date,Project,Task,Description,WORK HOUR
08/25/2025,Jira: AYR BMS,ABMS-606,Code Review,5.00
08/25/2025,Jira: AYR BMS,ABMS-700,Bug Fix,3.50
TOTAL,,,,8.50

You can then ask Claude to save it wherever you want!

MCP Tools

1. export_weekly_csv

Get time tracking data for any date range in CSV format.

Parameters:

  • start_date (required): YYYY-MM-DD format
  • end_date (required): YYYY-MM-DD format

Returns: CSV data as text with summary statistics

2. get_daily_report

Get detailed report for a specific date.

Parameters:

  • date (required): YYYY-MM-DD format or "today"

Returns: Formatted report with project breakdown

3. get_hours_summary

Quick hours breakdown by project.

Parameters:

  • date (required): YYYY-MM-DD format or "today"

Returns: Summary by project

4. export_today_csv

Quick access to today's data.

Parameters: None

Returns: Today's CSV data with summary

How It Works

  1. Login: Playwright automation logs into Time Doctor web interface
  2. Navigate: Goes to Projects & Tasks report
  3. Date Navigation: Uses arrow buttons to change dates
  4. Extract: Parses Angular Material tree structure for project/task data
  5. Parse: Converts "3h 50m" format to decimal hours
  6. Aggregate: Combines duplicate tasks
  7. Return: CSV data as text in MCP response

Architecture

Single-Session Efficiency:

  • Login once
  • Navigate through all dates in one session
  • Extract data for each date
  • Close browser once
  • Result: 2-3x faster than logging in for each date

CSV Data Format:

Date,Project,Task,Description,WORK HOUR
11/04/2025,Jira: AYR BMS,ABMS-606,Code Review - ABMS-606,0.25
11/04/2025,Jira: AYR BMS,ABMS-4979,Deal template update,2.47
TOTAL,,,,2.72
  • Date: MM/DD/YYYY format
  • WORK HOUR: Decimal hours (5.00, 1.50, 0.25)
  • TOTAL: Sum of all hours

Project Structure

timedoctor-mcp/
โ”œโ”€โ”€ .env                    # Your credentials (git-ignored)
โ”œโ”€โ”€ .env.example            # Example configuration
โ”œโ”€โ”€ requirements.txt        # Python dependencies
โ”œโ”€โ”€ setup-with-uv.sh       # Setup script
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ scraper.py         # Browser automation & login
โ”‚   โ”œโ”€โ”€ parser.py          # HTML parsing (Angular Material tree)
โ”‚   โ”œโ”€โ”€ transformer.py     # CSV formatting
โ”‚   โ””โ”€โ”€ mcp_server.py      # MCP server with 4 tools
โ””โ”€โ”€ tests/
    โ”œโ”€โ”€ debug_login.py     # Login debugging tool
    โ”œโ”€โ”€ test_parser.py     # HTML parsing tests
    โ”œโ”€โ”€ test_date_navigation.py  # Date navigation tests
    โ””โ”€โ”€ test_complete_flow.py    # End-to-end tests

Troubleshooting

MCP Server Won't Start

Check the log:

tail -f timedoctor_mcp.log

Common issues:

  • โŒ Missing credentials: Add to .env or MCP config
  • โŒ Wrong Python path: Use .venv/bin/python (or .venv/Scripts/python.exe on Windows)
  • โŒ Dependencies not installed: Run ./setup-with-uv.sh
  • โŒ Playwright browsers not installed: Run uvx --with playwright playwright install chromium

Playwright Browser Error

If you see:

Error: BrowserType.launch: Executable doesn't exist at .../chromium_headless_shell-1187/chrome-mac/headless_shell

Solution:

uvx --with playwright playwright install chromium

This is a one-time setup that downloads the browser binaries (~130MB). You only need to run this once per system.

Login Fails

Check log for:

Login failed - still on login page

Solutions:

  • Verify credentials in .env are correct
  • Check if Time Doctor requires 2FA (not supported)
  • Try logging in manually at https://2.timedoctor.com/login
  • Look for error messages in the log

The scraper logs which email it's using:

TimeDoctorScraper initialized with email: your-email@example.com

No Data Returned

Check log for:

Parsed 0 time entries

Solutions:

  • Verify you have time tracking data for those dates
  • Check that "Expand All" button appears on the report page
  • Try with today's date first to confirm it works
  • Check log for HTML parsing errors

Claude Not Seeing Tools

Solutions:

  1. Verify config path is correct
  2. Check JSON syntax is valid (use a JSON validator)
  3. Ensure Python path is absolute, not relative
  4. Completely quit and restart Claude
  5. Check Claude settings โ†’ MCP Servers

Path Issues

Make sure all paths in your MCP config are absolute paths, not relative:

โœ… Good:

  • macOS/Linux: /Users/name/timedoctor-mcp/.venv/bin/python
  • Windows: C:\Users\name\timedoctor-mcp\.venv\Scripts\python.exe

โŒ Bad:

  • ~/timedoctor-mcp/.venv/bin/python (tilde not expanded)
  • ./timedoctor-mcp/.venv/bin/python (relative path)
  • timedoctor-mcp/.venv/bin/python (relative path)

Requirements

  • Python: 3.12 or 3.13 (3.14 not supported yet)
  • Dependencies: Playwright, BeautifulSoup4, MCP SDK, python-dotenv
  • System: macOS, Linux, Windows
  • Time Doctor: Active account with login credentials

Performance

Single-session architecture:

  • 7 days: ~45 seconds (vs ~90 seconds with multiple logins)
  • 30 days: ~3 minutes
  • Login: 5 seconds (once)
  • Per date: 3-4 seconds (navigation + extraction)

Security

  • โœ… Credentials stored in .env (git-ignored)
  • โœ… Headless browser (no GUI)
  • โœ… Local execution only
  • โœ… No data sent to third parties
  • โš ๏ธ Store .env securely (chmod 600 .env recommended)

Development

Test login:

source .venv/bin/activate  # or .venv\Scripts\activate on Windows
python tests/debug_login.py

Test parsing:

python tests/test_parser.py

Test complete flow:

python tests/test_complete_flow.py

View logs:

tail -f timedoctor_mcp.log

Why Web Scraping?

Time Doctor has an API, but this MCP server uses web automation because:

  • โœ… No API token setup needed
  • โœ… Same access as web interface
  • โœ… Works with all Time Doctor plans
  • โœ… More reliable for "Projects & Tasks" report

If you prefer API access, Time Doctor's API is available at: https://api2.timedoctor.com/api/1.0/

Alternative Installation Methods

Manual pip Installation

# Create virtual environment
python3.13 -m venv .venv
source .venv/bin/activate  # or .venv\Scripts\activate on Windows

# Install dependencies
pip install -r requirements.txt

# Install Playwright browsers
playwright install chromium

Using Python venv (without UV)

python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
playwright install chromium

Contributing

Contributions welcome! Please feel free to submit issues or pull requests.

License

MIT License - See LICENSE file for details.

Disclaimer

This tool is for personal use and automation of your own Time Doctor data. Ensure you comply with Time Doctor's Terms of Service and your organization's policies when using this scraper.

Support

If this tool saves you time, consider buying me a coffee! โ˜•

Buy Me A Coffee


Questions? Check the log file: timedoctor_mcp.log in the project directory

Working? Ask Claude: "Get my Time Doctor data for today"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

timedoctor_mcp-1.3.0.tar.gz (60.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

timedoctor_mcp-1.3.0-py3-none-any.whl (29.6 kB view details)

Uploaded Python 3

File details

Details for the file timedoctor_mcp-1.3.0.tar.gz.

File metadata

  • Download URL: timedoctor_mcp-1.3.0.tar.gz
  • Upload date:
  • Size: 60.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.7

File hashes

Hashes for timedoctor_mcp-1.3.0.tar.gz
Algorithm Hash digest
SHA256 c8262a57aa6fe4fd968d2b562e6c19735d34a939e2f41c103fac3860e23a886c
MD5 58b750d0dadf050e260d6a1f62a84778
BLAKE2b-256 b211bb30bf5ae93e3186802dc7141a60051ff4977d17ade6cf5ffb1a47b4da13

See more details on using hashes here.

File details

Details for the file timedoctor_mcp-1.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for timedoctor_mcp-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 328a7e32d855d2ff4ead43d713435a64d8a616f0d5ad489f8a1b0622182bda9b
MD5 ddefc160f8f4f19fcca472ea2cd4ce6a
BLAKE2b-256 5bec464abd4404acdbe200df72a68c2985900884a068471d646a10b8c2bd3b8c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page