Puzzlebottom/totm-convex-mcp
If you are the rightful owner of totm-convex-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
The TOTM Convex MCP Server is designed to manage encounters, player characters, and monster templates within a Convex app environment.
TOTM Convex MCP Server
An MCP (Model Context Protocol) server that connects to your Convex app totm-convex to manage encounters, player characters, and monster templates.
Features
The server provides the following tools:
- list_encounters - List all encounters with their details, including associated player characters and monsters
- add_encounter - Add a new encounter to the system
- add_player_character - Add a new player character
- add_monster_template - Add a new monster template
- add_player_character_to_encounter - Add a player character to an encounter
- remove_player_character_from_encounter - Remove a player character from an encounter
- add_monster_to_encounter - Add a monster to an encounter using a monster template
- remove_monster_from_encounter - Remove a monster from an encounter
Setup
1. Install Dependencies
npm install
2. Configure Environment Variables
Create a .env file in the project root:
cp .env.example .env
Then edit .env and set your Convex URL:
CONVEX_URL=https://your-deployment-name.convex.cloud
Authentication (email + password)
This MCP signs in using Convex Auth (Password provider) if credentials are present in .env:
CONVEX_AUTH_EMAIL=your-email@example.com
CONVEX_AUTH_PASSWORD=your-password
At startup, the server calls auth:signIn and will use either a returned token (Authorization: Bearer) or session cookies when calling the HTTP API. If these vars are omitted, requests will be unauthenticated and may fail depending on your Convex function visibility.
3. Build the Server
npm run build
4. Configure Claude Desktop (automated)
This repo includes a helper script that syncs claude_desktop_config.json into your Claude app config.
-
Set the absolute path to your Claude config in
.env:- macOS (default path):
echo "CLAUDE_DESKTOP_CONFIG_PATH=$HOME/Library/Application Support/Claude/claude_desktop_config.json" >> .env - Windows (PowerShell example):
Add-Content .env "CLAUDE_DESKTOP_CONFIG_PATH=$env:APPDATA\Claude\claude_desktop_config.json"
- macOS (default path):
-
Edit
claude_desktop_config.jsonin this repo to set (absolute paths required):command: your Node binary path (e.g.,/usr/local/bin/node)args: include--env-file, the path to your.env, and the path tobuild/index.js, for example:"args": [ "--env-file", "/absolute/path/to/project/.env", "/absolute/path/to/project/build/index.js" ]cwd: set to the project root absolute path
-
Build and sync:
- One-step (recommended):
npm run build-and-sync - Or separately:
npm run build npm run sync:claude-config
- One-step (recommended):
The script will back up your existing Claude config to claude_desktop_config.json.bak and then apply the changes.
5. Restart Claude Desktop
After configuring, fully quit and restart Claude Desktop (not just close the window):
- macOS: Use Cmd+Q or select "Quit Claude" from the menu bar
- Windows: Right-click the Claude icon in the system tray and select "Quit"
Usage
Once configured, you can use the MCP tools in Claude Desktop. For example:
- "List all encounters"
- "Add a new encounter called 'Goblin Cave'"
- "Add a player character named 'Aragorn'"
- "Add the Goblin template to the Goblin Cave encounter"
Troubleshooting
Server not showing up in Claude Desktop
- Check your
claude_desktop_config.jsonfile syntax - Make sure all paths are absolute (not relative)
- Fully quit and restart Claude Desktop (not just close the window)
Tool calls failing
- Check Claude's logs in:
- macOS:
~/Library/Logs/Claude/mcp*.log - Windows: Check the Claude logs directory
- macOS:
- Verify your
CONVEX_URLis correct - Ensure your Convex deployment is running and accessible
- If functions require authentication, make sure
CONVEX_AUTH_TOKENis set correctly
Convex API errors
If you see Convex API errors, verify:
- Your Convex deployment URL is correct
- The function names match those in your Convex app (
myFunctions:listEncounters, etc.) - Your Convex functions are properly exported and accessible
Development
Architecture
Source is modularized for clarity and future growth:
src/index.ts– entrypoint; starts the serversrc/server.ts– MCP server bootstrap and request handlers wiringsrc/tools/– domain-split tool definitions and handlerssrc/tools/types.ts– shared tool typessrc/tools/encounters.ts– encounter-related tools and handlersrc/tools/characters.ts– character-related tools and handlersrc/tools/monsters.ts– monster-related tools and handlersrc/tools/index.ts– combines tool arrays, exportstoolsList,ToolName,dispatchTool
src/convexClient.ts–callConvexFunctionwrapper for Convex HTTP APIsrc/auth.ts– auth/session management and header buildingsrc/config.ts– environment variable access and validation
Typical workflow
- Make changes in the relevant module (see Architecture above)
- Build:
npm run build - Restart Claude Desktop to load the new build
Adding a new tool
For an existing domain (encounters/characters/monsters):
- Add the tool definition to the relevant file (e.g.,
src/tools/encounters.ts) - Implement the corresponding
casein that file's handler - If it calls Convex, use
callConvexFunctionfromsrc/convexClient.ts - Build and restart Claude Desktop
For a new domain:
- Create a new
src/tools/<domain>.tsexporting a<domain>Toolsarray andhandle<Domain>Tool - Update
src/tools/index.tsto import and spread the new tools array, and route indispatchTool - Build and restart Claude Desktop
Debug logging
Set MCP_DEBUG=1 in your environment to see additional authentication logs.
License
MIT