email-doc-sender 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -36
- package/dist/config/email.config.d.ts +14 -0
- package/dist/config/email.config.d.ts.map +1 -1
- package/dist/config/email.config.js +12 -26
- package/dist/config/email.config.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts +10 -0
- package/dist/services/converter.service.d.ts +53 -0
- package/dist/services/email.service.d.ts +59 -0
- package/dist/tools/send-email.d.ts +10 -0
- package/dist/types/index.d.ts +94 -0
- package/package.json +7 -2
package/README.md
CHANGED
|
@@ -12,17 +12,16 @@
|
|
|
12
12
|
|
|
13
13
|
## 安装
|
|
14
14
|
|
|
15
|
-
###
|
|
15
|
+
### Claude CLI (推荐)
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
|
-
|
|
18
|
+
claude mcp add email-doc-sender --scope user -- npx email-doc-sender@latest
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
###
|
|
21
|
+
### 全局安装
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
|
-
npm install email-doc-sender
|
|
25
|
-
npx email-doc-sender
|
|
24
|
+
npm install -g email-doc-sender
|
|
26
25
|
```
|
|
27
26
|
|
|
28
27
|
### 从源码安装
|
|
@@ -36,6 +35,8 @@ npm run build
|
|
|
36
35
|
|
|
37
36
|
## 配置
|
|
38
37
|
|
|
38
|
+
### 配置文件
|
|
39
|
+
|
|
39
40
|
创建配置文件 `~/.email-doc-sender/config.json`:
|
|
40
41
|
|
|
41
42
|
```json
|
|
@@ -51,49 +52,31 @@ npm run build
|
|
|
51
52
|
}
|
|
52
53
|
```
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
- `
|
|
57
|
-
- `
|
|
58
|
-
- `
|
|
59
|
-
- `
|
|
60
|
-
- `
|
|
55
|
+
### 环境变量 (可选,优先级更高)
|
|
56
|
+
|
|
57
|
+
- `EMAIL_SMTP_HOST` - SMTP 服务器地址
|
|
58
|
+
- `EMAIL_SMTP_PORT` - SMTP 端口
|
|
59
|
+
- `EMAIL_SMTP_SECURE` - 是否使用 SSL (true/false)
|
|
60
|
+
- `EMAIL_SMTP_USER` - 邮箱用户名
|
|
61
|
+
- `EMAIL_SMTP_PASS` - 邮箱密码或授权码
|
|
62
|
+
- `EMAIL_FROM` - 发件人邮箱地址
|
|
61
63
|
|
|
62
64
|
## 邮箱配置示例
|
|
63
65
|
|
|
64
66
|
### QQ 邮箱
|
|
65
67
|
- 获取授权码:设置 → 账户 → POP3/IMAP/SMTP/Exchange/CardDAV/CalDAV服务 → 生成授权码
|
|
68
|
+
- SMTP: `smtp.qq.com:587`, secure: false
|
|
66
69
|
|
|
67
70
|
### 163 邮箱
|
|
68
|
-
-
|
|
71
|
+
- SMTP: `smtp.163.com:465`, secure: true
|
|
69
72
|
|
|
70
73
|
### Gmail
|
|
71
74
|
- 需要启用[应用专用密码](https://support.google.com/accounts/answer/185833)
|
|
75
|
+
- SMTP: `smtp.gmail.com:587`, secure: false
|
|
72
76
|
|
|
73
|
-
##
|
|
74
|
-
|
|
75
|
-
**Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
76
|
-
**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
77
|
-
|
|
78
|
-
```json
|
|
79
|
-
{
|
|
80
|
-
"mcpServers": {
|
|
81
|
-
"email-doc-sender": {
|
|
82
|
-
"command": "node",
|
|
83
|
-
"args": ["C:/Users/yourname/AppData/Roaming/npm/email-doc-sender/dist/index.js"]
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
Windows 路径示例:
|
|
90
|
-
```json
|
|
91
|
-
"args": ["C:\Users\yourname\AppData\Roaming\npm\node_modules\email-doc-sender\dist\index.js"]
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
## 使用示例
|
|
77
|
+
## 使用
|
|
95
78
|
|
|
96
|
-
配置完成后重启 Claude
|
|
79
|
+
配置完成后重启 Claude,然后:
|
|
97
80
|
|
|
98
81
|
```
|
|
99
82
|
# 发送文字
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { EmailConfig, ValidationResult } from '../types/index.js';
|
|
2
|
+
export declare class ConfigManager {
|
|
3
|
+
private configPath;
|
|
4
|
+
private config;
|
|
5
|
+
constructor(configPath?: string);
|
|
6
|
+
load(): Promise<EmailConfig>;
|
|
7
|
+
validate(config: Partial<EmailConfig>): ValidationResult;
|
|
8
|
+
getConfig(): EmailConfig;
|
|
9
|
+
private isValidEmail;
|
|
10
|
+
static maskPassword(password: string): string;
|
|
11
|
+
logConfig(): void;
|
|
12
|
+
}
|
|
13
|
+
export declare function getConfigManager(configPath?: string): ConfigManager;
|
|
14
|
+
//# sourceMappingURL=email.config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email.config.d.ts","sourceRoot":"","sources":["../../src/config/email.config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"email.config.d.ts","sourceRoot":"","sources":["../../src/config/email.config.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAMvE,qBAAa,aAAa;IACxB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,MAAM,CAA4B;gBAE9B,UAAU,CAAC,EAAE,MAAM;IAIzB,IAAI,IAAI,OAAO,CAAC,WAAW,CAAC;IA2ClC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,gBAAgB;IA0BxD,SAAS,IAAI,WAAW;IAOxB,OAAO,CAAC,YAAY;IAKpB,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAK7C,SAAS,IAAI,IAAI;CAUlB;AAID,wBAAgB,gBAAgB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,aAAa,CAKnE"}
|
|
@@ -1,40 +1,26 @@
|
|
|
1
1
|
import { promises as fs } from 'fs';
|
|
2
2
|
import * as path from 'path';
|
|
3
|
-
import { fileURLToPath } from 'url';
|
|
4
3
|
import { homedir } from 'os';
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
// Config file search paths (in order of priority)
|
|
8
|
-
const CONFIG_PATHS = [
|
|
9
|
-
// User home directory (for npm global installs)
|
|
10
|
-
path.join(homedir(), '.email-doc-sender', 'config.json'),
|
|
11
|
-
// Project directory
|
|
12
|
-
path.join(PROJECT_ROOT, '.email-doc-sender.json'),
|
|
13
|
-
// Legacy project directory (development)
|
|
14
|
-
path.join(PROJECT_ROOT, '.spec-workflow', 'config', 'email-config.json'),
|
|
15
|
-
];
|
|
4
|
+
// Config file path
|
|
5
|
+
const CONFIG_PATH = path.join(homedir(), '.email-doc-sender', 'config.json');
|
|
16
6
|
export class ConfigManager {
|
|
17
7
|
configPath;
|
|
18
8
|
config = null;
|
|
19
9
|
constructor(configPath) {
|
|
20
|
-
this.configPath = configPath ||
|
|
10
|
+
this.configPath = configPath || CONFIG_PATH;
|
|
21
11
|
}
|
|
22
12
|
async load() {
|
|
23
13
|
let fileConfig = {};
|
|
24
|
-
// Try to load
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
catch (error) {
|
|
33
|
-
if (error.code !== 'ENOENT') {
|
|
34
|
-
throw new Error(`Invalid config file: ${configPath}`);
|
|
35
|
-
}
|
|
36
|
-
// Continue to next path
|
|
14
|
+
// Try to load config file
|
|
15
|
+
try {
|
|
16
|
+
const configContent = await fs.readFile(this.configPath, 'utf-8');
|
|
17
|
+
fileConfig = JSON.parse(configContent);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
if (error.code !== 'ENOENT') {
|
|
21
|
+
throw new Error(`Invalid config file: ${this.configPath}`);
|
|
37
22
|
}
|
|
23
|
+
// Config file not found, use defaults/env
|
|
38
24
|
}
|
|
39
25
|
// Environment variables (override file config)
|
|
40
26
|
const envHost = process.env.EMAIL_SMTP_HOST;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email.config.js","sourceRoot":"","sources":["../../src/config/email.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"email.config.js","sourceRoot":"","sources":["../../src/config/email.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAI7B,mBAAmB;AACnB,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,mBAAmB,EAAE,aAAa,CAAC,CAAC;AAE7E,MAAM,OAAO,aAAa;IAChB,UAAU,CAAS;IACnB,MAAM,GAAuB,IAAI,CAAC;IAE1C,YAAY,UAAmB;QAC7B,IAAI,CAAC,UAAU,GAAG,UAAU,IAAI,WAAW,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,IAAI;QACR,IAAI,UAAU,GAAyB,EAAE,CAAC;QAE1C,0BAA0B;QAC1B,IAAI,CAAC;YACH,MAAM,aAAa,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;YAClE,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QACzC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ,EAAE,CA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IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;CACF;AAED,IAAI,aAAa,GAAyB,IAAI,CAAC;AAE/C,MAAM,UAAU,gBAAgB,CAAC,UAAmB;IAClD,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,aAAa,GAAG,IAAI,aAAa,CAAC,UAAU,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,aAAa,CAAC;AACvB,CAAC"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D;;GAEG;AACH,KAAK,UAAU,IAAI;IACjB,IAAI,CAAC;QACH,kCAAkC;QAClC,OAAO,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;QAChD,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC;QACzC,MAAM,aAAa,CAAC,IAAI,EAAE,CAAC;QAE3B,uCAAuC;QACvC,aAAa,CAAC,SAAS,EAAE,CAAC;QAE1B,yBAAyB;QACzB,OAAO,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAC9C,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,MAAM,CAAC,6BAA6B,CAAC,CAAC;QACxE,MAAM,YAAY,GAAG,MAAM,eAAe,EAAE,CAAC;QAC7C,MAAM,WAAW,GAAG,MAAM,YAAY,CAAC,gBAAgB,EAAE,CAAC;QAE1D,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAO,CAAC,KAAK,CAAC,gGAAgG,CAAC,CAAC;QAClH,CAAC;aAAM,CAAC;Y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C,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,mBAAmB;AACnB,IAAI,EAAE,CAAC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Create and configure MCP server
|
|
4
|
+
*/
|
|
5
|
+
export declare function createServer(): Promise<Server>;
|
|
6
|
+
/**
|
|
7
|
+
* Start the MCP server with stdio transport
|
|
8
|
+
*/
|
|
9
|
+
export declare function startServer(server: Server): Promise<void>;
|
|
10
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { ConvertedDoc, DocFormat } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Document converter service
|
|
4
|
+
* Handles conversion between different document formats for email sending
|
|
5
|
+
*/
|
|
6
|
+
export declare class DocumentConverter {
|
|
7
|
+
constructor();
|
|
8
|
+
/**
|
|
9
|
+
* Convert document content to email-ready format
|
|
10
|
+
* @param content - The document content to convert
|
|
11
|
+
* @param format - The format of the input content
|
|
12
|
+
* @param filename - Required when format is 'attachment'
|
|
13
|
+
* @returns ConvertedDoc with HTML, text, and optional attachment
|
|
14
|
+
*/
|
|
15
|
+
convert(content: string, format: DocFormat, filename?: string): Promise<ConvertedDoc>;
|
|
16
|
+
/**
|
|
17
|
+
* Convert Markdown to HTML
|
|
18
|
+
*/
|
|
19
|
+
private convertMarkdown;
|
|
20
|
+
/**
|
|
21
|
+
* Validate and wrap HTML content
|
|
22
|
+
*/
|
|
23
|
+
private convertHtml;
|
|
24
|
+
/**
|
|
25
|
+
* Handle plain text content
|
|
26
|
+
*/
|
|
27
|
+
private convertText;
|
|
28
|
+
/**
|
|
29
|
+
* Handle attachment format
|
|
30
|
+
*/
|
|
31
|
+
private convertAttachment;
|
|
32
|
+
/**
|
|
33
|
+
* Wrap HTML content in email-friendly container
|
|
34
|
+
*/
|
|
35
|
+
private wrapEmailHtml;
|
|
36
|
+
/**
|
|
37
|
+
* Basic HTML validation
|
|
38
|
+
*/
|
|
39
|
+
private validateHtml;
|
|
40
|
+
/**
|
|
41
|
+
* Convert HTML to plain text (fallback)
|
|
42
|
+
*/
|
|
43
|
+
private htmlToPlainText;
|
|
44
|
+
/**
|
|
45
|
+
* Escape HTML special characters
|
|
46
|
+
*/
|
|
47
|
+
private escapeHtml;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get or create the singleton DocumentConverter instance
|
|
51
|
+
*/
|
|
52
|
+
export declare function getDocumentConverter(): DocumentConverter;
|
|
53
|
+
//# sourceMappingURL=converter.service.d.ts.map
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { EmailConfig, EmailOptions, EmailResult, ConvertedDoc } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Email sending service
|
|
4
|
+
* Handles SMTP connection and email sending with retry logic
|
|
5
|
+
*/
|
|
6
|
+
export declare class EmailService {
|
|
7
|
+
private transporter;
|
|
8
|
+
private config;
|
|
9
|
+
constructor(config: EmailConfig);
|
|
10
|
+
/**
|
|
11
|
+
* Create nodemailer transporter with SMTP config
|
|
12
|
+
*/
|
|
13
|
+
private createTransporter;
|
|
14
|
+
/**
|
|
15
|
+
* Send email with retry logic (exponential backoff)
|
|
16
|
+
* @param options - Email sending options
|
|
17
|
+
* @param maxRetries - Maximum number of retry attempts (default: 3)
|
|
18
|
+
* @returns EmailResult with success status and message ID
|
|
19
|
+
*/
|
|
20
|
+
send(options: EmailOptions, maxRetries?: number): Promise<EmailResult>;
|
|
21
|
+
/**
|
|
22
|
+
* Send converted document
|
|
23
|
+
* @param to - Recipient email address
|
|
24
|
+
* @param subject - Email subject
|
|
25
|
+
* @param doc - Converted document
|
|
26
|
+
* @returns EmailResult
|
|
27
|
+
*/
|
|
28
|
+
sendDocument(to: string, subject: string, doc: ConvertedDoc): Promise<EmailResult>;
|
|
29
|
+
/**
|
|
30
|
+
* Verify SMTP connection
|
|
31
|
+
* @returns true if connection successful
|
|
32
|
+
*/
|
|
33
|
+
verifyConnection(): Promise<boolean>;
|
|
34
|
+
/**
|
|
35
|
+
* Check if error is authentication related
|
|
36
|
+
*/
|
|
37
|
+
private isAuthError;
|
|
38
|
+
/**
|
|
39
|
+
* Get safe error message (don't expose sensitive info)
|
|
40
|
+
*/
|
|
41
|
+
private getSafeErrorMessage;
|
|
42
|
+
/**
|
|
43
|
+
* Sleep for specified milliseconds
|
|
44
|
+
*/
|
|
45
|
+
private sleep;
|
|
46
|
+
/**
|
|
47
|
+
* Recreate transporter (e.g., after config change)
|
|
48
|
+
*/
|
|
49
|
+
recreateTransporter(config: EmailConfig): void;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Get or create the singleton EmailService instance
|
|
53
|
+
*/
|
|
54
|
+
export declare function getEmailService(): Promise<EmailService>;
|
|
55
|
+
/**
|
|
56
|
+
* Reset the singleton instance (for testing)
|
|
57
|
+
*/
|
|
58
|
+
export declare function resetEmailService(): void;
|
|
59
|
+
//# sourceMappingURL=email.service.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
export declare const sendEmailTool: Tool;
|
|
3
|
+
export declare function handleSendEmail(params: Record<string, unknown>): Promise<{
|
|
4
|
+
content: Array<{
|
|
5
|
+
type: 'text';
|
|
6
|
+
text: string;
|
|
7
|
+
}>;
|
|
8
|
+
isError?: boolean;
|
|
9
|
+
}>;
|
|
10
|
+
//# sourceMappingURL=send-email.d.ts.map
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Document format types supported by the email service
|
|
3
|
+
*/
|
|
4
|
+
export type DocFormat = 'markdown' | 'html' | 'text' | 'attachment';
|
|
5
|
+
/**
|
|
6
|
+
* Email server configuration for SMTP connection
|
|
7
|
+
*/
|
|
8
|
+
export interface EmailConfig {
|
|
9
|
+
/** SMTP server hostname (e.g., smtp.gmail.com) */
|
|
10
|
+
host: string;
|
|
11
|
+
/** SMTP server port (usually 465 for SSL, 587 for TLS) */
|
|
12
|
+
port: number;
|
|
13
|
+
/** Whether to use SSL/TLS for secure connection */
|
|
14
|
+
secure: boolean;
|
|
15
|
+
/** SMTP authentication credentials */
|
|
16
|
+
auth: {
|
|
17
|
+
/** Email account username */
|
|
18
|
+
user: string;
|
|
19
|
+
/** Email password or app-specific password */
|
|
20
|
+
pass: string;
|
|
21
|
+
};
|
|
22
|
+
/** Default sender email address */
|
|
23
|
+
from: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Parameters for sending an email with document content
|
|
27
|
+
*/
|
|
28
|
+
export interface SendEmailParams {
|
|
29
|
+
/** Recipient email address (required) */
|
|
30
|
+
to: string;
|
|
31
|
+
/** Email subject line (required) */
|
|
32
|
+
subject: string;
|
|
33
|
+
/** Document content to send (required) */
|
|
34
|
+
content: string;
|
|
35
|
+
/** Format of the document content (required) */
|
|
36
|
+
format: DocFormat;
|
|
37
|
+
/** Attachment filename (required when format='attachment') */
|
|
38
|
+
filename?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Result of an email send operation
|
|
42
|
+
*/
|
|
43
|
+
export interface EmailResult {
|
|
44
|
+
/** Whether the email was sent successfully */
|
|
45
|
+
success: boolean;
|
|
46
|
+
/** SMTP message ID if successful */
|
|
47
|
+
messageId?: string;
|
|
48
|
+
/** Error message if failed */
|
|
49
|
+
error?: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Converted document ready for email sending
|
|
53
|
+
*/
|
|
54
|
+
export interface ConvertedDoc {
|
|
55
|
+
/** HTML content for email body */
|
|
56
|
+
html: string;
|
|
57
|
+
/** Plain text fallback content */
|
|
58
|
+
text: string;
|
|
59
|
+
/** Attachment data if format='attachment' */
|
|
60
|
+
attachment?: {
|
|
61
|
+
/** Attachment filename */
|
|
62
|
+
filename: string;
|
|
63
|
+
/** Attachment content as buffer */
|
|
64
|
+
content: Buffer;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Email sending options (internal)
|
|
69
|
+
*/
|
|
70
|
+
export interface EmailOptions {
|
|
71
|
+
/** Recipient address */
|
|
72
|
+
to: string;
|
|
73
|
+
/** Email subject */
|
|
74
|
+
subject: string;
|
|
75
|
+
/** HTML body content */
|
|
76
|
+
html?: string;
|
|
77
|
+
/** Plain text body content */
|
|
78
|
+
text?: string;
|
|
79
|
+
/** Attachments */
|
|
80
|
+
attachments?: Array<{
|
|
81
|
+
filename: string;
|
|
82
|
+
content: Buffer;
|
|
83
|
+
}>;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Configuration validation result
|
|
87
|
+
*/
|
|
88
|
+
export interface ValidationResult {
|
|
89
|
+
/** Whether configuration is valid */
|
|
90
|
+
valid: boolean;
|
|
91
|
+
/** Validation errors if invalid */
|
|
92
|
+
errors: string[];
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=index.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "email-doc-sender",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "MCP server for sending generated documents to email",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -36,5 +36,10 @@
|
|
|
36
36
|
},
|
|
37
37
|
"engines": {
|
|
38
38
|
"node": ">=18.0.0"
|
|
39
|
-
}
|
|
39
|
+
},
|
|
40
|
+
"files": [
|
|
41
|
+
"dist",
|
|
42
|
+
"README.md",
|
|
43
|
+
"LICENSE"
|
|
44
|
+
]
|
|
40
45
|
}
|