Spaces:
Sleeping
Sleeping
| """MCP Server ADEME Environnement v2 - Architecture simplifiée. | |
| 3 outils avec niveaux de détail progressifs : | |
| 1. search - Exploration large (id + nom) | |
| 2. compare - Éléments différenciants (valeur, incertitude, date, source) | |
| 3. details - Méthodologie complète | |
| """ | |
| import gradio as gr | |
| from src.tools import search, compare, details | |
| # Interface Gradio avec MCP | |
| with gr.Blocks(title="MCP Server ADEME Environnement v2") as demo: | |
| gr.Markdown(""" | |
| # 🌱 MCP Server ADEME Environnement v2 | |
| **3 outils avec niveaux de détail progressifs :** | |
| | Étape | Outil | Retour | Usage | | |
| |-------|-------|--------|-------| | |
| | 1 | `search` | id + nom | Explorer, identifier les FE pertinents | | |
| | 2 | `compare` | valeur, incertitude, date, source | Choisir entre les candidats | | |
| | 3 | `details` | méthodologie complète | Comprendre un FE spécifique | | |
| **Sources** : [AGRIBALYSE](https://agribalyse.ademe.fr/) (alimentation) | [Base Carbone](https://base-empreinte.ademe.fr/) (transport, énergie, déchets, équipements) | |
| --- | |
| **MCP URL** : `https://ekimetrics-mcp-indicators.hf.space/gradio_api/mcp/sse` | |
| """) | |
| # Onglet 1 : Search | |
| with gr.Tab("🔍 Search"): | |
| gr.Markdown("### Étape 1 : Explorer et identifier les FE pertinents") | |
| search_query = gr.Textbox( | |
| label="Recherche", | |
| placeholder="Ex: camion livraison, boeuf, gaz naturel...", | |
| info="Terme de recherche libre" | |
| ) | |
| with gr.Row(): | |
| search_source = gr.Dropdown( | |
| choices=["all", "agribalyse", "base_carbone"], | |
| value="all", | |
| label="Source", | |
| info="all = cherche partout, agribalyse = alimentation, base_carbone = transport/énergie/déchets" | |
| ) | |
| search_size = gr.Number(value=20, label="Résultats max", minimum=1, maximum=50) | |
| search_btn = gr.Button("Rechercher", variant="primary") | |
| search_out = gr.JSON(label="Résultats (id + nom)") | |
| search_btn.click(search, [search_query, search_source, search_size], search_out, api_name="search") | |
| # Onglet 2 : Compare | |
| with gr.Tab("⚖️ Compare"): | |
| gr.Markdown("""### Étape 2 : Comparer les FE candidats | |
| Entrez les IDs trouvés avec search, séparés par des virgules. | |
| Format : `bc_XXXXX` (Base Carbone) ou `agri_XXXXX` (AGRIBALYSE) | |
| """) | |
| compare_ids = gr.Textbox( | |
| label="IDs à comparer", | |
| placeholder="Ex: bc_28022,bc_28023,bc_28024", | |
| info="Copiez les IDs depuis les résultats de search" | |
| ) | |
| compare_btn = gr.Button("Comparer", variant="primary") | |
| compare_out = gr.JSON(label="Comparaison (valeur, incertitude, date, source)") | |
| compare_btn.click(compare, [compare_ids], compare_out, api_name="compare") | |
| # Onglet 3 : Details | |
| with gr.Tab("📋 Details"): | |
| gr.Markdown("""### Étape 3 : Détails méthodologiques complets | |
| Pour creuser un FE spécifique : méthodologie, décomposition par gaz, | |
| commentaires, réglementations, etc. | |
| """) | |
| details_ids = gr.Textbox( | |
| label="IDs", | |
| placeholder="Ex: bc_28022", | |
| info="1 à 5 IDs maximum" | |
| ) | |
| details_btn = gr.Button("Obtenir détails", variant="primary") | |
| details_out = gr.JSON(label="Détails complets") | |
| details_btn.click(details, [details_ids], details_out, api_name="details") | |
| if __name__ == "__main__": | |
| demo.launch(mcp_server=True) | |