-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsms.py
More file actions
40 lines (33 loc) · 1.22 KB
/
sms.py
File metadata and controls
40 lines (33 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""SMS tools."""
import logging
from typing import Any
from fastmcp import Context # pylint: disable=import-error
from ..mcp_core import make_api_call, mcp
from ..memory_store import OPENAPI_HOST_PREFIX
logger = logging.getLogger(__name__)
logger.debug("module loaded")
@mcp.tool
async def send_sms(sender: str, body: str, mobile: str, ctx: Context) -> Any:
"""
Send an SMS to a mobile number using minus sign to separate international prefix from the number
Args:
sender: optional, can be a 11 char long string
body: the body of the message string
mobile: the recipient mobile number. Eg.:"+39-1234567890"
"""
# Ensure the mobile number has a '-' between the international prefix and the number
if mobile.startswith("+") and "-" not in mobile:
return {
"success": False,
"error": 111,
"message": (
"please use minus simbol to separate international prefix and "
"the number"
),
}
url = f"https://{OPENAPI_HOST_PREFIX}ws.messaggisms.com/messages/"
return make_api_call(ctx, "POST", url, json_payload={
"sender": sender,
"body": body,
"recipients": mobile
})