mcp_tools.py•2.71 kB
"""MCP tools definitions for email operations"""
def get_mcp_tools():
"""Return list of available MCP tools"""
return [
{
"name": "send_email",
"description": "Send a single email using Mailjet",
"inputSchema": {
"type": "object",
"properties": {
"to_email": {
"type": "string",
"format": "email",
"description": "Recipient email address"
},
"to_name": {
"type": "string",
"description": "Recipient name"
},
"subject": {
"type": "string",
"description": "Email subject"
},
"text_content": {
"type": "string",
"description": "Plain text email content"
},
"html_content": {
"type": "string",
"description": "HTML email content (optional)"
},
"from_email": {
"type": "string",
"format": "email",
"description": "Sender email address"
},
"from_name": {
"type": "string",
"description": "Sender name"
},
"mailjet_api_key": {
"type": "string",
"description": "User's Mailjet API key"
},
"mailjet_secret_key": {
"type": "string",
"description": "User's Mailjet secret key"
}
},
"required": ["to_email", "subject", "text_content", "from_email", "from_name", "mailjet_api_key",
"mailjet_secret_key"]
}
}
]
async def handle_tool_call(tool_name: str, arguments: dict, mailjet_key: str, mailjet_secret: str):
"""Handle tool execution"""
from email_sender import EmailSender
if tool_name == "send_email":
sender = EmailSender(mailjet_key, mailjet_secret)
result = await sender.send_single_email(arguments)
return {
"content": [
{
"type": "text",
"text": f"✅ Email sent successfully to {arguments['to_email']}"
}
]
}
raise Exception(f"Unknown tool: {tool_name}")