Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add rules/steipete/agent-rules/mcp-best-practicesgit clone --depth 1 https://github.com/steipete/agent-rulesWhat it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00000 | $0.02231 |
| Opus 5 | $0.00000 | $0.01115 |
| Sonnet 5 | $0.00000 | $0.00446 |
| Haiku 4.5 | $0.00000 | $0.00223 |
Grade A, and why
mcp-best-practices scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
Copies of this mod
1 near-identical copy found in the catalogue:
- mcp-best-practices — 100% identical, 0 lines differ
How it starts
The opening of the file, as written. The whole thing — 123 lines — stays where its author put it; the contents beside it link to each section on GitHub.
MCP Best Practices - May 26, 2025
I. General Tool Configuration & Behavior
- Sensible Defaults: All environment variables must have sensible defaults for easy out-of-the-box usage.
- Dynamic Versioning: The tool's version is emitted in its description. This version must be read dynamically (e.g., from
package.json) and not hardcoded. - Tool & Parameter Descriptions:
- Tool Titles: Use descriptive, human-friendly titles for tools.
- Parameter Descriptions: All parameters must offer a clear description.
- Optional/Required Parameters: Parameters must be explicitly noted as "optional" or "required."
- Default Values: If a parameter is optional, its default value must be explained.
- (These details should be verifiable by hovering over the tool in clients like Cursor or using the MCP inspector.)
- Parameter Parsing: Parameter parsing should be lenient (e.g., accept
pathifproject_pathis formally defined). Generally, advertise stricter schemas but be more lenient in execution to accommodate variations from agents. - Runtime Error Handling: In case of an error, emit a helpful message to the caller with information to potentially recover.
- Configuration Error Handling: Misconfigurations (e.g., wrongly set environment variables) must not crash the tool. Instead, provide a useful explanation when the tool is run, enabling the user to self-correct their setup.
- No stdio Output: CRITICAL: There must be absolutely NO output to stdout or stderr during any tool operation. This includes:
- No
console.log(),console.error(),console.warn(), etc. - No
process.stdout.write()orprocess.stderr.write() - No print statements or debug output to stdio
- Even during errors or initialization, all output must go through the file logger
- Any stdio output will disrupt MCP clients (like Claude) and cause loading errors
- File-based logging (e.g., Pino to log files) is the only acceptable method for operational output
- No
infoCommand:- At least one tool must offer an
infosub command (find the most appropriate tool and add there) - This command shall list:
- The version of the MCP tool.
- The status of any required native dependencies (if applicable), including tests for their presence and functionality.
- Any detected configuration issues or missing environment variables (e.g., problems with the logger path).
- At least one tool must offer an
II. Logging (Pino)
- Default File Logger: Pino is used for logging with a default file logger in the system's log directory (e.g.,
~/Library/Logs/). The log file path is configurable via the[ProjectName]_LOG_FILEenvironment variable. - Log Path Resilience:
- Pino logic must automatically create missing parent directories for the specified log file path.
- If pino cannot write to the
[ProjectName]_LOG_FILEpath, it must fall back to logging to the default temporary directory path.
- Configurable Log Level: The log level is set using the
[ProjectName]_LOG_LEVELenvironment variable (accepts upper, lower, or mixed case values). - Optional Console Logging: An environment variable,
[ProjectName]_CONSOLE_LOGGING=true, enables logging to the console in addition to the pino file logger. - Logger Flush: The logger must be flushed before the process exits to ensure all log messages are written.
III. Code, Dependencies & Build
- Dependency Management: All dependencies should be kept at their latest stable versions. (The release script will warn for outdated dependencies).
- Static Analysis: There must be no linter (e.g., ESLint) or TypeScript errors.
- File Size: No single file should exceed 500 lines of code (LOC); aim for below 300 LOC.
- Execution with Compiled Code: The startup logic and all tool operations must always use the compiled JavaScript output (e.g., from the
distfolder). - Shebangs: Compiled JavaScript files intended for direct execution must have the correct shebang (e.g.,
#!/usr/bin/env node). - NPM Package Contents: The published npm package must contain only the absolute minimum files: the
dist/folder, any potential native components, theREADME.md, and aLICENSEfile.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 3d ago First seen · 123 lines · 0 tokens per session scan A 2e20f0cee257
mcp-best-practices is a cursor rule published in the GitHub repository steipete/agent-rules (5,695 stars, last pushed 4mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 2,231 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other cursor rules, from other repositories
code-optimization
Guidelines for optimizing duplicate and poorly structured code.
type-inference
Derive TypeScript types from Zod schemas - no hand-written interfaces for wire shapes.
paperfit
PaperFit project rule for LaTeX visual typesetting optimization.
ports
Local dev port allocation - role ranges, registry, inspectorport, strictPort, multi-config wrangler.
workers-cache
Workers Cache - Cache-Control, gateway exports cache off, RPC vs fetch.
boundaries
Package dependency boundaries - tag map and enforced invariants.