"""
Stdio MCP server for voice notifications.
"""
import os
import warnings
from dotenv import load_dotenv
from fastmcp import FastMCP
from voice import generate_and_play_voice
# Suppress deprecation warnings
warnings.filterwarnings("ignore", category=DeprecationWarning, module="websockets.*")
# Load environment variables
load_dotenv()
app = FastMCP("voice-notification")
GROK_API_KEY = os.getenv("GROK_API_KEY")
if not GROK_API_KEY:
raise ValueError("GROK_API_KEY not found in .env file")
@app.tool()
def voice_notification(text: str = "Done!") -> str:
"""
Generate a voice notification using Grok Voice API and play it.
Args:
text: The text to convert to speech (default: "Done!")
Returns:
str: Confirmation message
"""
success, message = generate_and_play_voice(text, GROK_API_KEY)
return message
if __name__ == "__main__":
# Run as MCP server over stdio
app.run()