Skip to content
prod 352bb92
Browse

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.


  • 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

RequirementNotes
ZajLibrary repo clonedThis guide assumes you can run dev from app/
Node 22+Astro 6 requirement
MCP clientCursor, Claude Code, or Streamable HTTP host
Feedback on localapp/.env.local with dev DATABASE_URL (Neon development branch)
Admin feedback toolsOptional MCP_ADMIN_TOKEN in app/.env.local + Bearer on MCP requests

Full prod + tool reference: Use the ZajLibrary MCP.


Register both zajlibrary and zajlibrary-local in your MCP client. Pick per session:

SituationServer
Real CodeCanyon deploy — shipping an app; stable playbook; handoff to otherszajlibrary (prod)
First-time walkthrough / QA — agent follows setup-new before you trust prodzajlibrary-local
Authoring or enriching docs in this repozajlibrary-local
Testing submit_feedback → dev queue + /admin without polluting prodzajlibrary-local
Unreleased playbook on dev not yet deployedzajlibrary-local
Canonical URL in a PR, doc, or message to a teammatezajlibrary (prod URLs)

After local validation, re-check critical steps against prod before you treat a deploy as production-truth.


From app/ (port 4321 is locked — do not use another port):

Terminal window
cd app
npm run dev

Open http://localhost:4321. MCP endpoint: http://localhost:4321/api/mcp.

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).

Section titled “3. Env for local feedback (optional but recommended for QA)”

Create or extend app/.env.local (gitignored):

Terminal window
DATABASE_URL=postgresql://… # Neon *development* branch
MCP_ADMIN_TOKEN=your-long-random-token # optional — admin list/review tools
  • submit_feedback works anonymously on local if DB is wired.
  • list_feedback / review_feedback need Bearer MCP_ADMIN_TOKEN (or an allowlisted Better Auth session on :4321).

Triage UI: http://localhost:4321/admin.


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"]
EventIndex updates?
npm run dev start (predev)Yes — regenerates index
Save a doc while dev runsNo — run build:index + restart
Prod deployProd MCP updates after Vercel build
  1. Save under app/src/content/docs/.
  2. cd app && npm run build:index
  3. Restart dev (stop + npm run dev, or fresh terminal).
  4. list_contents — confirm totalDocs and commitShaShort match expectation.

  1. Dev on 4321 · MCP client on zajlibrary-local
  2. search_libraryget_document for the page you are editing
  3. After saves: index refresh loop (above)
  4. 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.

  1. Dev on 4321 · zajlibrary-local
  2. Orientlist_contents (codecanyon / setup-new paths)
  3. Readget_document each phase; execute ## Steps + ## Checklist in order
  4. Verify — command output for each checklist item
  5. Feedback — gaps via submit_feedback (pageUrl, category, dedupeKey = <phase>/<step>)
  6. Triagehttp://localhost:4321/admin (dev queue only)
  7. Promote — when satisfied, repeat critical reads on zajlibrary (prod)

Machine setup registration: Phase 1 · Machine setup §3.

  1. Local dev + dev DATABASE_URL
  2. Agent calls submit_feedback with a test row (use a real pageUrl when possible)
  3. Confirm row in /admin or via list_feedback with Bearer token
  4. Optional: review_feedback to move through review states on dev

Terminal window
cd app
npm run test:mcp

Expected: connects to :4321, all six tools registered, read tools exercised.

Manual checks:

Terminal window
# inside the ZajLibrary repo only: commit on disk should match list_contents.commitShaShort (local)
git rev-parse --short HEAD

In the MCP client: list_contents → note totalDocs, commitShaShort, semanticEnabled.


SymptomFix
Connection refused on :4321cd app && npm run dev — port 4321 only
New page missing from searchnpm run build:index then restart dev
submit_feedback failsCheck dev DATABASE_URL in app/.env.local; run npm run feedback:schema if needed
Admin tools deniedSet MCP_ADMIN_TOKEN in .env.local; send Bearer on MCP requests; restart dev
Agent reads stale playbookWrong server — prod vs local; or index not refreshed
Local works, prod differsExpected until you deploy — prod corpus updates on Vercel build

  • npm run dev running on 4321
  • zajlibrary-local registered; prod still available for deploy sessions
  • After doc edits: build:index + dev restart
  • npm run test:mcp passes
  • list_contents.commitShaShort matches 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)