Developer GuideSetup

Local Development

Set up Node.js 22+, install dependencies, configure local Discord OAuth redirects, and run the MCP server and documentation portal locally.

Prerequisites

  • Node.js 22 or newer:: mcp/package.json requires "node": ">=22.0.0" for native fetch, Web Crypto parity, and current ESM module resolution.
  • MongoDB access:: A reachable MongoDB database for MCP_MONGODB_URI (taicket_mcp) plus the Taicket core and module database URIs configured in the root .env file.
  • Discord OAuth2 redirect:: Add http://localhost:4130/oauth/discord/callback under OAuth2 -> Redirects in the Discord Developer Portal for your development application.

Install dependencies and start dev servers

  1. 1

    Install backend and docs-site dependencies

    Run npm install inside both mcp/ and mcp/docs-site/ from the repository root.

    Install dependenciesbash
    npm --prefix mcp install
    npm --prefix mcp/docs-site install
  2. 2

    Configure local environment overrides

    For local OAuth testing, point the issuer, resource, and Discord callback URLs in root .env (or your shell session) to localhost:4130.

    Local URL environment overridesbash
    MCP_PORT=4130
    MCP_HOST=127.0.0.1
    MCP_ISSUER_URL=http://localhost:4130
    MCP_RESOURCE_URL=http://localhost:4130/mcp
    MCP_DISCORD_REDIRECT_URI=http://localhost:4130/oauth/discord/callback
  3. 3

    Start the MCP server in watch mode

    Uses tsx watch src/index.ts to hot-reload the Express + MCP server on port 4130.

    Start MCP server dev watcherbash
    npm --prefix mcp run dev
  4. 4

    Start the Next.js docs dev server (optional)

    When editing pages or components in mcp/docs-site/, launch Next.js dev mode on port 4131.

    Start docs-site dev server on port 4131bash
    npm --prefix mcp/docs-site run dev

Verify local endpoints and full production bundle

Smoke-check local MCP metadata and health endpointsbash
curl -s http://localhost:4130/health
curl -s http://localhost:4130/.well-known/oauth-protected-resource
curl -s http://localhost:4130/.well-known/oauth-authorization-server

# Unauthenticated /mcp must return 401 with WWW-Authenticate
curl -i -X POST http://localhost:4130/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'

To test the exact production layout where Express serves both /mcp and the statically exported documentation site from mcp/dist/site/, run npm --prefix mcp run build:all.

Keep other workspace services isolated

Develop and test exclusively inside mcp/ and mcp/docs-site/. Do not launch or restart the Discord bot process (bot/aimoderation/index.js) from MCP development scripts.

Related documentation