Skip to main content
Glama
README.md
# Word MCP Server

Based on [Office-Word-MCP-Server](https://github.com/GongRzhe/Office-Word-MCP-Server) by **GongRzhe** – all credit for the core implementation goes to the original author.

## Setup

```bash
./start_server.sh
```

Creates a `.venv` (using `python3.12`), installs dependencies from `requirements.txt`, and starts the server on port **8000** via streamable HTTP.

## Deployment to Docker host

```bash
./deploy_to_remote.sh user
```

Syncs the server via `rsync` to the Docker host and builds/starts the container via `docker compose`.

## MCP Registration

```bash
# Docker / remote
claude mcp add --scope user --transport http word http://<docker-host>:8000/mcp

# Local
claude mcp add --scope user --transport http word http://127.0.0.1:8000/mcp
```

## File Transfer

The server runs in Docker and **cannot access local file paths** (e.g. `/Users/…`). Files must be uploaded via HTTP before they can be used with MCP tools.

Files are stored in `/app/docx_files` inside the container (mapped to `/mnt/dockershare/word`).

```bash
# Upload (required before any tool that takes a filename)
curl -s -H "X-API-Key: $MCP_API_KEY" -F "file=@document.docx" http://<docker-host>:8000/upload
# → returns JSON with "filename": "document.docx"

# Download
curl -H "X-API-Key: $MCP_API_KEY" http://<docker-host>:8000/download/document.docx -o document.docx

# List files
curl -H "X-API-Key: $MCP_API_KEY" http://<docker-host>:8000/files

# Delete single file
curl -X DELETE -H "X-API-Key: $MCP_API_KEY" http://<docker-host>:8000/files/document.docx

# Delete all files
curl -X DELETE -H "X-API-Key: $MCP_API_KEY" http://<docker-host>:8000/files
```

### Workflow for agents

1. Upload the local file via `curl -s -H "X-API-Key: $MCP_API_KEY" -F "file=@/path/to/file.docx" http://<docker-host>:8000/upload`
2. Use the returned `filename` (e.g. `"document.docx"`) with all Word tools
3. Do NOT try to read or unzip DOCX files locally — always upload via curl first

## API Key

Set `MCP_API_KEY` in the container environment to require `X-API-Key` on all `/upload`, `/download`, and `/files` requests. If unset, endpoints are unprotected.

See `docker-compose.yml` for the placeholder.

## License

MIT