mcp-rules

mcp-rules is a cursor rule for Cursor from tienan92it/binance-mcp. It costs 0 tokens per session (4,089 once invoked), scanned A, original, MIT.

A set of coding rules for building an MCP server: a program that lets AI tools call defined functions and access resources. It covers server structure, agent sessions, strategy execution, messages, and data models.

In plain words
What is it for?
Use it when developing or changing an MCP server with FastMCP, including its tools, resources, startup and shutdown handling, strategy logic, session management, and data models.
Why use it?
It gives the code agent consistent guidance about where responsibilities belong and how to follow the MCP communication standard. This reduces hand-written routing and muddled project structure.

Cursor rule for Cursor

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.

agentmods
npx agentmods add rules/tienan92it/binance-mcp/mcp-rules
Clone the repo
git clone --depth 1 https://github.com/tienan92it/binance-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 mcp-rules

README.md
[![agentmods](https://agentmods.dev/badge/rules/tienan92it/binance-mcp/mcp-rules.svg)](https://agentmods.dev/rules/tienan92it/binance-mcp/mcp-rules)
Your own site
<a href="https://agentmods.dev/rules/tienan92it/binance-mcp/mcp-rules"><img src="https://agentmods.dev/badge/rules/tienan92it/binance-mcp/mcp-rules.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 4,089 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00000 $0.04089
Opus 5 $0.00000 $0.02044
Sonnet 5 $0.00000 $0.00818
Haiku 4.5 $0.00000 $0.00409

Measured 5d ago against content hash 0400dcd91acb, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

mcp-rules 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 5d 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/mcp-rules.mdc · 63 lines

How it starts

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

Architecture & Code Structure

  • Use the MCP SDK's server builder (FastMCP) – Initialize a FastMCP server instance (e.g. in a main server.py) with a clear name for your application. Avoid writing custom networking or JSON handling; let the SDK handle connection management and message routing.
  • Separation of concerns – Organize code into modules for distinct purposes. Keep MCP interface code (server setup, tool/resource definitions) separate from business logic (strategy algorithms, data loading, backtest engine). For example, have a module for strategy logic and another for MCP server initialization that calls into that logic.
  • Leverage SDK conventions – Define MCP tools and resources using the provided decorators (e.g. @mcp.tool(), @mcp.resource()) instead of manual routing. This ensures the server advertises capabilities correctly to the client and maintains protocol compliance. Use the SDK’s structure (prompts, tools, resources as needed) to align with MCP’s expected architecture.
  • Lifecycle management – If your server needs setup/teardown (database connections, data pre-loading), use the lifespan context provided by FastMCP (or similar startup hooks) rather than running setup code at import time. This yields a cleaner architecture and integrates with MCP’s lifecycle (init and shutdown events) gracefully.
  • Minimal server entry-point – Keep the code that launches the server lightweight. For example, use an if __name__ == "__main__": block or a small CLI to start the MCP server (possibly using mcp.run() or uvicorn if using HTTP). This makes it easier to start the server in different modes (dev, production) and to test components in isolation.

Agent Registration & Session Management

  • Explicit agent registration – Provide tools or functions for registering a new trading strategy/agent into the system (e.g. a register_strategy(name, config) tool). When an agent is registered, store its definition (parameters, possibly code or identifier) in an internal registry. Confirm registration by returning a unique ID or name to reference that strategy later.
  • Session isolation – Design the server to handle multiple sessions or users without interference. Utilize MCP’s session features to keep each session’s data separate. For example, maintain a session-specific structure (dictionary or context object) that holds the strategies and state for that session. Do not use global state for per-session data; instead, use the Context or session storage provided by the SDK (e.g. ctx.session or similar) to tie data to a session.
  • Track session state – Maintain clear state for each strategy/agent within a session: whether it’s idle, running a backtest, or completed. If a strategy is running, subsequent actions (like checking results) should reference the correct session and strategy. Use unique keys (like session_id + strategy_id) if storing in a global registry to avoid collisions, but prefer built-in session context when available.
  • Cleanup and lifecycle – Handle the removal or resetting of strategies when appropriate. For example, if a session ends or an agent is unregistered, ensure its state is cleaned up from the registry. This prevents stale data from accumulating and ensures each new session starts fresh or with only intended persisted state.
  • Concurrent execution considerations – If multiple agents or multiple sessions might run backtests concurrently, ensure that shared resources are managed safely. Use locks or asyncio synchronization for shared data, or better, avoid sharing mutable global data altogether by scoping it per session/agent. This will prevent race conditions when traders run strategies in parallel.

Read the full file on GitHub · 63 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. 5d ago First seen · 63 lines · 4,089 tokens per session scan A 0400dcd91acb

Subscribe to this mod's changes

mcp-rules is a cursor rule published in the GitHub repository tienan92it/binance-mcp (20 stars, last pushed 1y ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 4,089 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.