fastmcp-best-practices

fastmcp-best-practices is a cursor rule for Cursor from techskies11/datadog-mcp. It costs 0 tokens per session (2,710 once invoked), scanned A, original, MIT.

A set of coding rules for building FastMCP servers, which expose tools that an AI assistant can call. It covers tool design, descriptions, annotations, and response conventions.

In plain words
What is it for?
Use it when designing or reviewing FastMCP tools, especially their filters, documentation, read-only labels, and response behavior.
Why use it?
It helps keep the server's tools understandable and practical for an AI assistant. It reduces duplication and discourages designs with too many narrowly focused tools.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use it when designing or reviewing FastMCP tools, especially their filters, documentation, read-only labels, and response behavior.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/techskies11/datadog-mcp/fastmcp-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/techskies11/datadog-mcp

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 fastmcp-best-practices

README.md
[![agentmods](https://agentmods.dev/badge/rules/techskies11/datadog-mcp/fastmcp-best-practices/github.svg)](https://agentmods.dev/rules/techskies11/datadog-mcp/fastmcp-best-practices)
Your own site
<a href="https://agentmods.dev/rules/techskies11/datadog-mcp/fastmcp-best-practices"><img src="https://agentmods.dev/badge/rules/techskies11/datadog-mcp/fastmcp-best-practices/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for fastmcp-best-practices

Your own site · 80×15
<a href="https://agentmods.dev/rules/techskies11/datadog-mcp/fastmcp-best-practices"><img src="https://agentmods.dev/badge/rules/techskies11/datadog-mcp/fastmcp-best-practices.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 2,710 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 original No closer match found 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.02710
Opus 5 $0.00000 $0.01355
Sonnet 5 $0.00000 $0.00542
Haiku 4.5 $0.00000 $0.00271

Measured 8d ago against content hash 5f9c6aca746a, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

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

.cursor/rules/fastmcp-best-practices.mdc · 276 lines

How it starts

The opening of the file, as written. The whole thing — 276 lines — stays where its author put it; the contents beside it link to each section on GitHub.

FastMCP Best Practices

Best practices for this FastMCP-based server. See mcp-architecture.mdc for where code lives and pydantic-models.mdc for response model conventions - this file covers FastMCP-specific decorator/documentation/annotation behavior.

Tool Design Principles

Be Selective with Tools

# ❌ BAD - one narrow tool per lookup key
@mcp.tool()
def get_monitor_by_id(monitor_id: int) -> MonitorResponse: ...
@mcp.tool()
def get_monitor_by_name(name: str) -> MonitorResponse: ...

# ✅ GOOD - one well-designed tool with optional filters
@mcp.tool(annotations=READ_ONLY)
def list_all_monitors(
    group_states: str | None = None,
    name: str | None = None,
    tags: str | None = None,
) -> ListMonitorsResponse:
    """List monitors with optional filters.

    Args:
        group_states: Comma-separated states to filter by (e.g. "alert,warn")
        name: Filter by monitor name substring
        tags: Filter by tag query (e.g. "env:prod")
    """
    ...

Why: LLMs perform better with fewer, well-designed tools than many narrow ones. This server currently exposes 30 tools across 7 domains - treat that as close to the practical ceiling, not a floor; a new tool should consolidate related endpoints (see describe_metric, which merges metric metadata + tags into one call) rather than adding a thin wrapper per Datadog endpoint.

Tool Annotations Are Not Optional

Every @mcp.tool in this codebase passes annotations= from utils/annotations.py. Pick the preset honestly - don't default to READ_ONLY for convenience, and don't mark an overwrite as non-destructive just because nothing is "deleted" in the HTTP sense:

from datadog_mcp.utils.annotations import READ_ONLY, WRITE_ADDITIVE, WRITE_OVERWRITE, STATE_TOGGLE

@mcp.tool(annotations=READ_ONLY)       # search/list/get/count/aggregate/validate
def search_logs(...) -> SearchLogsResponse: ...

@mcp.tool(annotations=WRITE_ADDITIVE)  # creates a new resource, not idempotent
def create_alert_monitor(...) -> CreateMonitorResponse: ...

@mcp.tool(annotations=WRITE_OVERWRITE) # overwrites existing state, no undo tool exists
def update_existing_dashboard(...) -> UpdateDashboardResponse: ...

@mcp.tool(annotations=STATE_TOGGLE)    # reversible, has a matching inverse tool
def silence_monitor(...) -> MuteMonitorResponse: ...

Read the full file on GitHub · 276 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. 8d ago First seen · 276 lines · 0 tokens per session scan A 5f9c6aca746a

Subscribe to this mod's changes

fastmcp-best-practices is a cursor rule published in the GitHub repository techskies11/datadog-mcp (0 stars, last pushed 2mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 2,710 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-31.