"""FastMCP server for Jon's Pushover MCP Server."""
import argparse
import logging
import os
import signal
import sys
from typing import Any
from fastmcp import FastMCP
from .tools import send_notification
# Configure logging
logging.basicConfig(
level=os.environ.get("LOG_LEVEL", "INFO"),
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
)
logger = logging.getLogger(__name__)
# Create FastMCP server instance
mcp = FastMCP(
name="jons-mcp-pushover",
instructions="""
An MCP server for sending push notifications via Pushover.
## Environment Variables
Set these environment variables before starting the server:
- `PUSHOVER_API_TOKEN`: Your Pushover application API token
- `PUSHOVER_USER_KEY`: Your Pushover user key
## Available Tools
| Tool | Purpose |
|------|---------|
| send_notification | Send a push notification to your devices |
## Example Usage
```python
send_notification(
message="Build completed successfully!",
title="CI Pipeline",
priority=1
)
```
""",
)
# Register tools
mcp.tool(send_notification)
# Signal handling for graceful shutdown
def signal_handler(signum: int, frame: Any) -> None:
"""Handle shutdown signals."""
logger.info(f"Received signal {signum}, shutting down...")
sys.exit(0)
def main() -> None:
parser = argparse.ArgumentParser(
description="An MCP server for sending notifications through pushover"
)
parser.add_argument(
"project_path",
nargs="?",
help="Path to the project (defaults to current directory)",
)
args = parser.parse_args()
if args.project_path:
logger.info(f"Starting server with project path: {args.project_path}")
else:
logger.info("Starting server with current directory")
signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)
mcp.run()
if __name__ == "__main__":
main()