Skip to main content
Glama
cybrlou

Office 365 Email MCP

by cybrlou

Office 365 Email MCP

An MCP server that lets an AI agent send email through Microsoft 365 / Office 365 using the OAuth2 client-credentials (app-only) flow and the Microsoft Graph API.

No interactive login at runtime — register an app once, grant it Mail.Send, and the server sends mail headlessly. Ideal for automation, notifications, and agent workflows.

Features

  • office365_send_email — send plain-text or HTML email, with CC/BCC and local file attachments.

  • office365_test_connection — verify your OAuth2 config by acquiring a token (sends nothing).

  • App-only auth (no user sign-in), tokens cached and refreshed automatically by MSAL.

  • Clear, actionable error messages for the common auth/permission/mailbox mistakes.

Related MCP server: MCP Outlook Server

How it works

agent → MCP tool → MSAL (client credentials) → Entra ID → access token
                 → POST https://graph.microsoft.com/v1.0/users/{sender}/sendMail

Prerequisites

  • Python 3.10+

  • A Microsoft 365 tenant where you can register an app (or an admin who can).

  • A licensed mailbox to send from.

1. Register the app in Microsoft Entra ID

  1. Go to Entra admin centerIdentity → Applications → App registrations → New registration.

  2. Name it (e.g. office365-email-mcp), leave redirect URI blank, Register.

  3. Copy the Application (client) ID and Directory (tenant) ID from the Overview page.

  4. Certificates & secrets → New client secret → copy the secret Value (shown once).

  5. API permissions → Add a permission → Microsoft Graph → Application permissions → Mail.SendAdd.

  6. Click Grant admin consent for your tenant. (Requires an admin; the green check must appear.)

Scope it down (recommended). Mail.Send (Application) lets the app send as any mailbox in the tenant. Restrict it to specific mailboxes with an Application Access Policy in Exchange Online:

New-ApplicationAccessPolicy -AppId <CLIENT_ID> `
  -PolicyScopeGroupId mcp-senders@yourdomain.com `
  -AccessRight RestrictAccess `
  -Description "Restrict office365-email-mcp to the mcp-senders group"

2. Install

# from a clone of this repo
pip install .

# or run without installing, using uv
uvx --from . office365-email-mcp

3. Configure

Set these environment variables (see .env.example):

Variable

Required

Description

O365_TENANT_ID

yes

Directory (tenant) ID

O365_CLIENT_ID

yes

Application (client) ID

O365_CLIENT_SECRET

yes

Client secret value

O365_SENDER

no

Default sender mailbox (overridable per call)

4. Add to your MCP client

Claude Desktop / Claude Code (claude_desktop_config.json or .mcp.json):

{
  "mcpServers": {
    "office365-email": {
      "command": "office365-email-mcp",
      "env": {
        "O365_TENANT_ID": "00000000-0000-0000-0000-000000000000",
        "O365_CLIENT_ID": "00000000-0000-0000-0000-000000000000",
        "O365_CLIENT_SECRET": "your-secret-value",
        "O365_SENDER": "noreply@yourdomain.com"
      }
    }
  }
}

If you didn't pip install, use "command": "uvx" with "args": ["--from", "/path/to/repo", "office365-email-mcp"].

Tools

office365_send_email

Parameter

Type

Required

Notes

to

string[]

yes

Primary recipients

subject

string

yes

body

string

yes

Plain text or HTML

is_html

bool

no

Treat body as HTML (default false)

cc / bcc

string[]

no

sender

string

no

Overrides O365_SENDER

attachments

string[]

no

Local file paths, < ~3 MB total

save_to_sent_items

bool

no

Default true

office365_test_connection

No parameters. Acquires a token and reports success/failure — run this first when troubleshooting.

Troubleshooting

Error

Fix

401 Authentication failed

Client secret expired or wrong tenant/client ID.

403 Permission denied

Missing Mail.Send Application permission or admin consent not granted.

404 Sender mailbox not found

sender isn't a real, licensed mailbox in the tenant.

Application Access Policy blocks send

The sender isn't in the allowed group from your access policy.

Security notes

  • The client secret is a credential — keep it out of source control (.env is gitignored). Rotate it periodically.

  • Prefer an Application Access Policy so the app can only send as intended mailboxes.

  • Attachments over ~3 MB exceed Graph's single-request sendMail limit; share a link instead.

License

MIT

Available Tools

2 tools
office365_send_emailA

Send an email through Microsoft 365 via the Microsoft Graph API.

Uses the app-only (client-credentials) OAuth2 flow, so no user is signed in; mail is sent from the mailbox given by sender or the O365_SENDER env var. Supports plain-text or HTML bodies, CC/BCC, and local file attachments.

Args: params (SendEmailInput): Validated parameters containing: - to (list[str]): Primary recipient addresses (required). - subject (str): Subject line (required). - body (str): Body content, plain text or HTML (required). - is_html (bool): Treat body as HTML when true (default False). - cc (Optional[list[str]]): CC recipients. - bcc (Optional[list[str]]): BCC recipients. - sender (Optional[str]): From mailbox; overrides O365_SENDER. - attachments (Optional[list[str]]): Local file paths (<~3 MB total). - save_to_sent_items (bool): Keep a Sent Items copy (default True).

Returns: str: A human-readable confirmation, e.g. "Email sent from finance@contoso.com to 2 recipient(s): 'Subject'." On failure, a string beginning with "Error: " describing the problem and how to fix it (auth, permissions, mailbox, rate limits, etc.).

Examples: - "Email the Q3 report to alice@contoso.com" -> to=['alice@contoso.com'], subject='Q3 report', body='...', attachments=['/path/q3.pdf']. - Don't use to read or search mail; this tool only sends.

ParametersJSON Schema
NameRequiredDescriptionDefault
paramsYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A5/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description discloses behavioral traits beyond annotations: it confirms email sending (write operation), notes default save to sent items, attachment size limit (~3 MB), and error response format ('Error:'). Annotations show readOnlyHint=false, destructiveHint=false, idempotentHint=false, with no contradictions.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with sections (summary, details, Args, Returns, Examples) and front-loads the core purpose. Every sentence is informative, concise, and earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity and the presence of an output schema, the description covers all necessary aspects: inputs, outputs, error handling, authentication, constraints, and examples. The sibling tool is minimal, so no additional differentiation needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Despite 0% schema description coverage, the description provides detailed parameter semantics in the Args section, explaining purpose, constraints, defaults, and examples for each parameter (to, subject, body, is_html, cc, bcc, sender, attachments, save_to_sent_items). This fully compensates for the lack of schema descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Send an email through Microsoft 365 via the Microsoft Graph API,' specifying the action, resource, and distinguishing from the sibling tool (office365_test_connection). It explicitly warns 'Don't use to read or search mail; this tool only sends.'

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit when-to-use guidance (sending email) and when-not-to-use (reading or searching mail). It includes examples, constraints like attachment size limits, authentication details, and mentions the O365_SENDER env var. It also clarifies that it uses app-only OAuth2 flow.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

office365_test_connectionA
Read-onlyIdempotent

Verify OAuth2 configuration by acquiring an app-only Graph token.

Performs no email send and reads no data. It only checks that the O365_TENANT_ID / O365_CLIENT_ID / O365_CLIENT_SECRET environment variables are present and valid enough to obtain an access token from Microsoft Entra ID. Use this first when diagnosing setup problems.

Returns: str: "OK: ..." on success (token acquired), including whether a default O365_SENDER is configured; otherwise a string beginning with "Error: " explaining what is misconfigured.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.7/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint and destructiveHint, but description adds detail on checking environment variables and the return format (success/error strings), providing behavior beyond annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Description is concise with two paragraphs, front-loaded with main purpose, and every sentence adds value without redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a zero-parameter diagnostic tool with annotations, the description fully explains behavior and return format, making it complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Input schema has zero parameters, so schema_description_coverage is 100%. Baseline for 0 params is 4, and description adds no parameter info which is unnecessary.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states the tool verifies OAuth2 configuration by acquiring an app-only token. It specifies what it does not do (no email send, no data read), distinguishing it from sibling tool office365_send_email.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly advises 'Use this first when diagnosing setup problems,' and clarifies that it performs no email send and reads no data, guiding when to use versus alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

TDQS

A4.6/5.0
Disambiguation5/5

The two tools serve entirely distinct purposes: one sends emails, the other verifies OAuth2 connectivity. There is no overlap or ambiguity.

Naming Consistency5/5

Both tools follow a consistent 'office365_verb_noun' pattern (send_email, test_connection), with no mixing of conventions.

Tool Count4/5

With only two tools, the server is extremely focused on sending emails and testing authentication. While this is appropriate for a minimal integration, it feels slightly under-scoped for a full Office 365 Email MCP.

Completeness2/5

The server only covers sending emails and connection testing, missing essential email operations like reading, searching, or managing folders. This is a significant gap for a service branded as 'Email MCP'.

Maintenance

ActivityStale
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables sending emails through Microsoft Outlook using the Microsoft Graph API. Provides the missing send-email capability for Agent Builder's Outlook connector with support for both delegated and app-only authentication flows.
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables AI agents to interact with Microsoft 365 Outlook Mail, allowing email operations via natural language.
    29
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables AI agents to manage Microsoft Outlook emails through the Microsoft Graph API, supporting operations like listing, reading, sending, and moving emails.
    MIT

Latest Blog Posts

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/cybrlou/office365-email-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server