timedoctor-mcp

timedoctor-mcp

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

Category
访问服务器

README

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"

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选