# MCP — timer.kituwa.com

Two transports, one tool table.

| Transport | Where | Auth |
| --- | --- | --- |
| stdio | `python3 -m server.mcp_server` on the worker | none (local process) |
| Streamable HTTP | `POST https://timer.kituwa.com/mcp` | `Authorization: Bearer $MCP_TOKEN` |

`GET /mcp` returns a server card (name, version, protocol version, tool list)
when the bearer token is present. Requests without it get `401` and a
`WWW-Authenticate: Bearer` header.

## Tools

| Tool | Arguments | Returns |
| --- | --- | --- |
| `list_presets` | `category?`, `query?` | The library items (same JSON as `/api/v1/presets`) |
| `create_timer` | `seconds` \| `minutes` \| `duration`, `label?` | `seconds`, `clock`, deep link |
| `create_alarm` | `time` (HH:MM), `label?`, `days?`, `timezone?` | Next occurrence, seconds until, deep link |
| `create_email_alert` | `email`, `label?`, `fire_at?` \| `seconds_from_now?`, `timezone?` | Alert id, status, status URL |
| `world_clock` | `zones` (IANA names, max 6) | Local time, date, offset, working-hours state |
| `convert_duration` | `value` (`"5:00"`, `"90m"`, `300`), `unit?` | seconds, minutes, hours, clock |

`create_email_alert` obeys the website's limits exactly: 5 pending per address,
12 creations per IP per hour, 200 per day across the service, `fire_at` between
now+5s and now+30d. It never returns another person's address.

## Client configuration

### HTTP (remote)

```json
{
  "mcpServers": {
    "kituwa-timer": {
      "type": "http",
      "url": "https://timer.kituwa.com/mcp",
      "headers": {
        "Authorization": "Bearer <MCP_TOKEN>"
      }
    }
  }
}
```

The token lives in `/home/airdrop/lock/timer-kituwa.env` on the worker
(`MCP_TOKEN`), staged with the other service secrets. Put it in the client's
secret store, never in a repository or a shell history file.

### stdio (on the worker)

```json
{
  "mcpServers": {
    "kituwa-timer": {
      "command": "python3",
      "args": ["-m", "server.mcp_server"],
      "cwd": "/home/airdrop/projects/timer-kituwa",
      "env": {
        "TIMER_DB": "/var/lib/timer-kituwa/timer.db",
        "SMTP_HOST": "mail.kituwa.com",
        "SMTP_PORT": "465",
        "SMTP_SSL": "true",
        "SMTP_USER": "no-reply@kituwa.com",
        "ALERT_FROM": "no-reply@kituwa.com",
        "ALERT_REPLY_TO": "support@kituwa.com"
      }
    }
  }
}
```

For a stdio client that will create email alerts, add `SMTP_PASS` and
`MCP_TOKEN` from the env file (the same names). A timer-only client needs no
secrets.

## Quick check

```bash
curl -s https://timer.kituwa.com/mcp \
  -H "Authorization: Bearer $MCP_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18"}}'
```

Expected: `result.serverInfo.name` is `kituwa-timer`, and `result.capabilities`
advertises `tools`.

```bash
curl -s https://timer.kituwa.com/mcp \
  -H "Authorization: Bearer $MCP_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"create_timer","arguments":{"duration":"5:00","label":"Tea"}}}'
```

Expected: `structuredContent.deep_link` is
`https://timer.kituwa.com/?tool=timer&t=300&label=Tea`.

## Notes

* The HTTP endpoint is stateless; it returns an `Mcp-Session-Id` header but does
  not require the client to keep it.
* Notifications (`notifications/initialized`, `notifications/cancelled`) answer
  `202` with no body, as the transport expects.
* Errors use JSON-RPC codes: `-32601` unknown method, `-32602` bad arguments,
  `-32603` internal error.
