MCP Spotlight: Pathrule — Path-Scoped Context That Cuts AI Agent Token Waste by 85%
Server: pathrule/mcp by Pathrule
Tools: 30 · License: MIT · Transport: Remote MCP (OAuth) + stdio
MCP Tracker: glama.ai/mcp/servers/pathrule/pathrule
Docs: pathrule.io
Your AI coding agent forgets every session. So it re-reads half the repo to rediscover what your team already knows — that the coupon field lives on lineItem, not total; that the shared package pins React 18 for a reason nobody documented; that the checkout schema has an unused column left over from last year's refactor. Same prompt, two different runs, wildly different results.
Pathrule solves this at the architecture level: path-scoped context that attaches memories, rules, and skills to folders instead of dumping everything into a global CLAUDE.md. The result: 5× fewer tool calls, 10× fewer files read, and 85% fewer input tokens per session — without @-mentions, without tags, without maintaining a prompt template by hand.
The Path-Scoping Difference
Traditional approaches to agent context (CLAUDE.md, AGENTS.md, cursorrules) are flat files with global scope. Every session loads everything. This works for small projects but breaks down at scale — you either trim context and lose specificity, or keep it all and blow out your token budget.
Pathrule inverts this: memories, rules, and skills attach to directory paths, not a global file. When your agent works in /apps/web/checkout, Pathrule walks up the tree and surfaces what's relevant:
/apps
└─ /web
└─ /checkout ← Agent is working here
├─ /payment ← Payment-specific rules apply
Memory: "Checkout Field Map — coupons on lineItem, never total"
Rule: "Never mutate props directly"
Skill: "migration workflow"
The narrowest path wins. If a rule at /apps/web/checkout says one thing and a more general rule at /apps says another, the checkout-specific rule takes precedence.
Three Node Types, One Routing Model
| Node Type | Purpose | Agent Behavior |
|---|---|---|
| Memory | Facts — how fields map, why a schema quirk exists, what happened last incident | Retrieved as reference context; helps the agent understand why code is the way it is |
| Rule | Constraints — "never write to total.coupon," "props are immutable," "use the shared error handler" | Actively constrains agent output; the agent refuses actions that violate active rules |
| Skill | Procedures — migration workflows, review checklists, deployment sequences | Provides step-by-step guidance the agent follows before acting |
All three use the same scoping and routing — they differ only in how the agent interprets them. This means you can express anything from "here's a fact about this module" to "never do X in this directory" within a single system.
Signals, Not Tags
Pathrule surfaces context based on four signals, not manual tagging:
- Path proximity — how close the agent's working directory is to scoped nodes
- Git co-change — files that often change together in your repo's history
- Recency — nodes your team has interacted with recently rise in rank
- Keyword match — natural overlap between the agent's intent and node content
This means the agent gets relevant context without anyone remembering to @-mention a document, maintain a tag taxonomy, or manually curate what should appear per-session.
Self-Auditing Knowledge Graph
Context rots. Paths get renamed. Milestones ship. Dependency pins drift. Pathrule runs eight independent detectors against the workspace and surfaces structured suggestions:
| Detector | Catches |
|---|---|
| Dead paths | Memories referencing file paths that no longer exist |
| Shipped milestones | Entries tied to completed work |
| Drifted pins | Dependency versions that have changed |
| Expired dates | Time-bound entries past their date |
| Zero-hit rules | Rules never triggered in recent sessions |
| Empty nodes | Nodes with no content |
| Title clashes | Conflicting node titles |
| Stale entries | Nodes untouched for 120+ days |
Each suggestion cites the node, the detector, and the specific signal that fired. Your assistant proposes the patch through MCP — you approve or dismiss. The system adapts: suggestion types your team keeps dismissing fade over time.
The Architecture: Local Reads, Cloud Writes
Pathrule's architecture splits reads and writes across two layers:
┌──────────────────────┐ write (JWT) ┌─────────────────┐
│ Your Machine │ ─────────────────► │ Cloud (Postgres)│
│ ┌────────────────┐ │ │ ┌───────────┐ │
│ │ Local Cache │ │ realtime sync │ │ RLS │ │
│ │ (milliseconds) │ │ ◄───────────────── │ │ versioning │ │
│ └────────────────┘ │ │ │ audit log │ │
└──────────────────────┘ └─────────────────┘
- Reads: served from a path-scoped local disk cache. Single-digit milliseconds, zero network, offline-safe. The hook fires before the next tool call on every surface.
- Writes: carry a short-lived, per-user JWT. Postgres with row-level security gates every write per-user and per-node. No service key ever lives on the device.
This split means your agent's context retrieval is instant and never waits on the network, while every write is audited, versioned, and broadcast back through realtime sync.
Facio Integration
Pathrule offers a Remote MCP endpoint for cloud clients — no local install required:
{
"mcpServers": {
"pathrule": {
"type": "http",
"url": "https://mcp.pathrule.io/mcp"
}
}
}
Connection triggers an OAuth flow. After approval, the agent accesses only the workspaces visible to the authenticated account, with scoped read/write permissions. For local-first use, Pathrule Desktop or @pathrule/cli provide stdio transport.
Facio's audit trail captures every context retrieval alongside the agent's decisions. This creates a complete chain: "The agent followed this path because Pathrule surfaced memory checkout-field-map constraining the coupon field to lineItem."
Quickstart
# Web (no install)
# 1. Sign in at app.pathrule.io
# 2. Create a workspace
# 3. Connect your MCP client to https://mcp.pathrule.io/mcp
# CLI (local)
npm install -g @pathrule/cli
cd your-project
pathrule attach # links workspace to current repo
pathrule setup # creates initial structure
# Add a memory
pathrule memory set "coupons on lineItem only" --path apps/web/checkout
# Agent prompt after connection:
# "Edit the checkout flow to support multi-currency."
# → Agent finds the coupon memory scoped to /apps/web/checkout
# → Correctly places coupon on lineItem, avoids the legacy total.coupon
When Pathrule Makes Sense
Pathrule isn't for every project. It earns its keep when:
- Your repo has non-obvious constraints that live in team members' heads, not in code
- Your agent re-reads the same files across sessions to rediscover context your team already knows
- You have path-specific rules that shouldn't apply globally — per-module styling conventions, per-directory API patterns, per-service deployment constraints
- Your context documents are rotting because nobody remembers to update them
For small projects with simple, stable context, a CLAUDE.md file works fine. For everything else, path-scoped context with automatic staleness detection is the architectural upgrade.
Bottom Line
Pathrule brings three things to AI coding agents that flat context files can't: path-scoped routing (the right context for the right files), signal-based retrieval (no tags, no @-mentions, no curation), and self-auditing detectors (context that doesn't rot). 30 MCP tools, a local-first architecture with cloud-backed durability, and measured results of 85% fewer input tokens per session.
For teams shipping production code with AI assistants, this is how you stop your agent from rediscovering your repo on every run.
MCP Spotlight is a series covering servers that give AI agents real capabilities. Every server is evaluated for architectural innovation, engineering rigor, and integration fit with Facio's HITL-first agent runtime.