SendGrid MCP Server
Enables comprehensive email marketing and transactional email operations through SendGrid's API v3. Supports contact management, campaign creation, email automation, list management, and email sending with built-in read-only safety mode.
README
SendGrid MCP Server
A Model Context Protocol (MCP) server that provides comprehensive access to SendGrid's API v3 for email marketing and transactional email operations.
Features
- Marketing Automations: Create and manage email automation workflows
- Single Send Campaigns: Manage one-time email campaigns
- Contact Management: Handle email lists, segments, and contacts
- Mail Sending: Send transactional emails via SendGrid
- Suppression Lists: Manage bounces, spam reports, and unsubscribes
- Account Settings: Access account details and configuration
- Browser Integration: Quick links to SendGrid web interface
Quick Start
1. Installation
git clone <repository-url>
cd sendgrid-mcp
npm install
2. Environment Setup
# Copy the example environment file
cp .env.example .env
# Edit .env with your SendGrid API key
nano .env
3. Get SendGrid API Key
- Go to SendGrid API Keys
- Click "Create API Key"
- Choose "Full Access" or select specific permissions
- Copy the generated key (starts with
SG.)
4. Configure Environment
Edit .env file:
# Required: Your SendGrid API key
SENDGRID_API_KEY=SG.your_actual_api_key_here
# Optional: Server configuration
MCP_SERVER_NAME=sendgrid-mcp
MCP_SERVER_VERSION=1.0.0
LOG_LEVEL=info
REQUEST_TIMEOUT=30000
5. Build and Run
# Build the server
npm run build
# Run the server
./build/index.js
MCP Integration
Claude Desktop
Add this server to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"sendgrid": {
"command": "node",
"args": ["/path/to/sendgrid-mcp/build/index.js"],
"env": {
"SENDGRID_API_KEY": "SG.your_api_key_here",
"READ_ONLY": "true"
}
}
}
}
Other MCP-Compatible AI Agents
For other AI agents that support MCP, use these connection details:
# Direct execution
node /path/to/sendgrid-mcp/build/index.js
# With environment variables
SENDGRID_API_KEY="SG.your_api_key_here" READ_ONLY="true" node /path/to/sendgrid-mcp/build/index.js
Cline (VS Code Extension)
Add to your Cline MCP configuration:
{
"mcpServers": {
"sendgrid": {
"command": "node",
"args": ["/path/to/sendgrid-mcp/build/index.js"],
"env": {
"SENDGRID_API_KEY": "SG.your_api_key_here",
"READ_ONLY": "true"
}
}
}
}
Important Notes:
- Replace
/path/to/sendgrid-mcp/with the actual absolute path to your project - Replace
SG.your_api_key_herewith your actual SendGrid API key - Restart Claude Desktop or your AI agent after updating the configuration
- Ensure the server builds successfully with
npm run buildbefore configuring
Environment Variables
| Variable | Required | Description | Default |
|---|---|---|---|
SENDGRID_API_KEY |
✅ | Your SendGrid API key (starts with SG.) | - |
MCP_SERVER_NAME |
❌ | Server name for identification | sendgrid-mcp |
MCP_SERVER_VERSION |
❌ | Server version | 1.0.0 |
LOG_LEVEL |
❌ | Logging level (debug, info, warn, error) | info |
REQUEST_TIMEOUT |
❌ | API request timeout in milliseconds | 30000 |
READ_ONLY |
❌ | Enable read-only mode (true/false) | true |
Read-Only Mode
By default, the SendGrid MCP server runs in read-only mode (READ_ONLY=true) for safety. All tools are registered and available, but mutable operations are blocked at runtime with helpful error messages.
How Read-Only Mode Works
When READ_ONLY=true (default):
- All tools are registered and visible to the AI assistant
- Non-mutating operations work normally (list, get, search, open browser links)
- Mutating operations are blocked with a clear error message:
❌ Operation blocked: Server is running in READ_ONLY mode. Set READ_ONLY=false in your environment to enable write operations.
Read-Only Safe Operations
These operations work normally when READ_ONLY=true:
Contact Operations:
list_contacts,get_contact,search_contacts,search_contacts_by_emails
List Operations:
list_email_lists,list_segments
Field Operations:
list_custom_fields
Sender Operations:
list_senders
Campaign & Automation Operations:
list_automations,list_single_sendsopen_automation_creator,open_automation_editoropen_single_send_creator,open_single_send_stats
Utility Operations:
get_scopes,open_segment_creator,open_csv_uploader
Blocked Operations in Read-Only Mode
These operations are blocked when READ_ONLY=true:
create_contact,update_contact,delete_contactcreate_contact_with_lists,remove_contact_from_listscreate_email_list,update_email_list,delete_email_listcreate_custom_field,update_custom_field,delete_custom_fieldcreate_sender,delete_senderupdate_segment,delete_segmentsend_mail
Full Access Mode
To enable create, update, delete, and send operations, set READ_ONLY=false in your .env file:
READ_ONLY=false
This will allow all mutating operations to execute normally while maintaining all read operations.
⚠️ Security Note: Only disable read-only mode if you need write access and trust the environment where the server is running.
Available Tools
Marketing Automations
list_automations- List all marketing automationsopen_automation_creator- Open automation creator in browseropen_automation_editor- Open specific automation editor
Single Send Campaigns
list_single_sends- List all single send campaignsopen_single_send_creator- Open campaign creator in browseropen_single_send_stats- View campaign statistics
Contact Management
Contact CRUD Operations
list_contacts- List all contacts with paginationget_contact- Get detailed information about a specific contactcreate_contact- Create new contactsupdate_contact- Update existing contact informationdelete_contact- Delete contacts permanentlysearch_contacts- Search for contacts using query conditionssearch_contacts_by_emails- Search for specific contacts by email addresses
List Management
list_email_lists- List all email listscreate_email_list- Create a new email listupdate_email_list- Update email list propertiesdelete_email_list- Delete an email listcreate_contact_with_lists- Create contacts and assign to listsremove_contact_from_lists- Remove contacts from a specific list
Segments & Custom Fields
list_segments- List segments with parent relationshipsopen_segment_creator- Open segment creator in browserupdate_segment- Update existing segment name or query criteriadelete_segment- Delete an existing segmentlist_custom_fields- List custom field definitionscreate_custom_field- Create new custom fieldsupdate_custom_field- Update existing custom field definitionsdelete_custom_field- Delete custom field definitions
Senders & Import
list_senders- List verified sender identitiescreate_sender- Create new sender identitydelete_sender- Delete a verified sender identityopen_csv_uploader- Open CSV upload interface
Mail Sending
send_mail- Send transactional emailsget_scopes- Get available API permission scopes
Available Resources
sendgrid://automations- Marketing automations datasendgrid://singlesends- Single send campaigns datasendgrid://lists- Email lists datasendgrid://contacts- Contact segments datasendgrid://suppressions- Suppression lists (bounces, spam, etc.)sendgrid://account- Account profile information
Available Prompts
sendgrid_automation_help- Get help with marketing automationssendgrid_campaign_help- Get help with single send campaignssendgrid_contacts_help- Get help with comprehensive contact managementsendgrid_list_management_help- Get help with email list CRUD operationssendgrid_update_list_help- Get help with updating/renaming email listssendgrid_contact_crud_help- Get help with contact create/read/update/delete operationssendgrid_custom_fields_help- Get help with custom field definitions managementsendgrid_segment_management_help- Get help with managing dynamic contact segmentssendgrid_sender_management_help- Get help with sender identity managementsendgrid_suppressions_help- Get help with suppression listssendgrid_settings_help- Get help with account settingssendgrid_mail_send_help- Get help with sending emails
Examples
Send a Simple Email
{
"tool": "send_mail",
"arguments": {
"personalizations": [
{
"to": [{"email": "recipient@example.com", "name": "John Doe"}],
"subject": "Hello from SendGrid MCP!"
}
],
"from": {"email": "sender@yourdomain.com", "name": "Your Name"},
"content": [
{
"type": "text/plain",
"value": "Hello! This email was sent via SendGrid MCP server."
}
]
}
}
Create a New Contact
{
"tool": "create_contact",
"arguments": {
"contacts": [
{
"email": "newuser@example.com",
"first_name": "Jane",
"last_name": "Smith"
}
]
}
}
Search for Contacts by Email
{
"tool": "search_contacts_by_emails",
"arguments": {
"emails": ["john@example.com", "jane@example.com"]
}
}
Search Contacts with Query Conditions
{
"tool": "search_contacts",
"arguments": {
"query": "email LIKE '@example.com'",
"page_size": 10
}
}
Update Contact Information
{
"tool": "update_contact",
"arguments": {
"contacts": [
{
"id": "contact_id_here",
"first_name": "John",
"last_name": "Updated"
}
]
}
}
Delete Contacts
{
"tool": "delete_contact",
"arguments": {
"contact_ids": ["contact_id_1", "contact_id_2"]
}
}
Remove Contacts from a List
{
"tool": "remove_contact_from_lists",
"arguments": {
"list_id": "list_id_here",
"contact_ids": ["contact_id_1", "contact_id_2"]
}
}
Delete a Sender Identity
{
"tool": "delete_sender",
"arguments": {
"sender_id": "sender_id_here"
}
}
Update an Email List
{
"tool": "update_email_list",
"arguments": {
"list_id": "list_id_here",
"name": "Updated List Name"
}
}
Delete an Email List
{
"tool": "delete_email_list",
"arguments": {
"list_id": "list_id_here"
}
}
Create a Custom Field
{
"tool": "create_custom_field",
"arguments": {
"name": "customer_tier",
"field_type": "Text"
}
}
Update a Custom Field
{
"tool": "update_custom_field",
"arguments": {
"field_id": "field_id_here",
"name": "customer_level"
}
}
Delete a Custom Field
{
"tool": "delete_custom_field",
"arguments": {
"field_id": "field_id_here"
}
}
List Email Lists
{
"tool": "list_email_lists",
"arguments": {
"page_size": 100
}
}
Update a Segment
{
"tool": "update_segment",
"arguments": {
"segment_id": "segment_id_here",
"name": "Updated Segment Name"
}
}
Update Segment Query Criteria
{
"tool": "update_segment",
"arguments": {
"segment_id": "segment_id_here",
"query_dsl": "{\"and\": [{\"field\": \"email\", \"value\": \"@example.com\", \"operator\": \"like\"}]}"
}
}
Delete a Segment
{
"tool": "delete_segment",
"arguments": {
"segment_id": "segment_id_here"
}
}
Development
Project Structure
src/
├── index.ts # Main entry point
├── shared/ # Shared utilities
│ ├── auth.ts # Authentication
│ ├── api.ts # SendGrid API client
│ ├── env.ts # Environment validation
│ └── types.ts # Shared types
├── tools/ # Tool definitions
│ ├── automations.ts # Automation tools
│ ├── campaigns.ts # Campaign tools
│ ├── contacts.ts # Contact tools
│ ├── mail.ts # Mail sending tools
│ └── misc.ts # Miscellaneous tools
├── resources/ # Resource definitions
│ └── sendgrid.ts # SendGrid resources
└── prompts/ # Prompt definitions
└── help.ts # Help prompts
Adding New Tools
- Add tool definition to appropriate file in
src/tools/ - Export from
src/tools/index.ts - Tool will be automatically registered
Building
npm run build
Scripts
npm run build- Build the TypeScript projectnpm start- Run the built server
Troubleshooting
Common Issues
-
Invalid API Key
- Ensure your API key starts with
SG. - Verify the key has necessary permissions
- Check for typos in
.envfile
- Ensure your API key starts with
-
Environment Validation Errors
- Check all required variables are set
- Verify variable names match exactly
- Ensure no extra spaces or quotes
-
Permission Errors
- Your API key might not have sufficient permissions
- Create a new key with "Full Access" or required scopes
Getting Help
- Use the built-in help prompts (e.g.,
sendgrid_automation_help) - Check SendGrid's API documentation
- Review the
.env.examplefile for configuration reference
License
This project is licensed under the ISC License.
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
Support
For issues related to:
- SendGrid API: Check SendGrid Documentation
- MCP Protocol: Check Model Context Protocol
- This Server: Open an issue in this repository
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.