multi-provider smtp email sending with environment-based credential management
Sends emails through 9 pre-configured SMTP providers (Gmail, Outlook, Yahoo, QQ, 163, 126, Sina, Sohu, Aliyun) by resolving provider configurations from a static email.json file and loading credentials from environment variables. The implementation uses Python's smtplib with TLS/SSL encryption, supporting both single and multiple recipients with HTML/plain-text content negotiation. Credentials are never hardcoded; instead, the system expects environment variables named after the provider (e.g., GMAIL_PASSWORD, QQ_MAIL_PASSWORD) to be pre-loaded before server startup.
Unique: Implements a pre-configured provider registry (email.json) with environment-variable-based credential loading, eliminating the need for users to manage SMTP configuration details while supporting 9 distinct providers including Chinese email services (QQ, 163, 126, Sina, Sohu, Aliyun) that are rarely included in generic email libraries.
vs alternatives: Simpler than building custom SMTP integrations for each provider and more secure than alternatives that embed credentials in code, though less flexible than OAuth2-based solutions like SendGrid or Mailgun.
file-system attachment search with pattern matching
Searches a designated directory (specified via CLI --dir argument or environment variable) for files matching text patterns, enabling LLMs to discover and reference attachments before composing emails. The implementation uses Python's pathlib and fnmatch for recursive directory traversal and glob-style pattern matching, returning file paths and metadata (size, modification time) that can be passed to the send_email tool. The search directory is configurable at server startup and enforced as a security boundary to prevent directory traversal attacks.
Unique: Implements a sandboxed, directory-scoped file search mechanism that prevents directory traversal while exposing file metadata (size, modification time) to LLMs, enabling intelligent attachment selection without requiring users to manually specify file paths.
vs alternatives: More secure than unrestricted filesystem access and simpler than building a full document management system, though less powerful than full-text search or semantic file discovery.
mcp protocol tool exposure via dual server implementations
Exposes email and attachment-search capabilities through the Model Context Protocol (MCP) using two parallel server implementations: a standard MCP server (using mcp library) and a FastMCP variant (using fastmcp library). Both implementations expose identical tool definitions (list_tools, call_tool) and handle request/response serialization according to the MCP specification. The dual implementation pattern demonstrates different architectural approaches while maintaining API compatibility, allowing clients to choose based on performance or dependency preferences.
Unique: Provides two parallel MCP server implementations (standard and FastMCP) exposing identical tool interfaces, allowing clients to choose between different performance characteristics and dependency footprints while maintaining API compatibility.
vs alternatives: More flexible than single-implementation servers by offering architectural choice, though adds complexity compared to a single implementation approach.
environment-variable-based configuration with multi-source fallback
Loads email provider credentials and server configuration from environment variables with a multi-source fallback pattern: CLI arguments (highest priority) override environment variables, which override defaults from email.json. Provider configurations (SMTP host, port, TLS settings) are stored in a static email.json file, while credentials (username, password) are loaded from environment variables named after the provider (e.g., GMAIL_EMAIL, GMAIL_PASSWORD). The attachment directory can be specified via --dir CLI argument or ATTACHMENT_DIR environment variable. This pattern separates configuration (static) from secrets (dynamic) and enables secure deployment without embedding credentials in code or configuration files.
Unique: Implements a three-tier configuration hierarchy (CLI > environment variables > defaults) that separates static provider configurations (email.json) from dynamic credentials (environment variables), enabling secure deployment patterns where secrets are never stored in code or configuration files.
vs alternatives: More secure than hardcoded credentials and simpler than full configuration management systems like Consul or etcd, though less flexible than runtime configuration APIs.
pydantic-based request validation for email messages
Validates incoming email requests using Pydantic models (EmailMessage) that enforce type checking, required field validation, and optional field handling before passing data to SMTP operations. The validation layer catches malformed requests (missing recipients, invalid email addresses, oversized payloads) at the MCP tool boundary, preventing invalid data from reaching SMTP operations and providing clear error messages to clients. Pydantic's JSON schema generation also enables automatic tool definition generation for MCP clients.
Unique: Uses Pydantic models for request validation, enabling automatic JSON schema generation for MCP tool definitions and providing structured error messages without manual validation code.
vs alternatives: More maintainable than manual validation code and provides better IDE support than untyped dictionaries, though adds a dependency compared to built-in validation.
stdio-based mcp server transport with standard/fastmcp variants
Implements MCP server communication over stdin/stdout using either the standard mcp library or the fastmcp library, both of which handle JSON-RPC message serialization, request routing, and response formatting according to the MCP specification. The stdio transport enables the server to run as a subprocess of MCP clients (Claude Desktop, custom MCPClient), with all communication flowing through standard input/output streams. The dual implementation pattern (standard vs FastMCP) allows clients to choose between different performance characteristics and dependency footprints.
Unique: Provides dual stdio-based MCP server implementations (standard mcp and fastmcp libraries) that handle JSON-RPC message serialization transparently, enabling subprocess-based communication with MCP clients.
vs alternatives: Simpler than HTTP-based servers for local communication and more secure than network-exposed alternatives, though less scalable than server-based architectures.
attachment file validation and path sanitization
Validates attachment file paths before including them in emails by checking that files exist within the configured attachment directory, preventing directory traversal attacks and unauthorized file access. The implementation uses pathlib to resolve absolute paths and verify that resolved paths are within the allowed directory boundary. Files are validated at email send time, and only files within the configured directory tree are permitted; attempts to attach files outside this boundary are rejected with clear error messages.
Unique: Implements path validation using pathlib to ensure attachment files are within the configured directory boundary, preventing directory traversal attacks while maintaining clear error messages.
vs alternatives: More secure than unrestricted file access and simpler than full filesystem permission systems, though less flexible than OS-level access controls.
tls/ssl encryption for smtp connections
Establishes encrypted SMTP connections using TLS (port 587) or SSL (port 465) based on provider configuration, protecting email credentials and message content in transit. The implementation uses Python's smtplib with starttls() or implicit SSL, with provider-specific port and encryption settings defined in email.json. Certificate validation is performed by default, preventing man-in-the-middle attacks on SMTP connections.
Unique: Implements provider-specific TLS/SSL configuration from email.json, supporting both port 587 (STARTTLS) and port 465 (implicit SSL) encryption methods with automatic certificate validation.
vs alternatives: Standard SMTP security approach, though less flexible than alternatives supporting certificate pinning or custom validation logic.
+1 more capabilities