"""
HTTP MCP server for voice notifications.
"""
import os
import warnings
from dotenv import load_dotenv
from fastmcp import FastMCP
from fastmcp.server.http import create_streamable_http_app
import uvicorn
from voice import generate_and_play_voice
# Suppress deprecation warnings
warnings.filterwarnings("ignore", category=DeprecationWarning, module="websockets.*")
warnings.filterwarnings("ignore", category=DeprecationWarning, module="uvicorn.*")
# 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 HTTP for integration with MCP clients
asgi_app = create_streamable_http_app(app, "/mcp", stateless_http=True)
uvicorn.run(asgi_app, host="127.0.0.1", port=8000)