mcp-best-practices

mcp-best-practices is a cursor rule for Cursor from roy2392/vibe-agents-rules. It costs 0 tokens per session (2,231 once invoked), scanned A, a copy of mcp-best-practices, MIT.

A set of rules for building Model Context Protocol tools, which let coding agents call external tools and services.

In plain words
What is it for?
Checking tool configuration, version reporting, parameter handling, optional and required inputs, and runtime error responses.
Why use it?
It helps tools behave consistently by requiring clear settings, parameter descriptions, sensible defaults, and useful error messages.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc).

Good fit Checking tool configuration, version reporting, parameter handling, optional and required inputs, and runtime error responses.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/roy2392/vibe-agents-rules/mcp-best-practices
Install

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.

Clone the repo
git clone --depth 1 https://github.com/roy2392/vibe-agents-rules

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for mcp-best-practices

README.md
[![agentmods](https://agentmods.dev/badge/rules/roy2392/vibe-agents-rules/mcp-best-practices.svg)](https://agentmods.dev/rules/roy2392/vibe-agents-rules/mcp-best-practices)
Your own site
<a href="https://agentmods.dev/rules/roy2392/vibe-agents-rules/mcp-best-practices"><img src="https://agentmods.dev/badge/rules/roy2392/vibe-agents-rules/mcp-best-practices.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 2,231 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin 100% copy Near-identical to another mod in the catalogue.
Token cost

What 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.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.02231
Opus 5 $0.00000 $0.01115
Sonnet 5 $0.00000 $0.00446
Haiku 4.5 $0.00000 $0.00223

Measured 7d ago against content hash 2e20f0cee257, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

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 7d 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.

Origin

This is a copy

100% identical to mcp-best-practices — 0 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

docs/mcp-best-practices.mdc · 123 lines

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

  1. Sensible Defaults: All environment variables must have sensible defaults for easy out-of-the-box usage.
  2. 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.
  3. 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.)
  4. Parameter Parsing: Parameter parsing should be lenient (e.g., accept path if project_path is formally defined). Generally, advertise stricter schemas but be more lenient in execution to accommodate variations from agents.
  5. Runtime Error Handling: In case of an error, emit a helpful message to the caller with information to potentially recover.
  6. 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.
  7. 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() or process.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
  8. info Command:
    • At least one tool must offer an info sub 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).

II. Logging (Pino)

  1. 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_FILE environment variable.
  2. 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_FILE path, it must fall back to logging to the default temporary directory path.
  3. Configurable Log Level: The log level is set using the [ProjectName]_LOG_LEVEL environment variable (accepts upper, lower, or mixed case values).
  4. Optional Console Logging: An environment variable, [ProjectName]_CONSOLE_LOGGING=true, enables logging to the console in addition to the pino file logger.
  5. Logger Flush: The logger must be flushed before the process exits to ensure all log messages are written.

III. Code, Dependencies & Build

  1. Dependency Management: All dependencies should be kept at their latest stable versions. (The release script will warn for outdated dependencies).
  2. Static Analysis: There must be no linter (e.g., ESLint) or TypeScript errors.
  3. File Size: No single file should exceed 500 lines of code (LOC); aim for below 300 LOC.
  4. Execution with Compiled Code: The startup logic and all tool operations must always use the compiled JavaScript output (e.g., from the dist folder).
  5. Shebangs: Compiled JavaScript files intended for direct execution must have the correct shebang (e.g., #!/usr/bin/env node).
  6. NPM Package Contents: The published npm package must contain only the absolute minimum files: the dist/ folder, any potential native components, the README.md, and a LICENSE file.

Read the full file on GitHub · 123 lines

Changes

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.

  1. 7d ago First seen · 123 lines · 0 tokens per session scan A 2e20f0cee257

Subscribe to this mod's changes

mcp-best-practices is a cursor rule published in the GitHub repository roy2392/vibe-agents-rules (11 stars, last pushed 1y 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. It is 100% identical to mcp-best-practices, differing in 0 lines, and is treated as a copy.