mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-09 07:09:11 +02:00
update example
This commit is contained in:
parent
ff829f7826
commit
1b2c9cbc67
2 changed files with 13 additions and 3 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -9,6 +9,7 @@ wheels/
|
|||
# Virtual environments
|
||||
.venv
|
||||
.DS_Store
|
||||
.env
|
||||
|
||||
|
||||
src/fastmcp/_version.py
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ class SurgeSettings(BaseSettings):
|
|||
api_key: str
|
||||
account_id: str
|
||||
my_phone_number: str
|
||||
my_first_name: str
|
||||
my_last_name: str
|
||||
|
||||
|
||||
# Create server
|
||||
|
|
@ -26,21 +28,28 @@ mcp = FastMCP("Text Me")
|
|||
surge_settings = SurgeSettings() # type: ignore
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
@mcp.tool(
|
||||
name="text_me",
|
||||
description="Send a text message to the number set as SURGE_MY_PHONE_NUMBER in the .env file",
|
||||
)
|
||||
def text_me(text_content: str) -> str:
|
||||
"""Send a text message to a phone number"""
|
||||
with httpx.Client() as client:
|
||||
response = client.post(
|
||||
"https://api.surgemsg.com/messages",
|
||||
headers={
|
||||
"Authorization": surge_settings.api_key,
|
||||
"Authorization": f"Bearer {surge_settings.api_key}",
|
||||
"Surge-Account": surge_settings.account_id,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
json={
|
||||
"body": text_content,
|
||||
"conversation": {
|
||||
"contact": {"phone_number": surge_settings.my_phone_number}
|
||||
"contact": {
|
||||
"first_name": surge_settings.my_first_name,
|
||||
"last_name": surge_settings.my_last_name,
|
||||
"phone_number": surge_settings.my_phone_number,
|
||||
}
|
||||
},
|
||||
},
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue