Skip to main content

MCP server that learns guardrail rules from your AI conversations and injects them automatically

Project description

AI Rule Learning — MCP Server

A personal MCP server that learns guardrail rules from your AI conversation history and injects them into future sessions — automatically, with any AI provider.

How it works

Your sessions (any AI tool)
  → MCP reads + scrubs PII locally
  → uploads to YOUR private HF dataset
  → analysis generates personalised rules
  → rules injected into your next session automatically

Supported AI providers

Provider Session format
Claude Code ~/.claude/projects/**/*.jsonl (auto-detected)
ChatGPT / OpenAI conversations.json export
Cursor / Windsurf Generic JSONL with {role, content} messages
Any tool Generic JSONL — {role, content} or {user, assistant}

Personal tier (this package — free)

  • Analyses your sessions → generates your personalised rules
  • Data stays in your own private HF dataset — you are the data controller
  • Opt in to contribute anonymised gap patterns to the community pool

Organisations and governments: a separate business version is available by pre-order. Contact info@tococolors.com to request access.

Installation

# From source
git clone https://github.com/faju85/ai_rule_learning.git
cd ai_rule_learning/mcp
pip install -e .

# Once published to PyPI
pip install ai-rule-learning-mcp

Configuration

Add to your Claude Desktop / Claude Code MCP config:

{
  "mcpServers": {
    "ai-rule-learning": {
      "command": "ai-rule-learning-mcp",
      "env": {
        "HF_TOKEN": "hf_your_write_token",
        "ARL_DATASET": "yourname/AI_Rule_Learning",
        "ARL_SESSIONS": "/path/to/sessions,/another/path",
        "ARL_CONTRIBUTE": "false"
      }
    }
  }
}

Environment variables

Variable Default Description
HF_TOKEN HF write token (required)
ARL_DATASET Your HF dataset repo ID
ARL_SESSIONS ~/.claude/projects Comma-separated session paths
ARL_CONTRIBUTE false Opt in to community contribution

Tools exposed to Claude

get_guardrail_rules

Returns your active rules as a formatted system prompt block.

"Load my guardrail rules before we start."

sync_sessions

Scans your session history, scrubs PII, uploads new conversations, pulls back the latest rules.

"Sync my sessions." "Sync my ChatGPT sessions from ~/Downloads/chat-export"

list_providers

Shows which session paths are configured and how many files were found.

Full automatic loop

Session ends (any AI tool)
  → Stop hook: export_sessions.py --sync-rules
  → conversations uploaded, latest rules saved to ~/.claude/ai_rule_learning_rules.md

Next session starts
  → SessionStart hook reads that file
  → rules injected as context automatically

Privacy

All PII scrubbing runs locally before any data leaves your machine. Community contributions send only anonymised gap type/count data — never raw text. See PRIVACY.md.

Licence

Free for personal use. Commercial and government use requires written permission. See LICENSE and TERMS.md.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ai_rule_learning_mcp-0.1.0.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ai_rule_learning_mcp-0.1.0-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file ai_rule_learning_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: ai_rule_learning_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ai_rule_learning_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8b00010906ff1a3fa96774f1c67afc531c3e4d8f26b8581991c73972bd3b7164
MD5 d5537c777fb5895449f0956268c4ee37
BLAKE2b-256 8eba0d60355a593c50253ea7bd5facab4fbd2c3eebc8238a4f3bcf1e6fb38c4d

See more details on using hashes here.

Provenance

The following attestation bundles were made for ai_rule_learning_mcp-0.1.0.tar.gz:

Publisher: publish-mcp.yml on FAJU85/AI_Rule_Learning

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ai_rule_learning_mcp-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ai_rule_learning_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 078aa1702410a18cd4bf28616fa33746329be0798a809079e56793444bc997b5
MD5 d9ce153b680c85fd197c9915d264f2ae
BLAKE2b-256 ec512027ee815070f0308e5632fcf59334f287b3a0dd9d71ec7dc7dec0c87724

See more details on using hashes here.

Provenance

The following attestation bundles were made for ai_rule_learning_mcp-0.1.0-py3-none-any.whl:

Publisher: publish-mcp.yml on FAJU85/AI_Rule_Learning

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page