Get the FREE Ultimate OpenClaw Setup Guide →

zenstack -auth

ZenStack Remote MCP Server with Authorization

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio jiashengguo-zenstack-mcp-auth npm run dev

How to use

This MCP server automatically exposes CRUD and analytics tools for the models defined in the ZenStack schema (in the demo, User and Post). It generates MCP operations such as findUnique, findFirst, findMany, create, createMany, delete, deleteMany, update, updateMany, upsert, aggregate, groupBy, and count. You can opt into the specific tools by configuring the functionNames in mcp-server.ts if you need to limit capabilities. To use the server, first ensure your ZenStack setup is ready, then start the server and connect via an MCP client or inspector. The server speaks the MCP Streamable HTTP protocol and supports credential authentication for multi-client access.

Once running, you can invoke the generated MCP tools against your User and Post models (for example, finding a user by ID, creating posts for a user, updating user attributes, or aggregating counts). If your MCP client supports OAuth2, you can connect directly; otherwise you can use mcp-remote to connect to http://localhost:3001/mcp and manage authentication and sessions across tools.

How to install

Prerequisites:

  • Node.js and npm installed
  • A ZenStack project with a database configured for Prisma

Step 1: Install dependencies

npm install

Step 2: Set up the database and generated tools

npx zenstack generate
npx prisma db push

Step 3: (Optional) Seed the database

npx prisma db seed

Step 4: Start the MCP server

npm run dev

Step 5: Verify the server

  • The server should start and listen for MCP connections. You can connect with an MCP client or inspector to test the generated tools (findUnique, findMany, create, update, etc.) against User and Post models.

Additional notes

Tips and caveats:

  • If you encounter invalid client errors during OAuth, try clearing cached state at ~/.mcp-auth: rm -rf ~/.mcp-auth
  • When using Claude Desktop or similar clients, ensure you're on a compatible Node version. If OAuth windows do not appear, it might be caused by older Node versions; consider cleaning up older Node versions in your NVM setup.
  • The server relies on ZenStack-generated models (e.g., User, Post). Ensure your schema matches expectations to avoid missing tool generation.
  • You can restrict tools via the functionNames option in mcp-server.ts to tailor the available MCP operations for your deployment.
  • If you deploy behind proxies or require authentication, configure the appropriate OAuth2 or credential providers and ensure your MCP client is aware of the endpoints (e.g., /mcp path).
  • Debugging: check logs for tool generation status and ensure the Prisma schema is in sync with the ZenStack models.

Related MCP Servers

Sponsor this space

Reach thousands of developers