46 lines
1.7 KiB
Python
46 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
"""Optional Hermes stdio MCP for Dona navigation. Run from a dedicated venv.
|
|
|
|
Dependencies: 'mcp<2' requests flask python-dotenv. Does not start Flask or alter its state.
|
|
"""
|
|
import sys
|
|
sys.path.insert(0, '/opt/alfred/app')
|
|
# Load existing Dona configuration (including optional Home Assistant token) from the host.
|
|
from dotenv import load_dotenv
|
|
load_dotenv('/opt/alfred/.env', override=False)
|
|
try:
|
|
from mcp.server.fastmcp import FastMCP
|
|
except ImportError as exc:
|
|
raise SystemExit('Installe mcp<2 dans ce venv (voir README du patch).') from exc
|
|
from services.dona_navigation import build, external_links, send_to_phone
|
|
mcp = FastMCP('dona-navigation')
|
|
|
|
@mcp.tool()
|
|
def rechercher_destination(destination: str) -> dict:
|
|
"""Résoudre un lieu pour afficher sa carte dans Dona, sans départ implicite."""
|
|
return build(destination)
|
|
|
|
@mcp.tool()
|
|
def calculer_itineraire(destination: str, depart: str = "") -> dict:
|
|
"""Calculer une route automobile et sa durée hors trafic.
|
|
|
|
Le paramètre depart est facultatif : si absent ou vide, utiliser
|
|
DONA_NAV_ORIGIN depuis /opt/alfred/.env, sans redemander le départ.
|
|
Si depart est indiqué, il remplace la valeur configurée.
|
|
"""
|
|
return build(destination, depart)
|
|
|
|
@mcp.tool()
|
|
def liens_waze_maps(destination: str) -> dict:
|
|
"""Créer des liens officiels vers Waze et Google Maps pour une destination."""
|
|
return external_links(destination)
|
|
|
|
@mcp.tool()
|
|
def envoyer_trajet_waze_telephone(destination: str) -> str:
|
|
"""UNIQUEMENT sur ordre explicite, notifier le téléphone Home Assistant configuré."""
|
|
send_to_phone(destination)
|
|
return 'Notification Waze envoyée vers le mobile Home Assistant configuré.'
|
|
|
|
if __name__ == '__main__':
|
|
mcp.run(transport='stdio')
|