feat: add client CRUD tools - #40
Open
madisonrickert wants to merge 5 commits into
Open
Conversation
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>
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:
I’m leaving this PR open for traceability while #61 moves through review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_client—POST /workspaces/{wid}/clients. Required:name. Optional:notes,external_reference.toggl_update_client—PUT /workspaces/{wid}/clients/{cid}. Toggl requiresnameon every update, so the schema marks it required and the runtime guard rejects calls that omit it. Pass the existing name unchanged when only adjustingnotesorexternal_reference. Optional:notes,external_reference.toggl_delete_client—DELETE /workspaces/{wid}/clients/{cid}.All three resolve workspace via
resolveWorkspaceForTool, return viajsonResponse, and callcache.invalidateWorkspaceClients(workspaceId)after each write so a subsequenttoggl_list_clientsreflects the change without a manualtoggl_clear_cache.Out of scope
Toggl's archive/restore endpoints (
POST /clients/{cid}/archiveand/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: 0like the other DELETE endpoints. Same fix, same patch-id collision story.Commits
fix(api): handle Toggl 200/empty-body responses— cherry-picked from feat: add time entry CRUD tools (closes #7, revisits #8 and #12) #38feat(api): add client CRUD methods to TogglAPI client— Co-Authored-By: Andrew Miller (create lifted from84emllc/mcp-toggl@eef1bea; update and delete added on top)feat(cache): add workspace client invalidationfeat(tools): expose client CRUD as MCP toolsdocs: document client CRUD tools in READMEVerification
npm test— 35/35 passing (4 new API-level tests: POST/PUT/DELETE shape, 4xx no-retry)npm run build— cleannpm run lint— no new warningscreate(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.