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/asheng008/unifiles-mcp/code_stylegit clone --depth 1 https://github.com/Asheng008/unifiles-mcpWhat 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.01530 |
| Opus 5 | $0.00000 | $0.00765 |
| Sonnet 5 | $0.00000 | $0.00306 |
| Haiku 4.5 | $0.00000 | $0.00153 |
Grade A, and why
code_style 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 2d 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.
How it starts
The opening of the file, as written. The whole thing — 141 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Python MCP SDK (FastMCP) Code Style
Context: 适用于使用
mcp官方 SDK 的FastMCP高级接口开发服务器。 Focus: 使用装饰器、类型提示自动生成 Schema、简化生命周期管理。 Reference: https://pypi.org/project/mcp/
1. 核心原则 (Core Principles)
- FastMCP 优先: 始终使用
mcp.server.fastmcp.FastMCP类,避免直接操作底层的Server类。 - 类型驱动: 利用 Python 类型提示 (
str,int,bool,list, 等) 自动生成 MCP Schema;优先使用简单类型平铺传参,避免用单个字典/对象包住所有参数。 - 文档即描述: 函数的 Docstring 会自动转换为工具/资源的描述字段。
- 上下文感知: 使用
Context对象处理日志、进度报告和二进制数据。
2. 基础架构 (Basic Structure)
标准的 FastMCP 服务器结构如下:
from mcp.server.fastmcp import FastMCP, Context, Image
# 1. 初始化服务器
mcp = FastMCP("My Server")
# 2. 定义工具 (Tools)
@mcp.tool()
async def calculate_metrics(data: list[float], threshold: float = 0.5) -> dict[str, float]:
"""
计算数据指标。
Args:
data: 输入的数据列表
threshold: 过滤阈值
"""
filtered = [x for x in data if x > threshold]
return {
"count": len(filtered),
"average": sum(filtered) / len(filtered) if filtered else 0
}
# 3. 定义资源 (Resources)
@mcp.resource("file://{path}")
def read_custom_file(path: str) -> str:
"""读取自定义格式文件"""
return f"Mock content for {path}"
# 4. 运行入口
if __name__ == "__main__":
mcp.run()
3. 关键模式 (Key Patterns)
3.1 工具传参:简单类型平铺 (Simple Flat Parameters)
优先使用简单类型平铺传参,不要用单个 Pydantic 模型或字典包住所有参数。这样 MCP 客户端只需传 key: value,无需构造 params: { ... } 对象。校验在函数内部完成。
- 必填/常用参数:
str、int、bool、list、tuple等,用Annotated[T, Field(description="...")]写描述。 - 可选参数:带默认值即可,如
limit: int = 10。 - 仅在确有复杂嵌套、且多工具复用时,再考虑 Pydantic 模型。
from typing import Annotated
from pydantic import Field
@mcp.tool()
async def search_database(
query: Annotated[str, Field(description="搜索关键词")],
limit: Annotated[int, Field(description="最多返回条数")] = 10,
tags: list[str] | None = None,
ctx: Context,
) -> list[str]:
"""在数据库中搜索内容。"""
if tags is None:
tags = []
# 校验在内部完成,如 limit 范围等
return [f"Result for {query}"]
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.
- 2d ago First seen · 141 lines · 1,530 tokens per session scan A 3bc4daa3370b
code_style is a cursor rule published in the GitHub repository Asheng008/unifiles-mcp (0 stars, last pushed 5mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,530 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.
Other cursor rules, from other repositories
python_tests
We use the unit tests to cover internal behavior that can work without the web / backend counterpart. We aim for 95%+ unit test coverage of our Python code in lib/streamlit.
fastapi-production-architecture-cursorrules-prompt-file
Cursor rules for FastAPI services with router/service/repository boundaries, typed provider adapters, bulkhead isolation, idempotency, and domain exceptions.
django
Definitive guidelines for writing maintainable, performant, and secure Django applications, emphasizing modern best practices, clear code organization, and efficient patterns.
sqlmodel
Satisfying the type checker when working with SQLModel.
python
Python开发规则 - Python最佳实践和项目结构 (python, pip, django, flask, fastapi).
backend-python
Cursor rule "backend-python" from coeusyk/inference-x, covering backend python rules, stack assumptions, code style, fastapi conventions and schema conventions.