# forlegalai/mcp-ms-office-documents architecture

> Architecture diagram of the GitHub repository forlegalai/mcp-ms-office-documents, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/forlegalai/mcp-ms-office-documents
- Repository: https://github.com/forlegalai/mcp-ms-office-documents

## Overview

This is an MCP server through which an AI client requests Office-file generation. The main workflow dispatches tool requests to format-specific generators, which render documents and return them through the configured storage strategy. The README also describes dynamic templates and an optional browser admin UI. Edges reflect README statements and SOURCE INDEX references; several format internals and backend implementations were not sampled, so their details are intentionally summarized.

Main entry points: [`main.py`](https://github.com/forlegalai/mcp-ms-office-documents/blob/master/main.py) (MCP entry point), [`upload_tools/main.py`](https://github.com/forlegalai/mcp-ms-office-documents/blob/master/upload_tools/main.py) (Upload dispatcher), [`docx_tools/dynamic_docx_tools.py`](https://github.com/forlegalai/mcp-ms-office-documents/blob/master/docx_tools/dynamic_docx_tools.py) (Word generation), [`email_tools/dynamic_email_tools.py`](https://github.com/forlegalai/mcp-ms-office-documents/blob/master/email_tools/dynamic_email_tools.py) (Email templates)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_server["MCP server"]
  node_main["MCP entry point<br/>[main.py]"]
  node_config["Configuration<br/>[config.py]"]
end

subgraph group_generators["Document generators"]
  node_docx["Word generation"]
  node_docx_render["Markdown rendering"]
  node_pptx["PowerPoint generation<br/>[slide_builder.py]"]
  node_pptx_layouts["Layout resolution<br/>[layouts.py]"]
  node_xlsx["Excel generation<br/>[base_xlsx_tool.py]"]
  node_email["Email drafts<br/>[base_email_tool.py]"]
  node_dynamic_email["Email templates"]
  node_xml["XML generation<br/>[base_xml_tool.py]"]
end

subgraph group_templates["Templates and admin"]
  node_registry["Template registry"]
  node_template_files["Template resolution<br/>[template_utils.py]"]
  node_pptx_templates["PowerPoint templates<br/>[templates.py]"]
  node_admin["Template admin UI<br/>[app.py]"]
  node_admin_store[("Managed template store<br/>[store.py]")]
end

subgraph group_storage["File storage"]
  node_uploader["Upload dispatcher<br/>[main.py]"]
  node_backends["Storage backends"]
  node_local_store[("Local output<br/>[local.py]")]
  node_cloud_store["Cloud and LibreChat backends"]
end

node_client(("AI client"))

node_client -->|"requests tools"| node_main
node_main -->|"registers tools"| node_docx
node_main -->|"registers tools"| node_pptx
node_main -->|"registers tools"| node_xlsx
node_main -->|"registers tools"| node_email
node_main -->|"registers tools"| node_dynamic_email
node_main -->|"registers tools"| node_xml
node_main -->|"loads settings"| node_config
node_docx -->|"renders Markdown"| node_docx_render
node_pptx -->|"resolves layouts"| node_pptx_layouts
node_docx -->|"loads template specs"| node_registry
node_dynamic_email -->|"loads template specs"| node_registry
node_docx -->|"resolves templates"| node_template_files
node_dynamic_email -->|"resolves templates"| node_template_files
node_pptx_templates -->|"uses registry"| node_registry
node_pptx_templates -->|"finds template files"| node_template_files
node_main -.->|"mounts admin UI"| node_admin
node_admin -->|"persists templates"| node_admin_store
node_admin -->|"updates registrations"| node_registry
node_docx -->|"uploads files"| node_uploader
node_email -->|"uploads drafts"| node_uploader
node_dynamic_email -->|"uploads drafts"| node_uploader
node_xml -->|"uploads files"| node_uploader
node_uploader -->|"reads strategy"| node_config
node_uploader -->|"dispatches uploads"| node_backends
node_backends -->|"saves locally"| node_local_store
node_backends -->|"uploads remotely"| node_cloud_store

click node_main "https://github.com/forlegalai/mcp-ms-office-documents/blob/master/main.py"
click node_config "https://github.com/forlegalai/mcp-ms-office-documents/blob/master/config.py"
click node_docx "https://github.com/forlegalai/mcp-ms-office-documents/blob/master/docx_tools/dynamic_docx_tools.py"
click node_docx_render "https://github.com/forlegalai/mcp-ms-office-documents/blob/master/docx_tools/markdown_processor.py"
click node_pptx "https://github.com/forlegalai/mcp-ms-office-documents/blob/master/pptx_tools/slide_builder.py"
click node_pptx_layouts "https://github.com/forlegalai/mcp-ms-office-documents/blob/master/pptx_tools/layouts.py"
click node_xlsx "https://github.com/forlegalai/mcp-ms-office-documents/blob/master/xlsx_tools/base_xlsx_tool.py"
click node_email "https://github.com/forlegalai/mcp-ms-office-documents/blob/master/email_tools/base_email_tool.py"
click node_dynamic_email "https://github.com/forlegalai/mcp-ms-office-documents/blob/master/email_tools/dynamic_email_tools.py"
click node_xml "https://github.com/forlegalai/mcp-ms-office-documents/blob/master/xml_tools/base_xml_tool.py"
click node_registry "https://github.com/forlegalai/mcp-ms-office-documents/blob/master/template_registry.py"
click node_template_files "https://github.com/forlegalai/mcp-ms-office-documents/blob/master/template_utils.py"
click node_pptx_templates "https://github.com/forlegalai/mcp-ms-office-documents/blob/master/pptx_tools/templates.py"
click node_admin "https://github.com/forlegalai/mcp-ms-office-documents/blob/master/admin/app.py"
click node_admin_store "https://github.com/forlegalai/mcp-ms-office-documents/blob/master/admin/store.py"
click node_uploader "https://github.com/forlegalai/mcp-ms-office-documents/blob/master/upload_tools/main.py"
click node_backends "https://github.com/forlegalai/mcp-ms-office-documents/tree/master/upload_tools/backends"
click node_local_store "https://github.com/forlegalai/mcp-ms-office-documents/blob/master/upload_tools/backends/local.py"
click node_cloud_store "https://github.com/forlegalai/mcp-ms-office-documents/tree/master/upload_tools/backends"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_config,node_client toneBlue
class node_docx,node_docx_render,node_pptx,node_pptx_layouts,node_xlsx,node_email,node_dynamic_email,node_xml toneAmber
class node_registry,node_template_files,node_pptx_templates,node_admin,node_admin_store toneMint
class node_uploader,node_backends,node_local_store,node_cloud_store toneRose
```

## Components

### MCP server

- [MCP entry point](https://github.com/forlegalai/mcp-ms-office-documents/blob/master/main.py): `main.py`
- [Configuration](https://github.com/forlegalai/mcp-ms-office-documents/blob/master/config.py): `config.py`

### Document generators

- [Word generation](https://github.com/forlegalai/mcp-ms-office-documents/blob/master/docx_tools/dynamic_docx_tools.py): `docx_tools/dynamic_docx_tools.py`
- [Markdown rendering](https://github.com/forlegalai/mcp-ms-office-documents/blob/master/docx_tools/markdown_processor.py): `docx_tools/markdown_processor.py`
- [PowerPoint generation](https://github.com/forlegalai/mcp-ms-office-documents/blob/master/pptx_tools/slide_builder.py): `pptx_tools/slide_builder.py`
- [Layout resolution](https://github.com/forlegalai/mcp-ms-office-documents/blob/master/pptx_tools/layouts.py): `pptx_tools/layouts.py`
- [Excel generation](https://github.com/forlegalai/mcp-ms-office-documents/blob/master/xlsx_tools/base_xlsx_tool.py): `xlsx_tools/base_xlsx_tool.py`
- [Email drafts](https://github.com/forlegalai/mcp-ms-office-documents/blob/master/email_tools/base_email_tool.py): `email_tools/base_email_tool.py`
- [Email templates](https://github.com/forlegalai/mcp-ms-office-documents/blob/master/email_tools/dynamic_email_tools.py): `email_tools/dynamic_email_tools.py`
- [XML generation](https://github.com/forlegalai/mcp-ms-office-documents/blob/master/xml_tools/base_xml_tool.py): `xml_tools/base_xml_tool.py`

### Templates and admin

- [Template registry](https://github.com/forlegalai/mcp-ms-office-documents/blob/master/template_registry.py): `template_registry.py`
- [Template resolution](https://github.com/forlegalai/mcp-ms-office-documents/blob/master/template_utils.py): `template_utils.py`
- [PowerPoint templates](https://github.com/forlegalai/mcp-ms-office-documents/blob/master/pptx_tools/templates.py): `pptx_tools/templates.py`
- [Template admin UI](https://github.com/forlegalai/mcp-ms-office-documents/blob/master/admin/app.py): `admin/app.py`
- [Managed template store](https://github.com/forlegalai/mcp-ms-office-documents/blob/master/admin/store.py): `admin/store.py`

### File storage

- [Upload dispatcher](https://github.com/forlegalai/mcp-ms-office-documents/blob/master/upload_tools/main.py): `upload_tools/main.py`
- [Storage backends](https://github.com/forlegalai/mcp-ms-office-documents/tree/master/upload_tools/backends): `upload_tools/backends`
- [Local output](https://github.com/forlegalai/mcp-ms-office-documents/blob/master/upload_tools/backends/local.py): `upload_tools/backends/local.py`
- [Cloud and LibreChat backends](https://github.com/forlegalai/mcp-ms-office-documents/tree/master/upload_tools/backends): `upload_tools/backends`

### Other components

- **AI client**

## Connections

- AI client → MCP entry point: requests tools
- MCP entry point → Word generation: registers tools (evidence: `main.py`)
- MCP entry point → PowerPoint generation: registers tools (evidence: `main.py`)
- MCP entry point → Excel generation: registers tools (evidence: `main.py`)
- MCP entry point → Email drafts: registers tools (evidence: `main.py`)
- MCP entry point → Email templates: registers tools (evidence: `main.py`)
- MCP entry point → XML generation: registers tools (evidence: `main.py`)
- MCP entry point → Configuration: loads settings (evidence: `main.py`)
- Word generation → Markdown rendering: renders Markdown (evidence: `docx_tools/dynamic_docx_tools.py`)
- PowerPoint generation → Layout resolution: resolves layouts (evidence: `pptx_tools/slide_builder.py`)
- Word generation → Template registry: loads template specs (evidence: `docx_tools/dynamic_docx_tools.py`)
- Email templates → Template registry: loads template specs (evidence: `email_tools/dynamic_email_tools.py`)
- Word generation → Template resolution: resolves templates (evidence: `docx_tools/dynamic_docx_tools.py`)
- Email templates → Template resolution: resolves templates (evidence: `email_tools/dynamic_email_tools.py`)
- PowerPoint templates → Template registry: uses registry (evidence: `pptx_tools/templates.py`)
- PowerPoint templates → Template resolution: finds template files (evidence: `pptx_tools/templates.py`)
- MCP entry point → Template admin UI: mounts admin UI (evidence: `main.py`)
- Template admin UI → Managed template store: persists templates (evidence: `admin/app.py`)
- Template admin UI → Template registry: updates registrations (evidence: `admin/app.py`)
- Word generation → Upload dispatcher: uploads files (evidence: `docx_tools/dynamic_docx_tools.py`)
- Email drafts → Upload dispatcher: uploads drafts (evidence: `email_tools/base_email_tool.py`)
- Email templates → Upload dispatcher: uploads drafts (evidence: `email_tools/dynamic_email_tools.py`)
- XML generation → Upload dispatcher: uploads files (evidence: `xml_tools/base_xml_tool.py`)
- Upload dispatcher → Configuration: reads strategy (evidence: `upload_tools/main.py`)
- Upload dispatcher → Storage backends: dispatches uploads (evidence: `upload_tools/main.py`)
- Storage backends → Local output: saves locally (evidence: `upload_tools/main.py`)
- Storage backends → Cloud and LibreChat backends: uploads remotely (evidence: `upload_tools/main.py`)
