[integrations] Wiki MCP tools#366
Conversation
Expose the persistent-wiki surface to any AI client without touching the core MCP server: wiki_list_pages, wiki_get_page, and a wiki_write_section that routes every write through the schema's regen guard so human-owned sections park a pending draft instead of being overwritten. Built as a remote Supabase Edge Function (per-request MCP construction, UUID page ids) following integrations/update-thought-mcp. Depends on the schemas/wiki-pages tables and RPC. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The committed import map only declared @supabase/supabase-js, so copying
deno.json + index.ts into a Supabase function left @hono/mcp,
@modelcontextprotocol/sdk, hono, and zod as unresolved bare specifiers
and bundling failed. Mirror the canonical versions from server/deno.json.
Resolving the imports surfaced a real type error: deno check now reaches
the wiki_write_section result-narrowing, where the {result: data} union
branch lacks .action/.section_id. Annotate result as Record so the
typecheck passes clean.
Add a "More from Nate" provenance CTA to the README.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cfa83cee2d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const text = [ | ||
| `[${pageRow.page_kind}] ${pageRow.slug}: ${pageRow.title} (id=${pageRow.id})`, | ||
| `Sections (${sectionRows.length}):`, | ||
| ...(sectionLines.length ? sectionLines : [" (none)"]), | ||
| ].join("\n"); |
There was a problem hiding this comment.
Include page text in wiki_get_page results
When wiki_get_page is called through an MCP host or adapter that only forwards the content text blocks to the model, the call appears successful but returns only section keys/headings; the actual body_md and pending draft text are only placed in structuredContent. In that environment the agent cannot actually read the page it was asked to fetch, nor safely decide how to update a section, so the text response should include the section bodies or a serialized equivalent.
Useful? React with 👍 / 👎.
Adds a standalone remote MCP Edge Function under
integrations/wiki-mcp/that exposes the persistent-wiki surface to any AI client, without modifying the curated core MCP server.Three tools
wiki_list_pages— list active wiki pages (most recently updated first) with a section count each. Read-only.wiki_get_page— fetch one page by slug, with all its sections and any pending generated drafts. Read-only. Returns thepage_id(a UUID) and section keys you need to write.wiki_write_section— write or refresh a section, identified bypage_idandsection_key. It always writes asorigin='generated', then surfaces the database'sactionverbatim:created/updated— the write landed.pending— the section is human-owned, so the text parked as a pending draft for review. The tool tells the caller not to retry.How it works
The regen guard, origin enforcement, and revision history all live in the
wiki_write_sectionRPC from theschemas/wiki-pagesschema, so this function is a thin, faithful surface over that one guard — every writer obeys the same rule. The machine proposes; a human accepts.Built from
integrations/update-thought-mcpas the structural template: Hono + StreamableHTTPTransport,x-brain-key/?key=auth, the same CORS and Accept-header handling. The MCP server is constructed per request (matching the core server's #261 refactor), and all ids are treated as UUID strings —page_idis validated as a UUID and never parsed as a number.Dependency
Requires the
schemas/wiki-pagesschema (fork PR #41) to be applied first — this function calls itswiki_pages/wiki_sectionstables andwiki_write_sectionRPC. The README's prerequisites and troubleshooting call that out.Notes
claude_desktop_config.json..github/metadata.schema.json; all ob1-gate-v2 rules simulated locally and pass.