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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b00010906ff1a3fa96774f1c67afc531c3e4d8f26b8581991c73972bd3b7164
|
|
| MD5 |
d5537c777fb5895449f0956268c4ee37
|
|
| BLAKE2b-256 |
8eba0d60355a593c50253ea7bd5facab4fbd2c3eebc8238a4f3bcf1e6fb38c4d
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ai_rule_learning_mcp-0.1.0.tar.gz -
Subject digest:
8b00010906ff1a3fa96774f1c67afc531c3e4d8f26b8581991c73972bd3b7164 - Sigstore transparency entry: 1866410783
- Sigstore integration time:
-
Permalink:
FAJU85/AI_Rule_Learning@01621f29f9eea35a200c1c218a4cb00218644107 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/FAJU85
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-mcp.yml@01621f29f9eea35a200c1c218a4cb00218644107 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file ai_rule_learning_mcp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ai_rule_learning_mcp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
078aa1702410a18cd4bf28616fa33746329be0798a809079e56793444bc997b5
|
|
| MD5 |
d9ce153b680c85fd197c9915d264f2ae
|
|
| BLAKE2b-256 |
ec512027ee815070f0308e5632fcf59334f287b3a0dd9d71ec7dc7dec0c87724
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ai_rule_learning_mcp-0.1.0-py3-none-any.whl -
Subject digest:
078aa1702410a18cd4bf28616fa33746329be0798a809079e56793444bc997b5 - Sigstore transparency entry: 1866410850
- Sigstore integration time:
-
Permalink:
FAJU85/AI_Rule_Learning@01621f29f9eea35a200c1c218a4cb00218644107 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/FAJU85
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-mcp.yml@01621f29f9eea35a200c1c218a4cb00218644107 -
Trigger Event:
workflow_dispatch
-
Statement type: