Tianji MCP server

Bridges AI assistants with the Tianji platform to enable survey management, including querying results, retrieving detailed information, and listing workspace surveys without navigating the Tianji interface.
Back to servers
Setup instructions
Provider
MsgByte
Release date
May 17, 2025
Language
Go
Stats
2.4K stars

Tianji is an All-in-One Insight Hub that combines website analytics, uptime monitoring, and server status tracking in a single lightweight application. It's designed for users who need comprehensive monitoring without the complexity of multiple specialized tools.

Installation

Docker (Recommended)

The easiest way to install Tianji is with Docker:

docker run -d \
  --name tianji \
  -p 3001:3001 \
  -v $(pwd)/data:/app/data \
  moonrailgun/tianji:latest

After installation, access Tianji at http://localhost:3001.

Docker Compose

For a more configurable setup, use Docker Compose:

version: '3'
services:
  tianji:
    image: moonrailgun/tianji:latest
    container_name: tianji
    ports:
      - "3001:3001"
    volumes:
      - ./data:/app/data
    restart: always

Save this as docker-compose.yml and run:

docker-compose up -d

Environment Variables

You can customize Tianji with these environment variables:

version: '3'
services:
  tianji:
    image: moonrailgun/tianji:latest
    container_name: tianji
    ports:
      - "3001:3001"
    volumes:
      - ./data:/app/data
    environment:
      - DATABASE_URL=file:../data/tianji.db
      - HOST=0.0.0.0
      - PORT=3001
      - SALT=any-random-string
      - TRACKER_SCRIPT_NAME=tianji.js
      - ALLOW_TELEMETRY=true
    restart: always

Usage

Website Analytics

  1. After login, create a new website in the dashboard
  2. Add the tracking script to your website:
<script async defer src="https://your-tianji-instance.com/tianji.js" data-website-id="your-website-id"></script>

Replace your-tianji-instance.com with your Tianji server URL and your-website-id with the ID provided after website creation.

Uptime Monitoring

  1. Navigate to the Monitor section
  2. Click "Add Monitor"
  3. Configure the following settings:
    • Monitor name
    • URL to monitor
    • Check interval
    • Alert settings

The system will immediately start checking your URL and collecting uptime data.

Monitor Reporter

For server monitoring, install the reporter on your servers:

curl -s https://your-tianji-instance.com/api/reporter/install | bash

This will install and configure the reporter to send data to your Tianji instance.

Custom Reporting

You can also manually send data to Tianji's API:

curl -X POST https://your-tianji-instance.com/api/report \
  -H "Content-Type: application/json" \
  -d '{"website":"your-website-id","data":{"metric":"value"}}'

Setting Up Alerts

  1. Go to the Settings page
  2. Configure notification channels (Email, Webhook, etc.)
  3. In the Monitor or Server sections, enable alerts for specific resources

Troubleshooting

Common Issues

  • Can't access dashboard: Check if your server is running and the port is accessible
  • No data showing: Verify that the tracking script is correctly installed
  • Reporter not working: Check network connectivity between reporter and server

Logs

To view logs when using Docker:

docker logs tianji

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "tianji" '{"command":"npx","args":["-y","tianji"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "tianji": {
            "command": "npx",
            "args": [
                "-y",
                "tianji"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "tianji": {
            "command": "npx",
            "args": [
                "-y",
                "tianji"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later