mcp-service-template: Instructions file for Codex

AGENTS.md

mcp-service-template AGENTS.md is an instructions file for Codex, OpenCode from RamidLab/mcp-service-template. It costs 4,503 tokens per session, scanned A, original, MIT.

Project instructions for a reusable Python MCP service template. The template uses FastMCP, SQLAlchemy, Pydantic, and Typer, and includes example database entities with create, read, update, delete, filtering, searching, and CSV export.

In plain words
What is it for?
They are for developing the service template, running it over supported connection methods, testing it, checking types, managing example database data, and applying migrations.
Why use it?
They explain how to set up, run, test, check, format, and rename the template, so changes follow the project’s expected workflow.

Instructions file for CodexOpenCode

Written for Codex and OpenCode: the file is AGENTS.md. Also seen: mentions AGENTS.md.

This is RamidLab/mcp-service-template's own configuration. It tells Codex and OpenCode how to work on mcp-service-template itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything mcp-service-template configures →

Reuse

Borrowing it

Nothing to install: this file belongs to RamidLab/mcp-service-template. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/RamidLab/mcp-service-template/main/AGENTS.md
Clone the repo
git clone --depth 1 https://github.com/RamidLab/mcp-service-template

Made for: Codex, OpenCode.

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-service-template AGENTS.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/ramidlab/mcp-service-template/agents-md/github.svg)](https://agentmods.dev/instructions/ramidlab/mcp-service-template/agents-md)
Your own site
<a href="https://agentmods.dev/instructions/ramidlab/mcp-service-template/agents-md"><img src="https://agentmods.dev/badge/instructions/ramidlab/mcp-service-template/agents-md/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 mcp-service-template AGENTS.md

Your own site · 80×15
<a href="https://agentmods.dev/instructions/ramidlab/mcp-service-template/agents-md"><img src="https://agentmods.dev/badge/instructions/ramidlab/mcp-service-template/agents-md.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 4,503 This file is loaded in full into every session.
When invoked 4,503 The same file — it is already loaded in full.
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.04503 $0.04503
Opus 5.5 $0.01801 $0.01801
Sonnet 5.5 $0.00901 $0.00901
Haiku 4.5 $0.00450 $0.00450

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

Security

Grade A, and why

mcp-service-template AGENTS.md 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.

AGENTS.md · 243 lines

How it starts

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

AGENTS.md — Service MCP 模板

项目概览

通用 MCP 服务模板(FastMCP + SQLAlchemy async + Pydantic v2 + Typer CLI),含示例实体 Product / ProductPrice,演示完整 CRUD + 外键解析 + 动态 Filter/Search 链路。 示例域字段与同族 backend/apps/demo_module、frontend demo 商品契约对齐。

  • Python: 3.12+ 必须
  • 包管理器: uv(pip 可用但 uv 为主)
  • 入口: service_mcp/server.py — CLI 命令 service-mcp
  • 工具数量: 约 33 个(2 个示例实体 + CSV 导出示例)

快速命令

# 环境
uv venv && uv sync --dev

# 运行服务(任选一种传输)
uv run service-mcp stdio
uv run service-mcp streamable-http --host 0.0.0.0 --port 8001
uv run service-mcp sse --host 0.0.0.0 --port 8001
uv run service-mcp ui --dev-port 8080 --mcp-port 8001

# 测试(内存 SQLite,无需外部 DB;mysql/postgresql 参数化用例需对应服务运行)
pytest                          # 全部测试
pytest tests/test_config.py     # 单文件
pytest -k "test_name"           # 单测试

# Lint + 格式 + 类型
ruff check .
ruff check --fix .
ruff format .
mypy service_mcp

# 修改 filter/search 声明后重新生成 .pyi stub(跑两次,第二次应无 diff)
uv run python scripts/refresh_project_stub.py

# 生成演示数据
uv run python mock/mock_product_data.py

# 数据库迁移(幂等,可重复执行)
uv run python scripts/migrate_example.py
uv run python scripts/migrate_example.py --url sqlite+aiosqlite:///path/to/service_data.db

# 项目改名(模板 → 新项目;默认 dry-run 预览,加 --write 才落盘)
uv run python scripts/rename_project.py my_company --project my-company-mcp --display "My Company MCP"
uv run python scripts/rename_project.py my_company --project my-company-mcp --write

架构

service_mcp/
├── server.py          # FastMCP app + Typer CLI(stdio/sse/streamable-http/ui)
├── config.py          # MCPSettings 分层配置(env → TOML → code),前缀 MCP_,分隔符 __
├── apps/              # FastMCP Apps UI(config_app:数据库/缓存配置管理面板)
├── auth/              # JWT 认证 + 权限
│   ├── config.py      # AuthConfig(mode: tool/admin,从环境变量加载)
│   ├── context.py     # 请求上下文(current_owner / scope_visibility_where 三级可见性)
│   ├── decorator.py   # @mcp_perm(resource, action) 权限装饰器 + build_perm_code(码格式唯一来源)
│   ├── discovery.py   # get_entity_metadata / get_all_permissions(实体元数据缓存)
│   └── middleware.py  # JWTAuthMiddleware(admin 模式时启用,server.py 挂载)
├── db/core.py         # DBManager(异步 SQLAlchemy CRUD/分页)+ InfluxDBManager + 管理器缓存
├── error/exceptions.py # UniqueConflictError / ToolError(业务失败收口)等自定义异常
├── handlers/          # 业务逻辑层
│   ├── base_handlers.py   # CodeResolveMixin — FK code→id 解析、占位自动创建、写侧可见性收敛
│   ├── ownership.py   # 归属档位判据 + GOVERNANCE_RESOURCES(表名→资源码)治理注册表
│   ├── add_handlers.py    # 单条 + 批量插入(含价格冲突版本升级)
│   ├── delete_handlers.py # 注册表驱动的删除定位 + 孤儿标记
│   ├── update_handlers.py # 部分更新(None 字段跳过)
│   └── query_handlers.py  # 分页、外键显示展开、异常待办聚合
├── models/
│   ├── orm/           # Base(id/created_at/updated_at/created_by + EnumInt)+ Product/ProductPrice
│   │                  # + PARENT_ENTITY_MAP(父实体可见性注册表)
│   ├── pydantic/      # 动态 Filter/Search 生成器(builder.py)+ 实体请求/响应模型
│   └── schemas.py     # 数据库/缓存配置 + 分页(PaginationParams/PageData)
├── tools/             # MCP 工具定义
│   ├── __init__.py    # @global_tool 装饰器(配置类工具,Apps UI 可跨 App 调用)
│   ├── annotations.py # ToolAnnotations 预设(READ_ONLY / WRITE_* 四件套)
│   ├── crud_factory.py # 注册表驱动生成 add/update/delete 工具(单条+批量)
│   ├── crud_tools.py  # __all__ = register_crud_tools(globals()) —— 保持原样
│   ├── query_tools.py # 列表/搜索/枚举工具
│   ├── basic_tools.py # health、配置 CRUD、review_abnormal_items
│   ├── export_tools.py # CSV 导出示例工具(export_products_csv)
│   └── dict_tools.py  # dict_meta 实体元数据工具
├── task/              # 通用后台任务包(TaskManager 生命周期 + TaskScheduler cron 调度)
└── utils/             # enums(BaseEnum/Errcode/领域枚举)、log、path_utils、common、
                       # rate_limiter(按 key 限速)、spill(大结果溢出)、cron、export(CSV)

Read the full file on GitHub · 243 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. 2d ago Changed · +50 lines · +1,454 tokens per session 5ff1ed04fbcd
  2. 1mo ago Changed · +17 lines · +407 tokens per session e0f53b9523df
  3. 2mo ago First seen · 176 lines · 2,642 tokens per session scan A 5ba9a559ca26

Subscribe to this mod's changes

mcp-service-template AGENTS.md is an instructions file published in the GitHub repository RamidLab/mcp-service-template (0 stars, last pushed 3d ago), licensed MIT. It adds 4,503 tokens to every session, about $0.0180 per session on Opus 5.5. 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.

Related

mcp-service-template AGENTS.md compared with instructions from other repositories

mcp-service-template AGENTS.md next to 6 instructions from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
mcp-service-template AGENTS.mdRamidLab/mcp-service-templateInstructions file03d agoMITA4,503Codex, OpenCode
vscode buildNext.instructions.mdmicrosoft/vscodeInstructions file195kyesterdayMITA9,719GitHub Copilot
next.js AGENTS.mdvercel/next.jsInstructions file143kyesterdayMITA7,461Codex, OpenCode
langchain AGENTS.mdlangchain-ai/langchainInstructions file149kyesterdayMITA4,680Codex, OpenCode
vscode oss-third-party-notices.instructions.mdmicrosoft/vscodeInstructions file195kyesterdayMITA5,516GitHub Copilot
vscode copilot-instructions.mdmicrosoft/vscodeInstructions file195kyesterdayMITA3,093GitHub Copilot
deepseek-harness AGENTS.mddeepseek-ai/deepseek-harnessInstructions file274k2d agoMITA4,313Codex, OpenCode