Skip to Content
TimeWren Docs
API

MCP server

Connect Claude, Cursor, Codex and other MCP clients to TimeWren to log time, check prepaid hours and prepare invoices.

TimeWren includes a Model Context Protocol server, so an AI assistant can work with your clients, time entries, prepaid packages and invoices. It uses the same business logic as the REST API.

Endpoint

https://timewren.example.com/api/v1/mcp

The transport is Streamable HTTP. Discovery documents are served at /.well-known/mcp/server-card.json and /.well-known/oauth-protected-resource/api/v1/mcp. The URLs inside them are built from NEXT_PUBLIC_APP_URL, so make sure it matches the public address of your instance (see Environment).

Authentication

There are two ways to authenticate. Both send a Bearer token in the Authorization header.

  • API key. Create a tk_live_... key in Settings, then API and use it as the Bearer token. See REST API. This is the simplest option for Claude Code, Cursor and scripts.
  • OAuth. Clients that support MCP authorization (for example Claude's custom connectors) discover the authorization server from the 401 response and let you sign in to TimeWren in the browser. The server supports dynamic client registration, PKCE and refresh tokens. On the consent screen you pick the organization and review the permissions. Access tokens start with tt_at_ and can be revoked at any time.

Without a valid token the endpoint answers 401.

What an MCP client can do

An API key keeps exactly the scopes you gave it when you created it. An OAuth connection gets the read and write scopes shown on the consent screen (clients, projects, time, invoices, prepaid, tasks and reports; never webhooks, and never the all-access * scope), and is bound to the one organization you chose. Every tool checks the scope it needs before it runs, using the same rules as the REST routes, and returns an error if the connection lacks it. Requests are limited to 120 per minute per key or connected app and user.

Tools

ToolScopeWhat it does
whoaminoneReturn the user id, organization and scopes of the current connection
list_clientsclients:readList clients with default hourly rate and contact info, with search and paging
get_clientclients:readGet one client by id
create_clientclients:writeCreate a client
list_time_entriestime:readList time entries, newest first, filtered by client, project, dates, billable and billed
create_time_entrytime:writeLog time for a client or project, optionally drawing from a prepaid package with prepaid: "auto" or prepaidPackageId
update_time_entrytime:writeChange fields of a time entry; billed entries are locked
list_prepaid_packagesprepaid:readList prepaid packages with total, used and remaining hours, expiry and status
unbilled_summaryreports:readUnbilled billable hours and amount per client
list_invoicesinvoices:readList invoices, optionally for one client or status
invoice_from_time_entriesinvoices:writePreview (dryRun) or create a draft invoice from a client's time entries; creating marks the entries as billed
send_invoiceinvoices:writeEmail an invoice to the client, which cannot be undone
week_timesheettime:readYour own time entries for one week (Monday to Sunday) per day with totals; an interactive timesheet in clients that support MCP Apps
klippekort_statusprepaid:readPrepaid packages with remaining hours, low or critical level and expiry, most urgent first; gauges in clients that support MCP Apps

List tools return a note telling the assistant which page to request next when the result is only partial. invoice_from_time_entries and send_invoice change data or contact your client, so ask your assistant to confirm with you before it calls them.

Interactive views (MCP Apps)

The server supports the MCP Apps extension (io.modelcontextprotocol/ui). In a client that supports it, for example Claude or ChatGPT, two tools show an interactive view in the conversation instead of plain text:

  • Week timesheet (week_timesheet). Ask "show my week". The view shows your entries per day with totals. Use the arrows to switch week, or Edit to change the hours or description of an entry. Billed entries are locked.
  • Klippekort status (klippekort_status). Ask "how much is left on Bageriet's klippekort". Each package has a gauge, its remaining hours and its expiry. Draft invoice sends a message asking the assistant for an invoice preview (dryRun) and to wait for your approval. The view cannot enforce that: creating the draft is a separate call to invoice_from_time_entries, which needs invoices:write (also for the preview) and marks the entries as billed. Keep tool approval on in your client so you confirm that call yourself. Top up in TimeWren opens the package in TimeWren.

The views follow your instance's brand name and colours and the language and light or dark theme of the client. They are served as ui:// resources, load nothing from the internet and get their data from the tool result.

Everything a view changes goes through the same tools as the assistant, with the same scope checks. Editing an entry calls update_time_entry, so it needs time:write, and a key with only time:read can show the timesheet but not save changes.

Clients without MCP Apps call the same tools and get a text summary with the data as JSON, so nothing needs to be configured. A client that says in its capabilities that it does not support the extension gets the tools without UI metadata.

Client configuration

Replace the URL and YOUR_API_KEY with your own values.

Claude Code

claude mcp add --transport http timewren https://timewren.example.com/api/v1/mcp --header "Authorization: Bearer YOUR_API_KEY"

Cursor

Add this to .cursor/mcp.json in your project, or to ~/.cursor/mcp.json for all projects:

{
  "mcpServers": {
    "timewren": {
      "url": "https://timewren.example.com/api/v1/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_API_KEY"
      }
    }
  }
}

Claude Desktop

The simplest route is a custom connector: open Settings, then Connectors, add a custom connector and enter the endpoint URL. You sign in with OAuth, no key needed.

To use an API key instead, bridge through mcp-remote in claude_desktop_config.json (requires Node.js):

{
  "mcpServers": {
    "timewren": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-remote",
        "https://timewren.example.com/api/v1/mcp",
        "--header",
        "Authorization:${TIMEWREN_AUTH}"
      ],
      "env": {
        "TIMEWREN_AUTH": "Bearer YOUR_API_KEY"
      }
    }
  }
}

Codex

Add this to ~/.codex/config.toml and export the key as an environment variable:

[mcp_servers.timewren]
url = "https://timewren.example.com/api/v1/mcp"
bearer_token_env_var = "TIMEWREN_API_KEY"
export TIMEWREN_API_KEY="YOUR_API_KEY"

Troubleshooting

  • 401: the token is missing, wrong, revoked or expired. Test it with curl https://timewren.example.com/api/v1/me -H "Authorization: Bearer YOUR_API_KEY".
  • A tool returns Forbidden: missing required scope: create a key with the scope listed in the table above.
  • 429: you hit the rate limit. Wait for the number of seconds in the Retry-After header.

On this page