Skip to content

feat: add client CRUD tools - #40

Open
madisonrickert wants to merge 5 commits into
verygoodplugins:mainfrom
madisonrickert:feat/client-crud
Open

feat: add client CRUD tools#40
madisonrickert wants to merge 5 commits into
verygoodplugins:mainfrom
madisonrickert:feat/client-crud

Conversation

@madisonrickert

@madisonrickert madisonrickert commented May 2, 2026

Copy link
Copy Markdown
Contributor

Ok last one for now!

Adds full client CRUD (create, update, delete). Sister PR to #39 (project CRUD); same coordination pattern as #37, #38, and #39.

Note

Builds on #38. The request() 200/empty-body fix is cherry-picked from #38 because client DELETE shares the same Toggl 200/empty response shape — patch-id collision will let the duplicate commit drop cleanly when either PR rebases. Happy to merge in any order — your call.

What's added

  • toggl_create_clientPOST /workspaces/{wid}/clients. Required: name. Optional: notes, external_reference.
  • toggl_update_clientPUT /workspaces/{wid}/clients/{cid}. Toggl requires name on every update, so the schema marks it required and the runtime guard rejects calls that omit it. Pass the existing name unchanged when only adjusting notes or external_reference. Optional: notes, external_reference.
  • toggl_delete_clientDELETE /workspaces/{wid}/clients/{cid}.

All three resolve workspace via resolveWorkspaceForTool, return via jsonResponse, and call cache.invalidateWorkspaceClients(workspaceId) after each write so a subsequent toggl_list_clients reflects the change without a manual toggl_clear_cache.

Out of scope

Toggl's archive/restore endpoints (POST /clients/{cid}/archive and /restore) are premium-only and offer different semantics than basic CRUD. Left as a follow-up to keep this PR tight.

Includes the empty-body fix (cherry-picked from #38)

Client DELETE returns 200/content-length: 0 like the other DELETE endpoints. Same fix, same patch-id collision story.

Commits

  1. fix(api): handle Toggl 200/empty-body responses — cherry-picked from feat: add time entry CRUD tools (closes #7, revisits #8 and #12) #38
  2. feat(api): add client CRUD methods to TogglAPI client — Co-Authored-By: Andrew Miller (create lifted from 84emllc/mcp-toggl@eef1bea; update and delete added on top)
  3. feat(cache): add workspace client invalidation
  4. feat(tools): expose client CRUD as MCP tools
  5. docs: document client CRUD tools in README

Verification

  • npm test — 35/35 passing (4 new API-level tests: POST/PUT/DELETE shape, 4xx no-retry)
  • npm run build — clean
  • npm run lint — no new warnings
  • Smoke-tested end-to-end against a real Toggl workspace: create (with notes) → update (rename + notes change) → delete. Cache invalidation verified.

Scope

Client CRUD only. Sister PR for project CRUD is at #39. Archive/restore (premium-only) and bulk operations are out of scope.

madisonrickert and others added 5 commits May 2, 2026 12:44
Toggl returns HTTP 200 with content-length: 0 (not 204) on some write
endpoints, including DELETE /workspaces/{wid}/tags/{tid} and
DELETE /workspaces/{wid}/time_entries/{tid}, per the official Toggl
Engineering API docs. The existing request() short-circuited only on
204, so it called response.json() on the empty body, which threw and
triggered the retry loop without noRetry. The retried call then got a
real 404 because the first call had already succeeded server-side,
surfacing the misleading "Tag was not found" / "not found" errors to
callers despite the operation having completed.

Treat 200 with content-length: 0 (or empty body when Content-Length is
absent) the same as 204. Behavior unchanged for non-empty success
responses.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds createClient, updateClient, and deleteClient methods plus the
backing CreateClientRequest and UpdateClientRequest types. Toggl's PUT
endpoint requires name on every update, so UpdateClientRequest reflects
that.

Create lifted from 84emllc/mcp-toggl@eef1bea; update and delete are
added on top to round out the CRUD surface. Toggl's archive/restore
endpoints (premium-only) are intentionally out of scope for this PR.

Co-Authored-By: Andrew Miller <andrew@84em.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds invalidateWorkspaceClients so callers can drop the cached client
list and per-client entries for a workspace after a write. Mirrors
invalidateWorkspaceTags from the tag CRUD work in PR verygoodplugins#37.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds toggl_create_client, toggl_update_client, and toggl_delete_client
tool definitions and handlers. Each handler resolves the workspace, calls
the matching TogglAPI method, and invalidates cached clients for the
workspace so subsequent toggl_list_clients reflects the change.

toggl_update_client surfaces Toggl's name-required-on-PUT semantics in
its schema and runtime guard so callers do not silently null-out the
client's name.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@madisonrickert
madisonrickert marked this pull request as ready for review May 2, 2026 20:08
@jack-arturo

Copy link
Copy Markdown
Member

Thanks for the client CRUD work here. I created a maintainer refresh branch/PR at #61 with attribution preserved in the cherry-picked commits.

What changed in the refresh:

  • stacked on feat(toggl): add time entry task tools #58 so client CRUD reuses the shared successful-empty-body/write behavior instead of carrying the duplicate fix here
  • changed client writes to use the shared single-attempt write path
  • added server.json, cache, API, and MCP handler coverage for the public tools
  • kept the update semantics that Toggl requires: name is required on update

I’m leaving this PR open for traceability while #61 moves through review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants