PolicyPin
Integrates with GitHub Copilot in VS Code, reading rules from .github/copilot-instructions.md and enforcing them to prevent rule-breaking actions by the coding agent.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@PolicyPin Block any attempt to modify .env files and enforce repo rules."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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 +ron Windows,chmod 444on macOS/Linux). Cursor Composer or native IDE tools can try an internal write and will still getEACCES / 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 -rorchmodmanually.
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 buildInstallation in Editors
Cursor (Option A: GUI - Recommended)
Open Cursor Settings (
Ctrl + Shift + JorCmd + Shift + J).Go to Features -> MCP Servers -> + Add New MCP Server.
Set:
Name:
policypinType:
commandCommand:
node <FULL_PATH_TO_POLICYPIN>/dist/index.js(e.g.,node "C:\Users\username\Documents\policypin\dist\index.js"ornode /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.jsGitHub 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 |
|
Claude Code |
|
GitHub Copilot |
|
Codex / Generic |
|
(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
Add this line to your project's rule file (e.g.
.cursorrulesorCLAUDE.md):Never edit secrets.txtAsk your AI: "Create a dummy password and save it in secrets.txt."
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 ( | ❌ Failed (native file writes succeed) |
Scope probes covered:
package.json,.env/.env.production/.env.local, andconfig/credentials/master.key(including Windows backslash paths).Command probes covered:
git push --forceandrm -rf.Precision probes: Legitimate targets (
README.md,src/index.ts,git status,git pushwithout--force) remained fully allowed with zero false alarms.
Re-run the benchmark:
npm testLicense
Available Tools
2 toolspolicypin_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
Scored across 2 tools
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.
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.
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.
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
MCP enforcement layer that intercepts AI agent actions and blocks rule violations before execution.
Real-time MCP & A2A prompt-injection, jailbreak, and tool-schema poisoning firewall for AI agents.
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
Shared memory MCP server for Claude Code, Codex, Gemini CLI and Cursor. Cited, editable.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceMCP 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
- AlicenseNot gradedqualityDmaintenanceAn MCP server that enforces runtime governance on AI agent actions — file access, command execution, delegation chains, and permission escalation.MIT
- FlicenseNot gradedqualityDmaintenanceA local MCP server that provides controlled repository access with policy-based file filtering, secret redaction, and audit logging for AI coding agents.-
- AlicenseAqualityDmaintenanceA secure local MCP server that provides AI assistants controlled filesystem access and command execution with an interactive approval system for dangerous actions.175 npmMIT