Use local ZajLibrary MCP
Learn · guide · Library MCP · local
Use zajlibrary-local at http://localhost:4321/api/mcp when you need the dev corpus or the dev feedback queue — not on every session. Start npm run dev from app/ (port 4321 only), register both servers in .mcp.json, and after doc edits run npm run build:index then restart dev.
What you’ll learn
Section titled “What you’ll learn”- When local beats prod (and when it does not)
- One-time setup — dev server, dual MCP wiring, env for feedback
- Index refresh after content changes
- Three workflows — doc authoring, CodeCanyon first walkthrough, feedback dry-run
- Verify and troubleshoot local MCP
Before you start
Section titled “Before you start”| Requirement | Notes |
|---|---|
| ZajLibrary repo cloned | This guide assumes you can run dev from app/ |
| Node 22+ | Astro 6 requirement |
| MCP client | Cursor, Claude Code, or Streamable HTTP host |
| Feedback on local | app/.env.local with dev DATABASE_URL (Neon development branch) |
| Admin feedback tools | Optional MCP_ADMIN_TOKEN in app/.env.local + Bearer on MCP requests |
Full prod + tool reference: Use the ZajLibrary MCP.
When to use local (not production)
Section titled “When to use local (not production)”Register both zajlibrary and zajlibrary-local in your MCP client. Pick per session:
| Situation | Server |
|---|---|
| Real CodeCanyon deploy — shipping an app; stable playbook; handoff to others | zajlibrary (prod) |
| First-time walkthrough / QA — agent follows setup-new before you trust prod | zajlibrary-local |
| Authoring or enriching docs in this repo | zajlibrary-local |
Testing submit_feedback → dev queue + /admin without polluting prod | zajlibrary-local |
Unreleased playbook on dev not yet deployed | zajlibrary-local |
| Canonical URL in a PR, doc, or message to a teammate | zajlibrary (prod URLs) |
After local validation, re-check critical steps against prod before you treat a deploy as production-truth.
1. Start the dev server
Section titled “1. Start the dev server”From app/ (port 4321 is locked — do not use another port):
cd appnpm run devOpen http://localhost:4321. MCP endpoint: http://localhost:4321/api/mcp.
2. Wire both MCP servers
Section titled “2. Wire both MCP servers”Repo root .mcp.json:
{ "mcpServers": { "zajlibrary": { "type": "http", "url": "https://library.zajapps.com/api/mcp" }, "zajlibrary-local": { "type": "http", "url": "http://localhost:4321/api/mcp" } }}Reload MCP servers after editing. Disable or ignore zajlibrary-local when dev is not running (connection refused).
claude mcp add --transport http zajlibrary https://library.zajapps.com/api/mcp -s userclaude mcp add --transport http zajlibrary-local http://localhost:4321/api/mcp -s userclaude mcp list3. Env for local feedback (optional but recommended for QA)
Section titled “3. Env for local feedback (optional but recommended for QA)”Create or extend app/.env.local (gitignored):
DATABASE_URL=postgresql://… # Neon *development* branchMCP_ADMIN_TOKEN=your-long-random-token # optional — admin list/review toolssubmit_feedbackworks anonymously on local if DB is wired.list_feedback/review_feedbackneed BearerMCP_ADMIN_TOKEN(or an allowlisted Better Auth session on:4321).
Triage UI: http://localhost:4321/admin.
How local MCP loads content
Section titled “How local MCP loads content”The corpus is not read from disk at request time. The server imports a build-time index (src/mcp/generated/docs.json) when dev starts.
flowchart LR Edit["Edit .md / .mdx"] --> BuildIndex["npm run build:index"] BuildIndex --> DocsJson["docs.json"] DocsJson --> Restart["Restart npm run dev"] Restart --> Mcp["/api/mcp"] Mcp --> Agent["zajlibrary-local client"]| Event | Index updates? |
|---|---|
npm run dev start (predev) | Yes — regenerates index |
| Save a doc while dev runs | No — run build:index + restart |
| Prod deploy | Prod MCP updates after Vercel build |
Index refresh loop
Section titled “Index refresh loop”- Save under
app/src/content/docs/. cd app && npm run build:index- Restart dev (stop +
npm run dev, or fresh terminal). list_contents— confirmtotalDocsandcommitShaShortmatch expectation.
Workflows
Section titled “Workflows”A. Authoring or enriching library docs
Section titled “A. Authoring or enriching library docs”- Dev on 4321 · MCP client on
zajlibrary-local search_library→get_documentfor the page you are editing- After saves: index refresh loop (above)
- Before merge: spot-check the same page via prod if it is already deployed
B. First-time CodeCanyon setup-new walkthrough
Section titled “B. First-time CodeCanyon setup-new walkthrough”Use when an agent (or you) follows Set up a New CodeCanyon App before trusting the live playbook.
- Dev on 4321 ·
zajlibrary-local - Orient —
list_contents(codecanyon / setup-new paths) - Read —
get_documenteach phase; execute## Steps+## Checklistin order - Verify — command output for each checklist item
- Feedback — gaps via
submit_feedback(pageUrl,category,dedupeKey=<phase>/<step>) - Triage —
http://localhost:4321/admin(dev queue only) - Promote — when satisfied, repeat critical reads on
zajlibrary(prod)
Machine setup registration: Phase 1 · Machine setup §3.
C. Feedback dry-run (MCP + admin)
Section titled “C. Feedback dry-run (MCP + admin)”- Local dev + dev
DATABASE_URL - Agent calls
submit_feedbackwith a test row (use a realpageUrlwhen possible) - Confirm row in
/adminor vialist_feedbackwith Bearer token - Optional:
review_feedbackto move through review states on dev
Verify
Section titled “Verify”cd appnpm run test:mcpExpected: connects to :4321, all six tools registered, read tools exercised.
Manual checks:
# inside the ZajLibrary repo only: commit on disk should match list_contents.commitShaShort (local)git rev-parse --short HEADIn the MCP client: list_contents → note totalDocs, commitShaShort, semanticEnabled.
Troubleshooting
Section titled “Troubleshooting”| Symptom | Fix |
|---|---|
Connection refused on :4321 | cd app && npm run dev — port 4321 only |
| New page missing from search | npm run build:index then restart dev |
submit_feedback fails | Check dev DATABASE_URL in app/.env.local; run npm run feedback:schema if needed |
| Admin tools denied | Set MCP_ADMIN_TOKEN in .env.local; send Bearer on MCP requests; restart dev |
| Agent reads stale playbook | Wrong server — prod vs local; or index not refreshed |
| Local works, prod differs | Expected until you deploy — prod corpus updates on Vercel build |
Checklist
Section titled “Checklist”-
npm run devrunning on 4321 -
zajlibrary-localregistered; prod still available for deploy sessions - After doc edits:
build:index+ dev restart -
npm run test:mcppasses -
list_contents.commitShaShortmatches local git when validating WIP inside the ZajLibrary repo; consuming projects treat it as freshness metadata - Feedback QA uses dev DB; prod queue untouched until deploy
- Real deploy sessions use
zajlibrary(prod)