Borrowing it
Nothing to install: this file belongs to ForLegalAI/mcp-ms-office-documents. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.
curl -O https://raw.githubusercontent.com/ForLegalAI/mcp-ms-office-documents/master/AGENTS.mdgit clone --depth 1 https://github.com/ForLegalAI/mcp-ms-office-documentsWrote 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/instructions/forlegalai/mcp-ms-office-documents/agents-md)<a href="https://agentmods.dev/instructions/forlegalai/mcp-ms-office-documents/agents-md"><img src="https://agentmods.dev/badge/instructions/forlegalai/mcp-ms-office-documents/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.
<a href="https://agentmods.dev/instructions/forlegalai/mcp-ms-office-documents/agents-md"><img src="https://agentmods.dev/badge/instructions/forlegalai/mcp-ms-office-documents/agents-md.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.02319 | $0.02319 |
| Opus 5 | $0.01159 | $0.01159 |
| Sonnet 5 | $0.00464 | $0.00464 |
| Haiku 4.5 | $0.00232 | $0.00232 |
Grade A, and why
mcp-ms-office-documents 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 yesterday.
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 — 73 lines — stays where its author put it; the contents beside it link to each section on GitHub.
AGENTS.md
Project Overview
MCP (Model Context Protocol) server built with FastMCP 3.0 that exposes Office document generation as MCP tools. Runs as a Docker container (Python 3.12, Alpine) on port 8958 at /mcp using streamable-HTTP transport. Entry point: main.py.
Architecture
main.py ← Registers all MCP tools on a single FastMCP instance
├── {docx,xlsx,pptx,email,xml}_tools/
│ ├── __init__.py ← Re-exports the public function (e.g. markdown_to_word)
│ ├── base_*_tool.py ← Core conversion logic (markdown → document bytes)
│ ├── helpers.py ← Parsing, formatting, shared utilities
│ └── dynamic_*_tools.py ← YAML-driven tool registration (docx, email only)
├── upload_tools/
│ ├── main.py ← upload_file() dispatches to strategy backend
│ └── backends/{local,s3,gcs,azure,minio}.py
├── config.py ← Singleton Config from env vars (Pydantic v2), logging setup
├── template_utils.py ← Template resolution: custom_templates/ → default_templates/
└── middleware.py ← Optional API key auth (Bearer / x-api-key header)
Data flow: Every tool converts input → in-memory bytes → calls upload_file(file_obj, suffix) → backend saves/uploads → returns URL or path string to the MCP client.
Key Conventions
- Config is centralized in
config.py— no module readsos.environdirectly. Access viaget_config()singleton. - Template resolution (
template_utils.py): searchescustom_templates/beforedefault_templates/, with/app/*container paths tried first, then local paths. Never hardcode template paths.- PowerPoint templates additionally go through
pptx_tools/templates.py: an optional registry (config/pptx_templates.yamlmerged withconfig/pptx_templates.d/) naming one or more templates, each selectable by the tool'stemplateargument. With no registry the two historical filename slots are synthesised as specs named16_9and4_3, so existing deployments are unchanged. The registry is cached against an mtime fingerprint of the config and template directories rather than for the process lifetime, so a new template is picked up without a restart..potxis accepted by rewriting its content type in memory, since python-pptx rejects the template flavour outright. - Layouts are resolved by name and placeholder signature, never by index (
pptx_tools/layouts.py). Addressingslide_layouts[N]positionally silently mis-laid decks built on any template whose layouts were reordered, and raised on any template with fewer layouts.classify_layout()reads placeholder types (so it is language-independent) to assign each layout a role — title, section, content, two_column, comparison, image_text, title_only, blank. Order: the slide's ownlayoutname, then the registry'slayouts:mapping, then detection, then the positional index with a warning. Do not reintroduce a bareslide_layouts[...]lookup in a builder; go through_new_slide().
- PowerPoint templates additionally go through
- The slide schema is modelled as a union and published flat (
pptx_tools/schema.py): validation uses the discriminated union of the fourteen slide models, but the tool parameter declaresflat_slide_schema()— one object with every field of every type, each field's description naming the types that accept it — viaWithJsonSchema.oneOf/$ref/discriminatordo not survive clients that bridge MCP to a provider without them: they show the modelslides: array of stringwhile still validating against the union, so every call fails client-side before reaching the server. Keep the published schema inside that keyword subset (_simplify()strips the rest), and keep validation incoerce_slides(), which is reached throughPowerpointPresentationand producesslide 2 -> rows.0: …messages thatmain.pyturns into aToolError. A slide arriving as a string (JSON, or markdown for one slide) is read byslide_from_text()rather than rejected — a fallback for those same clients, deliberately not documented as a second spelling in the tool description. - Dynamic tool registration: YAML files in
config/define parameterized email/docx templates. Each entry becomes a separate MCP tool at startup viaregister_*_template_tools_from_yaml(mcp, path). Placeholders use Mustache syntax{{name}}. Seeconfig/docx_templates.yamlfor the canonical example.- Merged loading: the master
config/<kind>_templates.yamlis merged with UI-managed per-template files inconfig/<kind>_templates.d/<name>.yaml(the.dfile wins on a name clash). The documented master files are never rewritten by tooling. Merge logic lives intemplate_registry.py. - Live (un)registration:
register_docx_template/register_email_template(and theirunregister_*counterparts) can add/replace/remove tools on a runningFastMCPinstance vialocal_provider, so the admin UI applies template edits without a restart. A module-level registry tracks live dynamic tool names.
- Merged loading: the master
- Admin UI (
admin/, opt-in viaADMIN_ENABLED): a FastHTML template-admin for creating/editing dynamic docx+email templates without YAML. When enabled,main.pyruns the combined ASGI app (admin.app.build_combined_app) under uvicorn — the MCP endpoint mounted at/and the admin UI underADMIN_PATH(default/admin) in one process, so saving a template registers its MCP tool live. Modules:store.py(TemplateStore+FileTemplateStore, abstracted for a future shared backend),analysis.py(placeholder/conditional/style detection on uploaded assets),preview.py(render with sample values, no upload backend),auth.py(shared-password gate),app.py(views + app factory, including the Status page and document re-upload/re-scan). WhenADMIN_ENABLEDis unset,main.pykeeps the originalmcp.run()path unchanged. - Metrics (
metrics.py, project root): tiny always-on in-process counters (per-template calls/errors/last-used, recorded by the dynamic tool wrappers) plus a bounded recent-log ring buffer (installed by the admin app at startup). Surfaced on the admin Status page. No external deps; safe to import from the core tool modules. - Pydantic models for tool arguments are created dynamically with
create_model()indynamic_*_tools.py. TheTYPE_MAPdict maps YAML type strings to Python types. - Error handling in tools: raise
fastmcp.exceptions.ToolErrorfor user-facing errors; useRuntimeErrorin upload/backend layers. - Logging: use
logging.getLogger(__name__)everywhere. Level controlled byDEBUGenv var only.
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.
- yesterday Changed · +1 lines · +237 tokens per session 5bb38617e4ea
- 6d ago Changed · +3 lines · +403 tokens per session 91bc7096046d
- 11d ago First seen · 69 lines · 1,679 tokens per session scan A 5fb867305edb
mcp-ms-office-documents AGENTS.md is an instructions file published in the GitHub repository ForLegalAI/mcp-ms-office-documents (38 stars, last pushed yesterday), licensed MIT. It adds 2,319 tokens to every session, about $0.0116 per session on Opus 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-30.
Other instructions, from other repositories
next.js AGENTS.md
AGENTS.md instructions for vercel/next.js, covering next.js development guide, codebase structure, monorepo overview, core package: packages/next and other important packages.
codex AGENTS.md
AGENTS.md instructions for openai/codex, covering rust/codex-rs, the codex-core crate, code review rules, crate api surface and model visible context.
vscode buildNext.instructions.md
Working notes and architecture documentation for the new esbuild-based build system in build/next. Use when making changes to the new build pipeline (transpile/bundle commands, NLS plugin, source-map handling, resource copying, or self-hosting watch tasks).
spec-kit AGENTS.md
AGENTS.md instructions for github/spec-kit, covering agents.md, about spec kit and specify, quickstart — add a new integration in 5 steps, integration architecture and integrationmanifest — file tracking.
langchain AGENTS.md
AGENTS.md instructions for langchain-ai/langchain, covering global development guidelines for the langchain monorepo, corridor security analysis, project architecture and context, monorepo structure and development tools & commands.
vscode oss-third-party-notices.instructions.md
Instructions for microsoft/vscode, covering vs code oss third-party-notices pipeline, architecture, pipeline flow in ci, applying the notice (cutover) and fallback chain (never fail the build).