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.
git clone --depth 1 https://github.com/Asheng008/unifiles-mcpWrote 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.
[](https://agentmods.dev/rules/asheng008/unifiles-mcp/code_style)<a href="https://agentmods.dev/rules/asheng008/unifiles-mcp/code_style"><img src="https://agentmods.dev/badge/rules/asheng008/unifiles-mcp/code_style/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.
<a href="https://agentmods.dev/rules/asheng008/unifiles-mcp/code_style"><img src="https://agentmods.dev/badge/rules/asheng008/unifiles-mcp/code_style.svg" alt="Reviewed on agentmods" width="80" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00000 | $0.01530 |
| Opus 5.5 | $0.00000 | $0.00612 |
| Sonnet 5.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 3mo 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.
- 3mo 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 8mo 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.
code_style compared with cursor rules from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| code_styleAsheng008/unifiles-mcp | Cursor rule | 0 | 8mo ago | MIT | A | 0 | Cursor |
| python_testsstreamlit/streamlit | Cursor rule | 47k | today | Apache-2.0 | A | 0 | Cursor |
| djangosanjeed5/awesome-cursor-rules-mdc | Cursor rule | 3.6k | 9d ago | CC0-1.0 | A | 2,043 | Cursor |
| richsanjeed5/awesome-cursor-rules-mdc | Cursor rule | 3.6k | 9d ago | CC0-1.0 | A | 1,749 | Cursor |
| python-llm-ml-workflow-cursorrules-prompt-filePatrickJS/awesome-cursorrules | Cursor rule | 41k | 6mo ago | CC0-1.0 | A | 1,530 | Cursor |
| pythonPatrickJS/awesome-cursorrules | Cursor rule | 41k | 6mo ago | CC0-1.0 | A | 734 | Cursor |
| python-containerization-cursorrules-prompt-filePatrickJS/awesome-cursorrules | Cursor rule | 41k | 6mo ago | CC0-1.0 | A | 56 | Cursor |