SuperAPIAI Directory

sendgrid-mcp-secure

github.com · AI developer platforms

Security-focused SendGrid email sending with recipient/domain allowlists, send caps, review mode, an audit log and no silent BCC.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)
PlatformsAPI

About this tool

sendgrid-mcp-secure is a security-first MCP server based on the SendGrid v3 API, whose design goal is to structurally prevent postmark-mcp-style incidents—that is, malicious MCP packages silently BCCing every outgoing email to an attacker.

Purpose This project is intended for scenarios where AI agents need to send transactional email securely. It does not cover SendGrid's Marketing API (contacts, lists, marketing campaigns), and only covers transactional email, templates, suppression lists, statistics, and domain authentication.

Main capabilities

  • Two-phase sending: there is no direct send tool. preview_email validates and renders the exact email payload, returns it for inspection, and generates a one-time confirmation token (expires in 10 minutes). send_email only accepts that token and only sends the payload that was previewed. The fully rendered email always passes through the conversation before it is sent.
  • Dry-run by default: no network write operations are triggered until SENDGRID_MCP_MODE=live is set in the server environment. All tools work in dry-run mode, so the server can be evaluated before trusting the key. Read tools still query SendGrid—dry-run blocks writes, not traffic.
  • No BCC: BCC is not accepted as a parameter and is disabled by default at the server layer. BCC injection was the exfiltration channel of postmark-mcp.
  • Recipient allowlist (optional): restrict sending to specified addresses or @domains via server environment variables, immune to prompt injection in chat.
  • Write rate limiting: token bucket algorithm, default 20 write operations per hour.
  • Audit logging: each write-type operation appends a line of JSONL (timestamp, tool, recipients, mode, result).
  • Key isolation: the API key comes only from environment variables. No tool accepts, returns, or logs the key.
  • Single file, single dependency: the entire server is one server.py; the only third-party dependency is the official mcp SDK. Auditable in one reading.

How to use Claude Desktop / Claude Code / Cursor (via uv): first start in the default dry-run mode, observe the audit log and rendered previews, and switch to live after confirming its behavior. Or run from a clone: python3 server.py (stdio transport). It is recommended to use a SendGr with restricted scopeid API key (Mail Send plus the required read scope). The server never needs Full Access.

Self-check and trust verification The self-check runs offline, requires no key and no network, and contains 32 checks: golden test cases built around the payload, adversarial test cases targeting the exact failure modes this server is designed to prevent (blind send, allowlist bypass, token replay, forged tokens, rate-limit exhaustion, BCC injection), and an end-to-end preview→send flow built on the real tool functions. Output contract: every tool returns a JSON object; on failure it returns {"error": "..."} instead of throwing an exception, so the agent loop can degrade gracefully. trust.json is the machine-readable version of this repository's claims, and every claim carries a verify command block. For example: C1 self-check passes (python3 test_server.py, 32 checks, offline), C6 dry-run gates every write operation, C7 the API key never leaves the environment, G1 releases since 0.1.1 carry PEP 740 attestations (0.1.0 does not). You can verify these four first. known_gaps lists four things not yet implemented, with the same level of specificity as the claims, including: two-phase send is defense in depth and is not itself a human approval gate. capabilities limit the blast radius: one network destination (api.sendgrid.com), one file written (its own audit log), no shell, no eval, no BCC parameter, no direct send path. If a claim does not match its verification command, then the claim is wrong—please file an issue.

When to use it Suitable for scenarios where you want an agent to be able to send transactional email safely without constantly worrying about exfiltration. If you need marketing campaign management, use a marketing-focused server; if you need the agent to send directly without a confirmation gate, you can also choose another SendGrid MCP server.

Limitations

  • The confirmation token is returned to the calling model, so two-phase send is defense in depth and is not itself a human approval gate; it is recommended to pair it with client-side per-tool approval (each send_email call can be viewed and approved individually) and an allowlist for the strongest posture.
  • The Marketing API (contacts, lists, campaigns) is out of scope.
  • SendGrid's API evolves; endpoints were verified against the v3 documentation at release time.
  • The defensive nature of two-phase send has been described in known_gaps.

Additional information Questions, bug reports, security issues: file a GitHub issue or email heychopp@proton.me. For security reports, contacting by email first is welcome.

Up/Down to navigate · Enter to open · ESC to closeBrowse all tools