Repository navigation
Feat(mcp): serve MCP at /mcp, off by default - #74
Merged
Merged
Conversation
Looking for an unused note, attachment, folder or template name now stops on any answer but "exists" or "does not exist", and gives up after 10,000 tries, instead of holding the vault's lock for as long as it runs. Note titles and uploaded file names are cut to 200 bytes without splitting a character, and control characters are removed from them.
…file An upload that size spills to a temp file. The scratch image had no /tmp, so it failed there, and now ships one any user can write to. The temp file also outlived the request, because net/http only cleans up the form on the request it started with, and the router hands the handler a copy. A new CI job uploads 12 MiB to the running image, since only that shows this. The Go base image digest is refreshed.
A Markdown link to `a b.png` or `a(1).png` is not a link unless it is in angle brackets, and a rename or a move could bring either in. The rewrite now adds them, as zn does. A note holding only a bracketed link also did not count as holding an attachment, so a rename skipped it and the link went stale, which already affected links the server writes itself on upload.
ZENNOTES_MCP_ENABLED turns on a route with the tools and scope rules of `zn mcp`, which reach the vault through the server's own API in-process. MCP tokens open /mcp and nothing else, and the server's token and browser sessions do not open /mcp. One scope comes from environment variables, or a credentials file binds several tokens to their own scopes. A setting that cannot work stops the server from starting. A new CI job runs the shared scope contract through /mcp. The server now needs Go 1.26, and imports github.com/ZenNotes/tui/mcpserver. Not releasable yet: go.mod has a local replace, and requires a tui tag that does not exist. #56, ZenNotes/zennotes#965
The server now requires ZENNOTES_VAULT_PATH with MCP on, which stops a vault switch, so the check for one is gone. A blank, empty or null allow list is refused rather than sharing the whole vault. In-process calls reach only the routes the tools use, stop if their time is up, and hold at most 64 MiB or twice the note limit of a response, and `read_note` checks a note's size before reading it. Search takes a `limit`, which a scoped client needs so that hidden matches cannot crowd out visible ones. CI and releases use Go 1.26.x rather than exactly the version in go.mod.
…he container `/api/assets/raw` sends a `sandbox` Content-Security-Policy on everything but PDFs, and serves scripts and wasm as plain text, since a vault's files can come from someone with less access than whoever views them. Images still draw, SVG included. In a container with a memory limit, the server sets a soft limit of 70% of it at startup. A GOMEMLIMIT someone set wins. Also: a limit on how long request headers may take, an end to the origins remembered for the CORS log, and the preflight allows Mcp-Protocol-Version.
A blank, empty or null deny list is refused, as an allow list already was. How many tool calls run at once follows the memory limit. go.mod names a toolchain, so that a build gets the latest fixes. The README covers the new limits, read-only containers and single-note deny entries.
A tool's answer stays in memory until its client reads it, so a memory limit now also lowers how many requests may be open (8 up to 800 MiB, 16 up to 2 GiB, otherwise 32) and the largest answer a tool may get from the API, to no less than 16 MiB. The README says what this costs: a small server under a burst answers some requests with a 503.
The largest answer to a tool call follows the memory limit, as the largest response from the API does, and is counted after JSON encoding. The README says what this means for a note made almost entirely of quotes, and that a deny entry naming a single note shuts a credential out once that note moves.
Drops the local replace, so CI and the Nix and Docker builds can build this branch. The vendor hash follows go.mod; the version stays 2.82.1 until the release sets 2.83.0.
Windows reports mode 666 for any file a user can write, and says a path under a file does not exist. The second means the name reads as free and the write refuses, so the search still ends on its first try.
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.
Serves the MCP tools at
/mcp, off by default, so assistants on other machines can use a vault without installingzn. The tools and scope rules come fromgithub.com/ZenNotes/tui/mcpserverat v0.17.0, the same code aszn mcp.#56, ZenNotes/zennotes#965
What it does
ZENNOTES_MCP_ENABLEDturns on the route. While it is off, the route does not exist and the other MCP variables are not read./mcpand nothing else. The server's token and browser sessions do not open/mcp.The README's new "MCP for AI assistants" section has the setup and the limits.
Also in this branch
/tmp, and leave no temp file./api/assets/rawsends asandboxContent-Security-Policy on everything but PDFs, and serves scripts and wasm as plain text.GOMEMLIMITyou set wins.Compatibility
release.jsonkeeps version 2.82.1, and onlyvendorHashchanges. The README describes/mcpas "since server 2.83.0", which the release sets.Tests
go vet ./...andgo test -p 1 -count=1 ./...pass.v0.17.0tag through this server:go test ./internal/mcp ./internal/remotepasses with both contract variables set. The/mcprun alone is 85 tests and subtests, none skipped.linux/arm64: it starts healthy,/mcpis absent by default and answers once on, tokens stay on their own side, scoped calls behave, and it comes back after a restart. Tokens and note text do not reach the log.nix-buildwith CI's pinned image passes onaarch64. CI'snixjob coversx86_64.New CI:
mcp-contractruns the shared contract through/mcpfrom thetuitaggo.modpins, anddocker-uploaduploads 12 MiB to the running image.Not tested: the hop through OpenAI's tunnel-client, which needs an OpenAI tunnel.