wip

link em
This commit is contained in:
zzstoatzz 2024-11-30 20:50:43 -06:00
commit c6e8de95b9

View file

@ -1,11 +1,14 @@
# /// script
# dependencies = ["fastmcp"]
# ///
"""
FastMCP Echo Server
"""
from typing import Annotated
import httpx
from pydantic import BeforeValidator
from pydantic_settings import BaseSettings, SettingsConfigDict
from fastmcp import FastMCP
@ -18,22 +21,21 @@ class SurgeSettings(BaseSettings):
api_key: str
account_id: str
my_phone_number: str
my_phone_number: Annotated[
str, BeforeValidator(lambda v: "+" + v if not v.startswith("+") else v)
]
my_first_name: str
my_last_name: str
# Create server
mcp = FastMCP("Text Me")
mcp = FastMCP("Text me")
surge_settings = SurgeSettings() # type: ignore
@mcp.tool(
name="text_me",
description="Send a text message to the number set as SURGE_MY_PHONE_NUMBER in the .env file",
)
@mcp.tool(name="textme", description="Send a text message to me")
def text_me(text_content: str) -> str:
"""Send a text message to a phone number"""
"""Send a text message to a phone number via https://surgemsg.com/"""
with httpx.Client() as client:
response = client.post(
"https://api.surgemsg.com/messages",
@ -54,4 +56,4 @@ def text_me(text_content: str) -> str:
},
)
response.raise_for_status()
return response.json()
return f"Message sent: {text_content}"