Skip to main content

Microsoft Word

Give agents tools to find, create, copy, and move Word documents, read and update their content, and share them in Microsoft Word through Mastra Connect. Each tool call goes through the Mastra platform, which adds the connection's credential. Your application never stores Microsoft Word credentials.

Connect
Direct link to Connect

Before you start, complete the Connect setup to install @mastra/connect and configure your platform project.

Connect an account
Direct link to Connect an account

Run this command from the directory that contains your .env file:

mastra connect add microsoft-word

The CLI guides you through Microsoft Word's authorization and waits until the connection is active.

Add tools to an agent
Direct link to Add tools to an agent

Pass tools() to the agent and select the microsoft-word provider:

src/mastra/agents/microsoft-word-agent.ts
import { Agent } from '@mastra/core/agent'
import { tools } from '@mastra/connect'

export const microsoftWordAgent = new Agent({
id: 'microsoft-word-agent',
name: 'Microsoft Word agent',
instructions:
'You help people find, create, copy, and move Word documents, read and update their content, and share them in Microsoft Word.',
model: 'openai/gpt-6-luna',
tools: tools({ providers: ['microsoft-word'] }),
})

The agent gets 18 Microsoft Word tools, with keys such as microsoft_word_copy_word_document. See Microsoft Word tools for the full list, and the tools() parameters to restrict tools or require approval before a call runs.

On this page