npm package: @smcphub/email
Description: A MCP Server for email management assistant by SMCPHUB
Author: SMCPHUB
Latest version: 0.0.12

# @smcphub/email

![Version](https://img.shields.io/badge/version-0.0.1-blue.svg?cacheSeconds=2592000)
[![License: Apache-2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](#)

> SMCPHub Email Toolkit.

SMCPHub Email is an email account and management toolkit based on the MCP protocol. It supports IMAP/SMTP account CRUD, email sending/receiving, body extraction, template management, signature management, and more.

### 🏠 [Homepage](https://smcphub.com)

## Install

Use the official MCP server to integrate this toolkit service:

```sh
npm i @smcphub/server
```
OR
```sh
yarn add @smcphub/server
```

## MCP Server configuration

```json
{
  "mcpServers": {
    "smcphub-server": {
      "command": "npx",
      "args": ["-y", "@smcphub/server@latest"],
      "env": {
        "SMCPHUB_API_KEY": "your api key",
      }
    }
  }
}
```

You can get your API Key from the [API Key Page](https://www.smcphub.com/user/api-key).

## Usage

Use the official MCP Client to connect to this toolkit service:

```js
// import the SDK
import SmcphubClient from '@smcphub/client';

// Instantiate the client
const smcphubClient = new SmcphubClient({
    api_key: 'your-api-key'
});

// Connect the MCP Server
smcphubClient
.connect()
.then(tools => {
    console.log(tools);
})
.catch(err => {
  console.error(err);
});
    
// Call the tool
smcphubClient
.callTool('getEmailAccounts', {})
.then(content => {
    console.log(content);
})
.catch(err => {
  console.error(err);
});
```

- You must set the `SMCPHUB_API_KEY` environment variable for authentication.

## Tool List

### upsertEmailAccount
Add or update an email account, supporting IMAP/SMTP configuration
- provider: Email provider identifier, e.g. gmail, qq, 163, etc.
- name: Email account name
- email: Email address
- config: Email configuration, supports IMAP/SMTP
  - imap: IMAP config (required)
    - host: IMAP server address
    - port: IMAP port, default 993
    - secure: IMAP SSL enabled
    - user: IMAP login username
    - password: IMAP login password
  - smtp: SMTP config (required)
    - host: SMTP server address
    - port: SMTP port, default 465
    - secure: SMTP SSL enabled
    - user: SMTP login username
    - password: SMTP login password
- is_active: Whether the account is active (optional)

### deleteEmailAccount
Delete an email account, supports deletion by accountId or email
- accountId: Account ID (optional)
- email: Email address (optional)

### getEmailAccounts
Get email accounts, supports query by accountId or email, or get all accounts
- accountId: Account ID (optional)
- email: Email address (optional)

### fetchAndSaveEmails
Automatically fetch and save new emails (IMAP/SMTP supported)

### sendEmail
Send email (IMAP/SMTP supported)
- to: Recipient email(s), comma separated
- subject: Email subject
- text: Email body (plain text, optional)
- html: Email body (HTML, optional)
- cc: CC email(s), comma separated (optional)
- bcc: BCC email(s), comma separated (optional)
- attachments: Attachments list (optional)
- accountId: Sender account ID (optional)
- email: Sender email address (optional)

### extractBodyFromText
Extract clean body (remove quoted content)
- text: Raw email body text

### formatEmailContent
Format email content according to a template (supports LLM formatting)
- emailId: Email ID
- templateId: Template ID

### getFormattedEmails
Get formatted emails (pagination, search, join attachments)
- page: Page number (optional, default 1)
- pageSize: Page size (optional, default 20)
- to: Filter by recipient email (optional)
- cc: Filter by CC email (optional)
- bcc: Filter by BCC email (optional)
- subject: Filter by subject (optional)
- account_id: Filter by account ID (optional)
- email: Filter by email address (optional)

### addTemplate
Add email template (send/reply)
- name: Template name
- content: Template content
- type: Template type (optional, send for sending, reply for replying)

### createNotification
Create notification (accepts type, title, content, priority, extra_data)
- type: Notification type
- title: Notification title (optional)
- content: Notification content (optional)
- priority: Priority (optional)
- extra_data: Extra data (optional)

### addOrUpdateSignature
Add or update signature (find account by accountId or email and update config.signature)
- accountId: Account ID (optional)
- email: Email address (optional)
- signature: Signature content

### getAllRecipients
Get all recipients of a specific email
- emailId: Email ID

### getAllTemplates
Get all email templates

### updateEmailAccountConfig
Update email account config (imap/smtp), supports accountId or email
- accountId: Account ID (optional)
- email: Email address (optional)
- config: Config object to update

### markEmailAsRead
Mark email as read
- emailIds: Email IDs

## Author

👤 [**SMCPHUB**](https://smcphub.com)

## License

Apache-2.0