Skip to main content
SE

SendGrid

v0.2.1API Key

Email (transactional + marketing), Twilio-owned. Completes channel coverage: Twilio handles SMS/WhatsApp/Voice, SendGrid handles email. Send mail, templates, contacts CRUD, suppressions, stats.

20 tools2 env vars🌐 GLOBALstable on npm

What your agent can do

SendGrid gives your agent 20 tools it calls directly β€” pick the ones it needs, in Claude, Cursor, or any MCP client.

  • send_mail β€” Send an email via POST /mail/send. Supply at least one `personalization` with `to` recipients, a `from` address (falls back to SENDGRID_FROM_EMAIL), and either `content` blocks or a `template_id` with `dynamic_template_data`. Returns 202 on success.
  • send_template β€” Convenience wrapper for POST /mail/send with a dynamic template. Equivalent to send_mail with `template_id` set. Supply `to`, `template_id`, and `dynamic_template_data`; content is rendered from the template.
  • add_contact β€” Upsert contacts in Marketing Campaigns via PUT /marketing/contacts. Matches on email. Returns a job_id β€” ingestion is async. Optionally assign to list_ids.
Example call
// Your agent calls a tool directly β€” no glue code.
// CodeSpar's managed tier handles OAuth2, token rotation and rate limits.
const result = await session.call("send_mail", { /* ... */ });

Install

terminal
$ npm install @codespar/mcp-sendgrid

Quickstart

Add this entry to your claude_desktop_config.json (or any MCP-compatible client config).

claude_desktop_config.json
{
  "mcpServers": {
    "sendgrid": {
      "command": "npx",
      "args": [
        "-y",
        "@codespar/mcp-sendgrid"
      ],
      "env": {
        "SENDGRID_API_KEY": "<your_sendgrid_api_key>"
      }
    }
  }
}

After restart, your agent can call any of the 20 tools below β€” try send_mail first.

Environment variables Β· 2

Required to authenticate the server. Stored encrypted when using CodeSpar managed hosting.

SENDGRID_API_KEY
requiredsecret

SendGrid API key. Used as Bearer token in the Authorization header.

SENDGRID_FROM_EMAIL
optional

Optional default From address used by send_mail / send_template when `from.email` is omitted. Must be a Verified Sender or authenticated domain.

Available tools Β· 20

Each tool is independent β€” your agent loads only what it needs to reduce context and response time.

WRITEsend_mail
Send an email via POST /mail/send. Supply at least one `personalization` with `to` recipients, a `from` address (falls back to SENDGRID_FROM_EMAIL), and either `content` blocks or a `template_id` with `dynamic_template_data`. Returns 202 on success.
WRITEsend_template
Convenience wrapper for POST /mail/send with a dynamic template. Equivalent to send_mail with `template_id` set. Supply `to`, `template_id`, and `dynamic_template_data`; content is rendered from the template.
WRITEadd_contact
Upsert contacts in Marketing Campaigns via PUT /marketing/contacts. Matches on email. Returns a job_id β€” ingestion is async. Optionally assign to list_ids.
READlist_contacts
List Marketing Campaigns contacts via GET /marketing/contacts. Returns up to 50 sample contacts; for full export use a Contacts Export job.
DELETEdelete_contact
Delete contacts by id via DELETE /marketing/contacts?ids=.... Pass a comma-separated list of contact UUIDs, or set delete_all_contacts=true to wipe all contacts (irreversible).
READsearch_contacts
Search contacts with an SGQL query via POST /marketing/contacts/search. Example: `email LIKE '%@codespar.com' AND CONTAINS(list_ids, 'abc-123')`.
READget_contact
Retrieve a single Marketing Campaigns contact by id via GET /marketing/contacts/{id}. Returns full contact record including custom fields and list_ids.
READlist_lists
List all Marketing Campaigns contact lists via GET /marketing/lists. Returns list UUIDs, names, and contact_count. Supports pagination.

Compatible frameworks

MCP is a protocol β€” any framework that speaks it can mount this server.

Claude Agent SDKAnthropic
OpenAI AgentsOpenAI
Vercel AI SDKVercel
LangChainLangChain
LlamaIndexLlamaIndex
CrewAICrewAI
MastraMastra
Any MCP clientProtocol

Frequently asked questions

Run `npx -y @codespar/mcp-sendgrid` and add the config block above to your MCP client β€” Claude, Cursor, VS Code, or any MCP-compatible client. No build step, no SDK required. Prefer hosted? CodeSpar's managed tier runs it for you with auth handled.
SendGrid β€” MCP server Β· 20 tools | CodeSpar