-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpush_server.py
More file actions
31 lines (21 loc) · 807 Bytes
/
Copy pathpush_server.py
File metadata and controls
31 lines (21 loc) · 807 Bytes
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
import os
from dotenv import load_dotenv
import requests
from pydantic import BaseModel, Field
from mcp.server.fastmcp import FastMCP
load_dotenv(override=True)
pushover_user = os.getenv("PUSHOVER_USER")
pushover_token = os.getenv("PUSHOVER_TOKEN")
pushover_url = "https://api.pushover.net/1/messages.json"
mcp = FastMCP("push_server")
class PushModelArgs(BaseModel):
message: str = Field(description="A brief message to push")
@mcp.tool()
def push(args: PushModelArgs):
"""Send a push notification with this brief message"""
print(f"Push: {args.message}")
payload = {"user": pushover_user, "token": pushover_token, "message": args.message}
requests.post(pushover_url, data=payload)
return "Push notification sent"
if __name__ == "__main__":
mcp.run(transport="stdio")