Provides automatic git context by fetching current branch name, recent commit history, and diffstat from git repositories, eliminating repetitive context gathering during AI interactions.
MCP House Rules Server
Stop re-explaining yourself to AI assistants. This MCP (Model Context Protocol) server exposes reusable "house rules" as prompts and provides automatic git context, so you can focus on what you actually want to do instead of repeating the same setup instructions.
What Problem Does This Solve?
If you use AI assistants daily, you've probably experienced this loop:
You open Cursor or VS Code and ask it to review a PR
It asks where the repo is, what branch, what you want checked
You paste the same context you pasted yesterday
You switch to another client and do it again
This project solves two problems:
Prompt reuse: Your "house rules" for how you want the assistant to behave are published once and discoverable by any MCP client
Context reuse: Basic git information (branch, recent commits, diffstat) is fetched automatically so the assistant stops asking basic questions
What This Project Provides
1. House Rules Prompt
A reusable prompt template named house_rules that defines your preferred assistant behavior:
Prefer safe and reversible actions (start read-only)
Summarize before acting
Keep scope small
Be explicit with checklists
Ask one clarifying question only when truly blocked
The prompt accepts an optional mode parameter (e.g., "review", "triage", "release-notes") to adapt the behavior for different workflows.
2. Git Context Tool
A tool named git_context that automatically fetches:
Current branch name
Recent commit history (configurable, default 15 commits)
Latest commit diffstat
This eliminates the back-and-forth of "which repo?", "which branch?", "what changed?"
Project Structure
Components Explained
MCP Server (src/index.ts)
The server implements three main handlers:
ListPromptsHandler: Exposes the
house_rulesprompt so clients can discover itGetPromptHandler: Returns the actual prompt content with optional mode customization
ListToolsHandler: Exposes the
git_contexttoolCallToolHandler: Executes
git_contextby running git commands and returning formatted results
Key Features
Stdio Transport: Uses standard input/output for communication (required for MCP)
Error Handling: Validates git repository before attempting operations
Logging: All logs go to stderr (stdout is reserved for protocol messages)
Type Safety: Uses Zod for runtime validation of tool arguments
Installation
Clone or download this repository
Install dependencies:
Build the TypeScript code:
Test the server:
You should see a log message on stderr indicating the server is running.
Testing with MCP Inspector
Before wiring this into your AI client, test it with the MCP Inspector:
This will help you verify:
✅ Prompts list includes
house_rules✅ Tools list includes
git_context✅ Calling
house_rulesreturns your operating rules✅ Calling
git_contextreturns a compact repo context bundle
Integration with MCP Clients
Different MCP clients have different configuration formats, but the setup is similar:
Register the server as a local process
Set the command to:
node+ absolute path todist/index.jsThe client will discover prompts and tools automatically
Example Configuration (Cursor)
In your Cursor MCP settings, add:
Daily Usage Example
Once integrated, your workflow becomes:
Apply the house_rules prompt (with optional mode):
Apply house_rules in review modeCall git_context for your repository:
Call git_context on /absolute/path/to/repo with 15 commitsAsk for what you actually want:
Summarize what changed recently, flag risky areas, and give me a short checklist for what to verify before merging.
What changed compared to normal prompting:
✅ You're not retyping rules every time
✅ You're not answering "what branch is this"
✅ The assistant starts from a compact, consistent context bundle
Common Pitfalls
1. Logging to stdout breaks everything
Don't use stdout is reserved for protocol messages. Always log to stderr using the provided log() function.
2. Use absolute paths
If you pass a relative path for repoPath, different clients may run your server with different working directories. Always use absolute paths to avoid weird failures.
3. Resist the urge to overbuild
It's tempting to add features like:
"Summarize PR"
"Open files"
"Edit code"
"Commit changes"
Resist it. This server is valuable because it stays focused:
Publish reusable behavior (prompt)
Publish reusable context (tool)
Everything else can remain in the AI client.
Customization
Modifying House Rules
Edit the prompt text in src/index.ts within the GetPromptRequestSchema handler. The rules are defined in the text array.
Adding New Modes
The mode parameter is already supported. You can extend the prompt logic to provide different instructions based on the mode:
Extending Git Context
You can add more git information to the git_context tool by adding additional execFileAsync calls:
Development
Build
Run
TypeScript Configuration
The project uses strict TypeScript settings. See tsconfig.json for details.
License
MIT
Credits
This project is based on the article: "Stop Re-Explaining Yourself to AI with MCP" - a beginner-friendly guide to building reusable MCP servers.
Contributing
This is a minimal, focused server. If you want to extend it, consider:
Keeping it simple and focused
Adding only reusable prompts and context tools
Avoiding complex agent logic (that belongs in the client)
Remember: Tools are reusable actions. Prompts are reusable behavior. Together, they turn "I keep re-explaining myself" into "my client can discover how I work."