Microsoft Excel
Give agents tools to find and create workbooks, read and update ranges, and manage worksheets, tables, and charts in Microsoft Excel through Mastra Connect. Each tool call goes through the Mastra platform, which adds the connection's credential. Your application never stores Microsoft Excel credentials.
ConnectDirect link to Connect
Before you start, complete the Connect setup to install @mastra/connect and configure your platform project.
Workbook operations, such as worksheets, ranges, tables, charts, and named items, require a work or school account. Personal Microsoft accounts can find, create, list, get, and delete workbook files, but Microsoft Graph rejects workbook operations on personal OneDrive.
Connect an accountDirect link to Connect an account
Run this command from the directory that contains your .env file:
mastra connect add microsoft-excel
The CLI guides you through Microsoft Excel's authorization and waits until the connection is active.
Add tools to an agentDirect link to Add tools to an agent
Pass tools() to the agent and select the microsoft-excel provider:
import { Agent } from '@mastra/core/agent'
import { tools } from '@mastra/connect'
export const microsoftExcelAgent = new Agent({
id: 'microsoft-excel-agent',
name: 'Microsoft Excel agent',
instructions:
'You help people find and create workbooks, read and update ranges, and manage worksheets, tables, and charts in Microsoft Excel.',
model: 'openai/gpt-6-luna',
tools: tools({ providers: ['microsoft-excel'] }),
})
The agent gets 27 Microsoft Excel tools, with keys such as microsoft_excel_add_chart. See Microsoft Excel tools for the full list, and the tools() parameters to restrict tools or require approval before a call runs.