Variance Log MCP server

Analyzes statistical variations in conversation structures and logs unusual events to a SQLite database for monitoring AI behavior and detecting anomalies.
Back to servers
Setup instructions
Provider
Kirk Truax
Release date
Jan 25, 2025
Language
Python
Stats
4 stars

The MCP Variance Log is an agentic tool that monitors conversations for statistical variations and logs unusual events to a SQLite database. Built using the Model Context Protocol (MCP), it works with Claude Desktop and other MCP-compatible clients to identify and record interactions that fall outside normal patterns.

Installation

Prerequisites

  • Python 3.10 or newer
  • UV (Python package installer and environment manager)
  • SQLite3
  • MCP 1.2.0 or newer

Basic Installation

# Clone and install
git clone https://github.com/truaxki/mcp-variance-log.git
cd mcp-variance-log
uv pip install -e .

Installing UV

If you don't have UV installed:

# Using pip (recommended for Windows)
pip install uv

# Using installation script (Linux/MacOS)
curl -LsSf https://astral.sh/uv/install.sh | sh

Configuring Claude Desktop

Add the server to your Claude Desktop configuration file:

{
  "mcpServers": {
    "mcp-variance-log": {
      "command": "uv",
      "args": [
        "--directory",
        "PATH_TO_REPO/mcp-variance-log",  # Update this path
        "run",
        "mcp-variance-log"
      ]
    }
  }
}

The config file location depends on your operating system:

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

Setting Claude Desktop Preferences

Add the following to Claude Desktop preferences:

Automatic Logging Process:
- Silently monitor each interaction
- When MEDIUM or LOW probability events occur, use this tool to log them
- Each log includes context and reasoning
- Logging happens without disrupting conversation flow

Usage

Automatic Logging

The tool silently monitors conversations and logs unusual events. Here are examples of how it works:

When a user makes an improbable claim:

prompt: "What if I told you I could lift 1000 lbs?"

{
  `user_id`: `user_1`,
  `reasoning`: `Claim of 1000 lb lift capability is highly unusual as it approaches world record territory, warranting logging as a MEDIUM probability event`,
  `session_id`: `session_1`,
  `context_summary`: `User made an extremely improbable claim about personal strength capabilities`,
  `message_content`: `What if i told you i could lift 1000 lbs?`,
  `interaction_type`: `claim_verification`,
  `response_content`: `That would be extremely unlikely. The current world record for weight lifted by a human (deadlift) is 1,104.5 lbs, set by Hafthor Björnsson in 2020 under very specific conditions. Only a handful of people in history have lifted close to 1,000 lbs.`,
  `probability_class`: `MEDIUM`
}

When the user follows up with another unusual claim:

prompt: "What if I told you I'm a Data Scientist that can lift 1000 pounds?"

{
  `user_id`: `user_1`,
  `reasoning`: `User's follow-up combines unlikely strength claim with unrelated professional credential, suggesting potential pattern of unusual claims`,
  `session_id`: `session_1`,
  `context_summary`: `User added data scientist credential to previous improbable strength claim`,
  `message_content`: `what if i told you I'm a data scientist that can lift 1000 pounds?`,
  `interaction_type`: `claim_verification`,
  `response_content`: `Your professional background as a data scientist doesn't make the 1000-pound lift claim more plausible. Such a lift would still be near the all-time world record of 1,104.5 lbs.`,
  `probability_class`: `LOW`
}

Viewing Logs

You can view logs in a dataframe format:

prompt: "Read-logs from this morning"

ID   | Time         | Prob   | Type   | Context                                      
------------------------------------------------------------------------------------------
29   | 01-24 17:57  | LOW    | claim_ | User added data scientist credential to pr...
28   | 01-24 17:56  | MEDIUM | claim_ | User made an extremely improbable claim ab...

Querying Logs

You can search specific log entries:

prompt: "Can you search the logs for entry 29?"

[{'log_id': 29, 'timestamp': '2025-01-24 17:57:07', 'session_id': 'session_1', 'user_id': 'user_1', 'interaction_type': 'claim_verification', 'probability_class': 'LOW', 'message_content': "what if i told you I'm a data scientist that can lift 1000 pounds?", 'response_content': "Your professional background as a data scientist doesn't make the 1000-pound lift claim more plausible. Such a lift would still be near the all-time world record of 1,104.5 lbs.", 'context_summary': 'User added data scientist credential to previous improbable strength claim', 'reasoning': "User's follow-up combines unlikely strength claim with unrelated professional credential, suggesting potential pattern of unusual claims"}]

Available Tools

Monitoring Tools

  • log-query: Tracks conversation patterns with probability classifications:
    • HIGH: Common interactions (not logged)
    • MEDIUM: Unusual patterns (logged)
    • LOW: Critical events (priority logged)

Database Tools

  • read-logs: View logs with filtering options
  • read_query: Execute SELECT queries
  • write_query: Execute INSERT/UPDATE/DELETE
  • create_table: Create tables
  • list_tables: Show all tables
  • describe_table: Show table structure

The database is located at data/varlog.db relative to the installation directory.

Database Schema

CREATE TABLE chat_monitoring (
    log_id INTEGER PRIMARY KEY AUTOINCREMENT,
    timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
    session_id TEXT NOT NULL,
    user_id TEXT NOT NULL,
    interaction_type TEXT NOT NULL,
    probability_class TEXT CHECK(probability_class IN ('HIGH', 'MEDIUM', 'LOW')),
    message_content TEXT NOT NULL,
    response_content TEXT NOT NULL,
    context_summary TEXT,
    reasoning TEXT
);

Troubleshooting

Database Access Issues

If you see "Failed to connect to database":

  • Check file permissions
  • Verify the path in your configuration
  • Ensure the /data directory exists

Installation Problems

If you encounter "No module named 'mcp'":

  • Run: uv pip install mcp>=1.2.0

If you see "UV command not found":

  • Install UV: curl -LsSf https://astral.sh/uv/install.sh | sh

Configuration Errors

If you get "Failed to start MCP server":

  • Verify your config.json syntax
  • Check path separators (use \ on Windows)
  • Ensure UV is in your system PATH

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 "mcp-variance-log" '{"command":"uv","args":["--directory","PATH_TO_REPO/mcp-variance-log","run","mcp-variance-log"]}'

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": {
        "mcp-variance-log": {
            "command": "uv",
            "args": [
                "--directory",
                "PATH_TO_REPO/mcp-variance-log",
                "run",
                "mcp-variance-log"
            ]
        }
    }
}

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": {
        "mcp-variance-log": {
            "command": "uv",
            "args": [
                "--directory",
                "PATH_TO_REPO/mcp-variance-log",
                "run",
                "mcp-variance-log"
            ]
        }
    }
}

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