Skip to main content
Glama
PolicyPin

PolicyPin

PolicyPin 📌

Stop your AI coding agent from forgetting its rules after context compaction.

Runs as a local, zero-config MCP server. It pulls rules from your repo, isolates them from lossy context summarization, and blocks violating actions in <1ms before they touch your disk.

(Currently in pre-release testing before public npm registry deployment).


The Problem: Governance Decay

In long sessions, tools like Cursor, Claude Code, and Copilot compact (summarize) conversation history to free up context tokens.

When that happens, the summarizer prioritizes recent conversational chatter and quietly drops negative constraints ("never edit package.json", "don't touch .env"). Researchers call this Governance Decay (arXiv:2606.22528), showing that rule violations jump from ~0% to over 40% post-compaction.

PolicyPin fixes this deterministically: it reads your rules, holds them on an immutable plane, and intercepts actions before execution. No API keys, no external calls, zero token drift.


Silent Lock

MCP is just how it boots. Point your editor to the built script and you're done:

  • File Protection (Kernel Level): On boot, PolicyPin flips forbidden paths to OS read-only (attrib +r on Windows, chmod 444 on macOS/Linux). Cursor Composer or native IDE tools can try an internal write and will still get EACCES / EPERM, even if the model forgets to call MCP.

  • Command Protection (Tool Level): Restricted commands (rm -rf, git push --force) are intercepted and blocked at the MCP gatekeeper boundary before execution.

  • Safe Exit: When the editor disconnects or the process exits, file locks come off cleanly so you can edit normally. Silent Lock is a protective read-only flag, not an ACL jail—a human can always attrib -r or chmod manually.


Quick Setup (From Source)

Because PolicyPin is currently in v0.1 pre-release, build it locally in 30 seconds:

git clone https://github.com/preprint-labs/policypin.git
cd policypin
npm install
npm run build

Installation in Editors

  1. Open Cursor Settings (Ctrl + Shift + J or Cmd + Shift + J).

  2. Go to Features -> MCP Servers -> + Add New MCP Server.

  3. Set:

    • Name: policypin

    • Type: command

    • Command: node <FULL_PATH_TO_POLICYPIN>/dist/index.js (e.g., node "C:\Users\username\Documents\policypin\dist\index.js" or node /Users/username/policypin/dist/index.js)

Cursor (Option B: JSON)

Add to your cursor-settings.json under mcpServers:

{
  "mcpServers": {
    "policypin": {
      "command": "node",
      "args": ["<FULL_PATH_TO_POLICYPIN>/dist/index.js"]
    }
  }
}

Claude Code (Terminal)

claude mcp add policypin -- node <FULL_PATH_TO_POLICYPIN>/dist/index.js

GitHub Copilot (VS Code)

Add to your VS Code settings.json:

{
  "github.copilot.chat.mcpServers": {
    "policypin": {
      "command": "node",
      "args": ["<FULL_PATH_TO_POLICYPIN>/dist/index.js"]
    }
  }
}

(Once v0.1.0 is published to the public registry, installation will be a single npx -y policypin command).


Auto-Detected Rule Files

PolicyPin checks your workspace root for any of the following:

Tool

Rule File

Cursor

.cursorrules or .cursor/rules/*.mdc

Claude Code

CLAUDE.md

GitHub Copilot

.github/copilot-instructions.md

Codex / Generic

AGENTS.md or .rules

(Pass --rules path/to/rules.txt to pin a specific file).


Supported Rule Syntax

PolicyPin parses standard natural language heuristics and globs out of your rule file:

# File and directory locks
Never edit package.json directly; always use npm.
Do not modify any file matching .env*
Forbidden directory: /infra/credentials/**

# Command locks
Forbidden command: rm -rf
Never run git push --force

# Explicit tagging (optional)
<!-- policy:pin -->
Must always preserve MIT license headers in /src
<!-- policy:unpin -->

30-Second Verification

  1. Add this line to your project's rule file (e.g. .cursorrules or CLAUDE.md):

    Never edit secrets.txt
  2. Ask your AI: "Create a dummy password and save it in secrets.txt."

  3. The write will immediately fail:

    🛑 [PolicyPin Blocked]: Target 'secrets.txt' violates rule: 'Never edit secrets.txt'.

Empirical Validation

We ran a ConstraintRot-style probe suite against the Silent Lock matcher/guard plus an OS write verification after attrib +r. That is the direct measurement from this machine.

The baseline figures below are not ours—they are published measurements from the Governance Decay paper (arXiv:2606.22528) showing baseline model compliance decaying across session turns (Fresh: 98.2% → Deep Context: 68.6% → Post-Compaction: 57.7%).

Metric

PolicyPin (Local Eval)

Paper Baselines (arXiv:2606.22528)

Enforcement

8/8 must-block probes (100%)

98.2% (Turn 1) → 57.7% (Post-compaction)

False Alarms

0

—

Avg Latency

0.561 ms

—

OS Kernel Deny

Verified (EPERM / EACCES)

❌ Failed (native file writes succeed)

  • Scope probes covered: package.json, .env / .env.production / .env.local, and config/credentials/master.key (including Windows backslash paths).

  • Command probes covered: git push --force and rm -rf.

  • Precision probes: Legitimate targets (README.md, src/index.ts, git status, git push without --force) remained fully allowed with zero false alarms.

Re-run the benchmark:

npm test

License

MIT

Available Tools

2 tools
policypin_checkA

Pre-flight PolicyPin check. Call before file edits, commands, or sensitive reads. A blocked result is mandatory.

Inputs: target (required), intent.

policypin_listA

List constraints currently pinned by PolicyPin. Read-only.

Inputs: no named parameters.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.8/5.0

    Scored across 2 tools

    Disambiguation5/5

    The two tools have clearly distinct purposes: one performs a pre-flight check, the other lists pinned constraints. There is no overlap or ambiguity between them.

    Naming Consistency4/5

    Both tool names follow a consistent pattern using 'policypin' as a prefix followed by an action verb ('check', 'list'), which is predictable. Minor deviation from 'verb_noun' but internally consistent.

    Tool Count4/5

    With only 2 tools, the server feels thin for a policy management system. However, for its narrow scope (pre-flight checks and listing constraints), the count is reasonable, though it might benefit from more tools to cover additional functionality.

    Completeness2/5

    The tool surface is missing obvious operations for managing constraints, such as adding, removing, or updating pinned rules. Without these, agents cannot modify policy, which is a significant gap for a policy management server.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      MCP server that intercepts and controls AI agent actions in your codebase by enforcing policies on file operations and commands, with logging, approval workflows, and rollback capabilities.
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      An MCP server that enforces runtime governance on AI agent actions — file access, command execution, delegation chains, and permission escalation.
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      A local MCP server that provides controlled repository access with policy-based file filtering, secret redaction, and audit logging for AI coding agents.
      -
    • A
      license
      A
      quality
      D
      maintenance
      A secure local MCP server that provides AI assistants controlled filesystem access and command execution with an interactive approval system for dangerous actions.
      17
      5 npm
      MIT