feat(mcp): opt-in write tools gated by --toolsets#99
Open
ryanlewis wants to merge 2 commits into
Open
Conversation
Expose the CLI's write surface (add, edit, complete, cancel, the project variants, log, import) as MCP tools, grouped into GitHub-style toolsets mounted with --toolsets (tasks, projects, areas, tags, bulk; "all" and THINGS_TOOLSETS supported). Writes are off by default; --read-only=false enables the write tools of the mounted toolsets, so a bare `things mcp` stays read-only and byte-identical to before. - A Writer interface (default forwards to internal/things) keeps the handlers unit-testable without shelling out to open/osascript. - edit/edit_project/import read the URL-scheme auth token from the DB; complete handles the project cascade; cancel points projects at edit. - add/edit are submitted-not-confirmed (URL scheme); complete/cancel are synchronous (AppleScript). Tool descriptions say so. Refs #82
…ad errors, reject empty import Extra-high-effort review fixes: - things_complete now refuses a project (which would cascade-complete every to-do inside it) and points at things_edit_project (complete=true). The CLI guards that cascade behind an interactive y/N and refuses it non-interactively; MCP has no prompt, so don't do it silently. Drops the now unused Writer.CompleteProject. - things_edit / things_edit_project / things_import no longer treat a GetAuthToken read error as fatal (`token, _ :=`, like the CLI): a missing token yields the actionable "enable Things URLs" guidance, and a create-only import proceeds without one. - validateImportPayload rejects an empty array "[]" (parity with the CLI's validateImportJSON) so a no-op import isn't reported as submitted. - Add TestEveryToolsetRegistersTools so AllToolsets can't drift from registerTools (a declared toolset registering nothing now fails the build).
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.
Stacked on #98 (base
feat/issue-82-mcp; GitHub will retarget this tomainonce #98 merges).Adds the write half of the MCP server, gated GitHub-MCP style.
What
--toolsets(comma-separated;allshorthand;THINGS_TOOLSETSenv) mounts only the domain groups you use:tasks,projects,areas,tags,bulk. Each toolset owns its read tools (always on) and write tools (opt-in).--read-onlydefaults on. Write tools register only with--read-only=false(or--no-read-only), so a barethings mcpstays read-only and byte-identical to feat(mcp): read-only MCP server baked into the CLI (things mcp) #98 (still exactly 6 read tools).things_add,things_edit,things_complete,things_cancel,things_add_project,things_edit_project,things_log,things_import.How
Writerinterface (default forwards tointernal/things; all ops already exist and self-validate) keeps handlers unit-testable without shelling out toopen/osascript.GetTask+ the existingambiguousErrorhelper (the non-interactive subset of the CLI'sresolveTask); no stdin prompts, no last-list cache.edit/edit_project/importread the URL-scheme auth token from the DB (Backend.GetAuthToken).completehandles the project cascade;cancelpoints projects atedit_project.add/editare submitted, not confirmed (URL scheme, async);complete/cancelare synchronous (AppleScript). Tool descriptions shout that they MUTATE.Config.EnableWritesso the zero value is read-only (safe default); the CLI maps--read-onlyonto it.Tests
internal/mcpserver/writes_test.go: toolset/read-only gating matrix, each write handler forwards correct params to a recordingWriterfake, ambiguous-ref + missing-token error paths.cmd/things/mcp_integration_test.go: spawns the real binary and asserts tools/list under default /--toolsets=tasks/--read-only=false(write tools are listed, never called).make build,make test(race),make lint,make test-integrationall green.internal/skill/SKILL.mdis intentionally unchanged (same standing exception as #98: the MCP server is a long-running server, not a Bash one-shot the skill drives).Refs #82