mcp-ms-office-documents: Instructions file for Codex

AGENTS.md

mcp-ms-office-documents AGENTS.md is an instructions file for Codex, OpenCode from ForLegalAI/mcp-ms-office-documents. It costs 2,319 tokens per session, scanned A, original, MIT.

Repository-specific instructions for an MCP server that creates Office files such as Word documents, spreadsheets, presentations, emails, and XML files. MCP is a standard way for AI tools to call services.

In plain words
What is it for?
Use them when developing or maintaining document-generation tools, upload backends, templates, middleware, or the server itself.
Why use it?
They explain the server's structure, conversion flow, templates, uploads, configuration, and authentication so changes fit the existing design.

Instructions file for CodexOpenCode

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

This is ForLegalAI/mcp-ms-office-documents's own configuration. It tells Codex and OpenCode how to work on mcp-ms-office-documents 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-ms-office-documents configures →

Reuse

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.

Copy the file
curl -O https://raw.githubusercontent.com/ForLegalAI/mcp-ms-office-documents/master/AGENTS.md
Clone the repo
git clone --depth 1 https://github.com/ForLegalAI/mcp-ms-office-documents

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-ms-office-documents AGENTS.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/forlegalai/mcp-ms-office-documents/agents-md/github.svg)](https://agentmods.dev/instructions/forlegalai/mcp-ms-office-documents/agents-md)
Your own site
<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.

agentmods 80×15 button for mcp-ms-office-documents AGENTS.md

Your own site · 80×15
<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>
Per session 2,319 This file is loaded in full into every session.
When invoked 2,319 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.02319 $0.02319
Opus 5 $0.01159 $0.01159
Sonnet 5 $0.00464 $0.00464
Haiku 4.5 $0.00232 $0.00232

Measured yesterday against content hash 5bb38617e4ea, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

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.

AGENTS.md · 73 lines

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 reads os.environ directly. Access via get_config() singleton.
  • Template resolution (template_utils.py): searches custom_templates/ before default_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.yaml merged with config/pptx_templates.d/) naming one or more templates, each selectable by the tool's template argument. With no registry the two historical filename slots are synthesised as specs named 16_9 and 4_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. .potx is 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). Addressing slide_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 own layout name, then the registry's layouts: mapping, then detection, then the positional index with a warning. Do not reintroduce a bare slide_layouts[...] lookup in a builder; go through _new_slide().
  • 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 declares flat_slide_schema() — one object with every field of every type, each field's description naming the types that accept it — via WithJsonSchema. oneOf/$ref/discriminator do not survive clients that bridge MCP to a provider without them: they show the model slides: array of string while 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 in coerce_slides(), which is reached through PowerpointPresentation and produces slide 2 -> rows.0: … messages that main.py turns into a ToolError. A slide arriving as a string (JSON, or markdown for one slide) is read by slide_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 via register_*_template_tools_from_yaml(mcp, path). Placeholders use Mustache syntax {{name}}. See config/docx_templates.yaml for the canonical example.
    • Merged loading: the master config/<kind>_templates.yaml is merged with UI-managed per-template files in config/<kind>_templates.d/<name>.yaml (the .d file wins on a name clash). The documented master files are never rewritten by tooling. Merge logic lives in template_registry.py.
    • Live (un)registration: register_docx_template / register_email_template (and their unregister_* counterparts) can add/replace/remove tools on a running FastMCP instance via local_provider, so the admin UI applies template edits without a restart. A module-level registry tracks live dynamic tool names.
  • Admin UI (admin/, opt-in via ADMIN_ENABLED): a FastHTML template-admin for creating/editing dynamic docx+email templates without YAML. When enabled, main.py runs the combined ASGI app (admin.app.build_combined_app) under uvicorn — the MCP endpoint mounted at / and the admin UI under ADMIN_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). When ADMIN_ENABLED is unset, main.py keeps the original mcp.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() in dynamic_*_tools.py. The TYPE_MAP dict maps YAML type strings to Python types.
  • Error handling in tools: raise fastmcp.exceptions.ToolError for user-facing errors; use RuntimeError in upload/backend layers.
  • Logging: use logging.getLogger(__name__) everywhere. Level controlled by DEBUG env var only.

Read the full file on GitHub · 73 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. yesterday Changed · +1 lines · +237 tokens per session 5bb38617e4ea
  2. 6d ago Changed · +3 lines · +403 tokens per session 91bc7096046d
  3. 11d ago First seen · 69 lines · 1,679 tokens per session scan A 5fb867305edb

Subscribe to this mod's changes

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.

Related

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.

vercel/next.js · 7,296 tokens

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.

openai/codex · 5,153 tokens

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).

microsoft/vscode · 6,785 tokens

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.

github/spec-kit · 7,104 tokens

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.

langchain-ai/langchain · 4,469 tokens

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).

microsoft/vscode · 5,001 tokens