zzstoatzz commited on
Commit
3958a11
·
1 Parent(s): 31f3ae5

update example

Browse files
Files changed (2) hide show
  1. .gitignore +1 -0
  2. examples/text_me.py +12 -3
.gitignore CHANGED
@@ -9,6 +9,7 @@ wheels/
9
  # Virtual environments
10
  .venv
11
  .DS_Store
 
12
 
13
 
14
  src/fastmcp/_version.py
 
9
  # Virtual environments
10
  .venv
11
  .DS_Store
12
+ .env
13
 
14
 
15
  src/fastmcp/_version.py
examples/text_me.py CHANGED
@@ -19,6 +19,8 @@ class SurgeSettings(BaseSettings):
19
  api_key: str
20
  account_id: str
21
  my_phone_number: str
 
 
22
 
23
 
24
  # Create server
@@ -26,21 +28,28 @@ mcp = FastMCP("Text Me")
26
  surge_settings = SurgeSettings() # type: ignore
27
 
28
 
29
- @mcp.tool()
 
 
 
30
  def text_me(text_content: str) -> str:
31
  """Send a text message to a phone number"""
32
  with httpx.Client() as client:
33
  response = client.post(
34
  "https://api.surgemsg.com/messages",
35
  headers={
36
- "Authorization": surge_settings.api_key,
37
  "Surge-Account": surge_settings.account_id,
38
  "Content-Type": "application/json",
39
  },
40
  json={
41
  "body": text_content,
42
  "conversation": {
43
- "contact": {"phone_number": surge_settings.my_phone_number}
 
 
 
 
44
  },
45
  },
46
  )
 
19
  api_key: str
20
  account_id: str
21
  my_phone_number: str
22
+ my_first_name: str
23
+ my_last_name: str
24
 
25
 
26
  # Create server
 
28
  surge_settings = SurgeSettings() # type: ignore
29
 
30
 
31
+ @mcp.tool(
32
+ name="text_me",
33
+ description="Send a text message to the number set as SURGE_MY_PHONE_NUMBER in the .env file",
34
+ )
35
  def text_me(text_content: str) -> str:
36
  """Send a text message to a phone number"""
37
  with httpx.Client() as client:
38
  response = client.post(
39
  "https://api.surgemsg.com/messages",
40
  headers={
41
+ "Authorization": f"Bearer {surge_settings.api_key}",
42
  "Surge-Account": surge_settings.account_id,
43
  "Content-Type": "application/json",
44
  },
45
  json={
46
  "body": text_content,
47
  "conversation": {
48
+ "contact": {
49
+ "first_name": surge_settings.my_first_name,
50
+ "last_name": surge_settings.my_last_name,
51
+ "phone_number": surge_settings.my_phone_number,
52
+ }
53
  },
54
  },
55
  )