draftly-wps
Draftly (wps-mcp)
Simplified Chinese | English
Run an AI chat sidebar that actually operates the current document in WPS Office (Mac), based on the official JS add-in object model API + Claude Agent SDK. Not keyboard/mouse simulation — it directly calls the WPS Writer / Spreadsheet / Presentation object model through MCP tools (Application.CreateTaskPane, etc.).
Prerequisites
macOS, with WPS Office (Mac version) installed and fully opened at least once
Node.js 20 or above
Claude Code CLI installed and logged in (
claude login) — Draftly doesn't manage its own API Key; it reuses your logged-in account state via the locally logged-in Claude Code CLI. If you switch to another machine or another person uses it, you must install and log in to theclaudeCLI on that machine first.
Related MCP server: wps-mcp-server
Installation
git clone <this-repo>
cd wps-mcp
bash scripts/install.shThe script is idempotent — re-running it after changing the code is the upgrade process. It will:
Run
npm installto install dependenciesGenerate a local shared key (
.bridge-token, see "Security Model" below)Copy the add-in files to WPS's add-in directory (
~/Library/Containers/com.kingsoft.wpsoffice.mac/Data/.kingsoft/wps/jsaddons/wps-mcp_)Install a
launchdLaunchAgent so the bridge service starts automatically at login and restarts automatically if it crashes
After installation:
Completely restart WPS Office once (required on first install or when
ribbon.xmlhas been updated — WPS only reads ribbon button definitions once at startup, and doesn't support hot updates;taskpane.html/main.jsupdates are hot-reloaded automatically, no restart needed)In WPS, find the "WPS-MCP" ribbon tab and click the "Draftly" button to open the sidebar
If you can't connect, check the logs:
tail -f ~/Library/Logs/wps-mcp.log
Uninstallation:
launchctl bootout gui/$(id -u)/com.wps-mcp.bridge
rm ~/Library/LaunchAgents/com.wps-mcp.bridge.plist
rm -rf ~/Library/Containers/com.kingsoft.wpsoffice.mac/Data/.kingsoft/wps/jsaddons/wps-mcp_Security Model
The bridge service listens on local 127.0.0.1:58892 and handles WebSocket and HTTP requests. All entry points that produce side effects (the two WebSockets, /tool, /mcp) require ?token= on the URL. This token is a local shared key generated randomly at install time and written to the project root .bridge-token (not in version control); the same value is baked into js/token.js deployed to WPS. Without this validation, any webpage open on your computer could directly connect to this port, impersonate the add-in/panel, and use MCP tools to modify the document you're editing — this isn't a theoretical risk; browsers don't enforce same-origin restrictions on WebSocket connections.
Architecture Overview
addin/— WPS JS add-in:ribbon.xml(ribbon),main.js(object model bridge),taskpane.html(chat panel UI)server/bridge.js— local WebSocket/HTTP bridge, the hub between the add-in and the MCP serverserver/agent.js—/agentWS handling for the chat panel, uses the Claude Agent SDK'squery()to drive conversationsserver/tools.js+server/index.js— MCP server (stdio), forwardswps_word_*/wps_et_*/wps_wpp_*tool calls to the bridge layer
server/index.js auto-detects port conflicts: if 58892 is already occupied by a resident instance, it becomes a lightweight stdio relay and forwards tool calls there instead of grabbing the port — so the MCP server subprocess spawned by the Agent SDK itself won't conflict with the resident service.
Development
npm test # node --test,全仓库单测Strict TDD: write a failing test before changing behavior. Pure logic (session/host handling, streaming accumulator, etc.) is extracted into DOM/WS-independent modules for easy unit testing; WS/DOM glue code stays thin and relies on human review.
Known Limitations
Only macOS WPS Office is supported for now, and it assumes installation at the standard Container path
Multi-user scenarios aren't handled — each user must install and log in to the
claudeCLI themselves; Draftly doesn't provide unified authentication/billingThe brand name "Draftly" is a placeholder; it's recommended to confirm trademark availability before a public release
License
GPL-3.0. Modified versions based on this project must also be open-sourced under GPL-3.0 when redistributed.
This server cannot be installed
Maintenance
Related MCP Servers
- Alicense-qualityDmaintenanceEnables AI assistants to create, read, edit, and manipulate LibreOffice documents with support for track changes, comments, search/replace, and real-time document operations through a native extension or HTTP API.9MIT
- Alicense-qualityDmaintenanceEnables AI agents to natively create and edit WPS Office documents, spreadsheets, and presentations via natural language commands.14MIT
- Alicense-qualityAmaintenanceA local MCP server that lets Claude, Cursor, Codex, or any MCP client work with Office documents on your Mac: evaluate spreadsheet formulas, read/write XLSX and PPTX, extract structured DOCX content, and merge/split/protect PDFs. 100% local, no network calls, no account. 14 tools.MIT
- Alicense-qualityCmaintenanceIntegrates AI assistants with WPS Office to automate operations across Writer, Spreadsheets, and Presentations via the MCP protocol.1MIT
Related MCP Connectors
Generate PDFs from templates via AI chat. Works with Claude, ChatGPT, Cursor, and any MCP client.
AI document editing for agents: draft, edit, export .docx/PDF. 37 MCP tools; agent self-signup.
A personal RAG database you build from chat, so AI creates work that sounds like you.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Antares422/draftly-wps'
If you have feedback or need assistance with the MCP directory API, please join our Discord server