Skip to main content

this is an mcp server for you to control office application installed in windows

Project description

OfficeMCP

OfficeMCP server is designed for AI to automate Microsoft Office Applications (Word, Excel, PowerPoint, Access, OneNote, Visio, Project, WPS.word, Wps.powerpoint, wps.excel etc.) by COM interface in Windows OS. Not working on Linux/MacOS.

Warns

you should this mcp carefully, as it not limit the usage of python. epeciall there's a tool RunPython(...) to execute Ai model's thought, but it is also the wonderfull parts of OfficeMCP. we can't guarantee that your AI model will not do something bad to your computer. we don't take any responsibility.

System Requirements

  1. Windows system

  2. python 3.1 or above installed

  3. uv installed open an shell window and run command

    pip install uv

How to install OfficeMCP

There are two ways or two modes to install OfficeMCP (They also can be used in the same time):

1. Use OfficeMCP as stdio server:

  • One OfficeMCP server for one mcp client mode
  • Put following setting to MCP.json file for vscode or some proper place for other AI IDE:
{
    "mcpServers": {
        "OfficeMCP": {
            "type": "stdio",
            "command": "uvx",
            "args": [
                "officemcp"
            ]
        }
    }
}

2. Use OfficeMCP as sse server:

  • One OfficeMCP server for multi mcp client mode
  • You can change port and host as you like
  • This is recommended way to use OfficeMCP server.

step 1:

Run one command in shell or power shell:

uvx officemcp sse

the Mcp server url will be: "http://127.0.0.1:8888/sse" or "http://127.0.0.1:8888/sse"

or something like below

uvx officemcp sse --port 7777 --host 127.0.0.8

"url" will be : "http://127.0.0.8:7777/sse"

step 2:

Put following setting to MCP.json file for vscode or some proper place for other AI IDE:

{
    "servers": {
        "OfficeMCP": {
            "url": "http://127.0.0.1:8888/sse"
        }
    }
}

or

{
    "servers": {
        "OfficeMCP": {
            "url": "http://{your_host}:{your_port}/sse"
        }
    }
}

Usage

On AI IDE, you can ask AI model to control Office Applications by OfficeMCP server:

  • You ask AI model to open a new Office Application. AI model will send a request to OfficeMCP server, and OfficeMCP server will open a new Office Application.

  • You ask AI model to do whatever you want to do in the current Office Application. AI model will analyze your request, and call OfficeMCP server's tool to accomplish your request.

Tools Reference

Tools:

  • AvailableApps(): check if Microsoft Office applications are installed on your computer.

  • RunningApps(): get a list of currently running Office applications.

  • IsAppAvailable(...): check if a specific Office application is installed.

  • Launch(...): launch a new Office application and set its visibility.

  • Visible(...): set the specified Office application's visibility to True or False.

  • Quit(...): quit the specified Office application.

  • Demonstrate(): run a demonstration of OfficeMCP automation features.

  • Speak(...): speak a string you passed in.

  • Beep(...): play a beep sound.

  • DefaultFolder(...): return the OfficeMCP root work folder default is ("D:\OfficeMCP")

  • IsFileExists(sub_path): check if a file exists in the OfficeMCP root folder.

  • DownloadImage(...): download an image from a given URL and save it to the specified path.

  • RunPython(codes,data): run python code in the OfficeMCP server context.

    • This is the most powerful tool in OfficeMCP server. AI can use this tool to do anything supported by the server, including automating Office applications.
    • There is an object "Officer" that can be used in the python code, e.g. Officer.Excel holds the current Excel com Application, and more are Officer.Word, Officer.Powerpoint, Office.Visio, Officer.Access, Officer.OneNote, Officer.Visio, Officer.Project. Office.Kwps for WPS word, Office.Ket for WPS excell, Office.Kwpp for WPS powerpoint.
    • There is an object "output" as RunPython(...) return that can be used in the python code, to put your own return result in to output, like output="run python sccessed", then RunPython return "run python sccessed" to AI model.
    • You can use Officer.Visio to create a new Visio document, and then use Officer.Visio.ActivePage to get the active page, and use Officer.Visio.ActivePage.DrawRectangle(...) to draw a rectangle on the page.
    • You can use Officer.Excel to create a new Excel document, and then use Officer.Excel.ActiveSheet to get the active sheet, and use Officer.Excel.ActiveSheet.Cells(...) to get the cell, and use Officer.Excel.ActiveSheet.Cells(...).Value = "hello" to set the cell value.
    • You use codes to control them by running the codes with RunPython tool.
  • More tools will be added in the future.

Development

git clone https://github.com/officemcp/officemcp

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

officemcp-1.0.5.tar.gz (27.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

officemcp-1.0.5-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file officemcp-1.0.5.tar.gz.

File metadata

  • Download URL: officemcp-1.0.5.tar.gz
  • Upload date:
  • Size: 27.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.16

File hashes

Hashes for officemcp-1.0.5.tar.gz
Algorithm Hash digest
SHA256 e7ee0616c76510faf485ee6a6254aea1e9c7e500e33da97c6f626586a749c514
MD5 95baf822aa026bc2115e3dd06ececfa8
BLAKE2b-256 d4121feb5d22976f252e74d0fb5280137dc2c920c6e6a103f4e4ad4be6bc86ee

See more details on using hashes here.

File details

Details for the file officemcp-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: officemcp-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 11.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.16

File hashes

Hashes for officemcp-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 9e263a91d996d6fd07eb9623ee762f7c10a1e4db43d20a38c15e0f897cba00ec
MD5 8a2a447daa2026df80ddaa2fb04d6bf5
BLAKE2b-256 f0a19c0b8dfd576aa1e6e6983224c3cb2858d06f4ca0a20343bfec2abc20cc7c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page