TickTick Model Context Protocol (MCP) Server

repository·main·Indexed 43 days ago

https://github.com/jacepark12/ticktick-mcp

An MCP server that enables AI clients like Claude to interact with the TickTick API. It provides tools for managing tasks, projects, and schedules through natural language, including GTD framework filters, batch task creation, and OAuth2 authentication for both TickTick and Dida365.

Tokens
9.9K
Snippets
26
Records
37
Agent score
54%

What's inside TickTick MCP

  1. How TickTick OAuth2 authorization works

    main

    TickTick uses the OAuth2 protocol to authorize access to user data. The process involves three main steps:

    1. Redirect to Authorization Page: Send the user to the TickTick authorization URL with your application credentials and requested scopes.
    2. Receive Authorization Code: After the user grants permission, TickTick redirects them back to your redirect_uri with a code and the original state parameter.
    3. Exchange Code for Access Token: Make a server-side POST request to exchange the authorization code for a usable access_token.
  2. Configure TickTick MCP for Claude for Desktop

    main

    To use the TickTick MCP server with Claude for Desktop, add the server configuration to your claude_desktop_config.json file using absolute paths.

    File Locations:

    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json

    Configuration Structure:

    {
       "mcpServers": {
          "ticktick": {
             "command": "<absolute path to uv>",
             "args": ["run", "--directory", "<absolute path to ticktick-mcp directory>", "-m", "ticktick_mcp.cli", "run"]
          }
       }
    }

    Restart Claude for Desktop after saving the file. You will see a 🔨 icon when tools are available.

    {
       "mcpServers": {
          "ticktick": {
             "command": "/usr/local/bin/uv",
             "args": ["run", "--directory", "/Users/username/ticktick-mcp", "-m", "ticktick_mcp.cli", "run"]
          }
       }
    }
  3. Step 1: Redirect user to TickTick authorization page

    main

    Redirect the user to https://ticktick.com/oauth/authorize using the following query parameters:

    NameDescription
    client_idYour application's unique ID
    scopeSpaces-separated permission scopes. Available: tasks:write, tasks:read
    stateA unique string to prevent CSRF; passed back to your redirect URL as-is
    redirect_uriThe URL where the user is redirected after authorization
    response_typeMust be set to code

    Example URL: https://ticktick.com/oauth/authorize?scope=scope&client_id=client_id&state=state&redirect_uri=redirect_uri&response_type=code

    https://ticktick.com/oauth/authorize?scope=scope&client_id=client_id&state=state&redirect_uri=redirect_uri&response_type=code
  4. Step 2: Handle the redirect and authorization code

    main

    Once the user authorizes your app, TickTick redirects them to your configured redirect_uri. You must extract the following query parameters from the URL:

    NameDescription
    codeThe authorization code used to request an access token
    stateThe state parameter you provided in the first step, used to verify the request integrity
  5. Authenticate with Dida365

    main

    For the China version of TickTick (Dida365), follow these steps:

    1. Register your application at the Dida365 Developer Center.
    2. Set the redirect URI to http://localhost:8000/callback.
    3. Manually add the following environment variables to your .env file:
    TICKTICK_BASE_URL='https://api.dida365.com/open/v1'
    TICKTICK_AUTH_URL='https://dida365.com/oauth/authorize'
    TICKTICK_TOKEN_URL='https://dida365.com/oauth/token'
    1. Run the standard authentication command: uv run -m ticktick_mcp.cli auth.
  6. Authenticate with TickTick via OAuth2

    main

    The server uses OAuth2. To set it up:

    1. Register your app at the TickTick Developer Center.
    2. Set the redirect URI to http://localhost:8000/callback.
    3. Run the CLI auth command:
      uv run -m ticktick_mcp.cli auth
    4. Enter your Client ID and Client Secret when prompted.
    5. Authorize via the browser window that opens.

    Tokens are automatically saved to a .env file and refreshed automatically.

    uv run -m ticktick_mcp.cli auth
  7. Install the TickTick MCP Server

    main

    To install the TickTick MCP server, you need Python 3.10+, uv, and TickTick API credentials. Follow these steps:

    1. Clone the repository:

      git clone https://github.com/jacepark12/ticktick-mcp.git
      cd ticktick-mcp
    2. Set up the environment with uv:

      # Install uv if not present
      curl -LsSf https://astral.sh/uv/install.sh | sh
      
      # Create and activate virtual environment
      uv venv
      # On macOS/Linux:
      source .venv/bin/activate
      # On Windows:
      .venv\Scripts\activate
      
      # Install the package in editable mode
      uv pip install -e .
    3. Authenticate: Run the authentication flow to link your TickTick account:

      uv run -m ticktick_mcp.cli auth
    git clone https://github.com/jacepark12/ticktick-mcp.git
    cd ticktick-mcp
    curl -LsSf https://astral.sh/uv/install.sh | sh
    uv venv
    source .venv/bin/activate
    uv pip install -e .
    uv run -m ticktick_mcp.cli auth
  8. Use the Getting Things Done (GTD) task filters

    main

    The server provides specialized tools based on the GTD framework to help focus on immediate priorities:

    • get_engaged_tasks: Returns tasks that require immediate attention. This includes tasks with High priority (5), tasks that are due today, or tasks that are overdue.
    • get_next_tasks: Returns tasks for upcoming focus. This includes tasks with Medium priority (3) or tasks due tomorrow.
  9. Get a task by Project ID and Task ID

    main

    Retrieve the details of a specific task using its taskId and the projectId it belongs to.

    Endpoint: GET /open/v1/project/{projectId}/task/{taskId}

    Path Parameters:

    • projectId (required): Project identifier.
    • taskId (required): Task identifier.

    Responses:

    • 200 OK: Returns the [Task] object.
    • 401 Unauthorized: Authentication failed.
    • 403 Forbidden: Insufficient permissions.
    • 404 Not Found: Task or Project not found.
    GET /open/v1/project/{{projectId}}/task/{{taskId}} HTTP/1.1
    Host: api.ticktick.com
    Authorization: Bearer {{token}}
  10. Step 3: Exchange authorization code for an access token

    main

    To obtain the access_token, make a POST request to https://ticktick.com/oauth/token.

    Requirements:

    • Content-Type: application/x-www-form-urlencoded
    • Authentication: Use Basic Auth in the request header. The client_id acts as the username and the client_secret acts as the password.

    Body Parameters:

    NameDescription
    codeThe code obtained from the redirect step
    grant_typeMust be authorization_code
    scopeSpaces-separated permission scopes (e.g., tasks:write tasks:read)
    redirect_uriThe same redirect URL used in the first step

    Response Format: Returns a JSON object containing the access_token:

    {
      "access_token": "access token value"
    }
    POST https://ticktick.com/oauth/token
    Content-Type: application/x-www-form-urlencoded
    Authorization: Basic <base64(client_id:client_secret)>
    
    code=YOUR_CODE&grant_type=authorization_code&scope=tasks:write tasks:read&redirect_uri=YOUR_REDIRECT_URI