Outils techniques pour la recherche juridique suisse : MCP servers (entscheidsuche, onlinekommentar), CLI (Fedlex SPARQL), APIs cantonales. Skill transversale centralisant tous les outils d'accès aux sources juridiques. Utiliser cette skill quand l'utilisateur veut savoir comment accéder techniquement aux sources juridiques suisses (CLI, MCP, API, web scraping).
Skill transversale centralisant tous les outils techniques pour accéder aux sources juridiques suisses.
Principe : Les skills de contenu juridique (sources-cantonales, sources-legislatives-federales, jurisprudence-suisse) décrivent quoi chercher. Cette skill décrit comment y accéder techniquement.
1. CLI (scripts locaux) → Meilleur contrôle, reproductible
2. MCP (serveurs intégrés) → Intégration native OpenCode
3. API (endpoints REST/JSON) → Programmable, stable
4. Web (fetch/scraping) → Dernier recours
| Source | Type | CLI | MCP | API | Web | Priorité |
|---|
| Fedlex (législation fédérale) | Législation | ✅ fedlex_sparql.py | ❌ | ✅ SPARQL | ✅ | CLI/API |
| entscheidsuche.ch | Jurisprudence | ❌ | ✅ @entscheidsuche | ✅ JSON/ES | ✅ | MCP/API |
| onlinekommentar.ch | Doctrine | ❌ | ✅ @onlinekommentar | ✅ JSON | ✅ | MCP/API |
| bger.ch | Jurisprudence TF | ❌ | ❌ | ⚠️ Limited | ✅ | Web |
| Lexfind | Portail cantonal | ❌ | ❌ | ❌ | ✅ | Web |
| Sites cantonaux | Législation | ❌ | ❌ | ⚠️ Certains | ✅ | Web/API |
Fedlex (data.fedlex.admin.ch) est la source officielle pour la législation fédérale suisse. Elle expose un endpoint SPARQL avec des données RDF/Linked Data.
Le CLI fedlex_sparql.py permet d'accéder à 9000+ lois fédérales via un mapping local RS → ELI.
# Dépendances (avec uv)
uv run --with sparqlwrapper --with requests --with beautifulsoup4 python scripts/fedlex_sparql.py --help
# Ou installation classique
pip install sparqlwrapper requests beautifulsoup4
python scripts/fedlex_sparql.py --help
| Commande | Description | Exemple |
|---|---|---|
generate-mapping | Génère le mapping complet RS → ELI (~9000 lois, 10-30s) | generate-mapping |
list | Liste toutes les lois du mapping local | list |
url <RS> | Obtient l'URL d'une loi | url 210 |
search <query> | Recherche par mots-clés (instantané) | search "code civil" |
get <RS> | Télécharge le contenu d'une loi | get 210 |
metadata <RS> | Affiche les métadonnées d'une loi | metadata 210 |
history <RS> | Liste les versions historiques | history 210 |
# Générer le mapping complet (à faire une fois)
python scripts/fedlex_sparql.py generate-mapping
# Rechercher une loi par numéro RS
python scripts/fedlex_sparql.py url 210
# Rechercher par mots-clés (instantané, dans le mapping local)
python scripts/fedlex_sparql.py search "protection données"
# Télécharger le HTML brut
python scripts/fedlex_sparql.py get 210
# Télécharger en texte brut (sans balises HTML)
python scripts/fedlex_sparql.py get 210 --text
# Sauvegarder dans un fichier
python scripts/fedlex_sparql.py get 210 --output code_civil.html
python scripts/fedlex_sparql.py get 210 --text --output code_civil.txt
# Télécharger en PDF
python scripts/fedlex_sparql.py get 210 --format pdf --output code_civil.pdf
# Télécharger en XML (Akoma Ntoso)
python scripts/fedlex_sparql.py get 210 --format xml --output code_civil.xml
# Télécharger en DOCX
python scripts/fedlex_sparql.py get 210 --format docx --output code_civil.docx
# Lister les versions historiques
python scripts/fedlex_sparql.py history 210
get| Option | Description | Défaut |
|---|---|---|
--format, -f | Format: html, pdf, xml, docx | html |
--lang | Langue: fr, de, it | fr |
--text, -t | Extraire le texte brut (HTML uniquement) | false |
--output, -o | Sauvegarder dans un fichier | - |
| Endpoint | URL | Format |
|---|---|---|
| SPARQL | https://fedlex.data.admin.ch/sparqlendpoint | RDF/SPARQL |
| Linked Data | https://fedlex.data.admin.ch/eli/cc/{rs} | RDF/JSON-LD |
| Filestore | https://fedlex.data.admin.ch/filestore/... | PDF/HTML/DOCX/XML |
ConsolidationAbstract (loi abstraite, identifiée par RS)
└── Consolidation (version datée)
└── Expression (version linguistique)
└── Manifestation (format de fichier)
└── isExemplifiedBy → URL de téléchargement
PREFIX jolux: <http://data.legilux.public.lu/resource/ontology/jolux#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
SELECT ?act ?title ?sr WHERE {
?act a jolux:ConsolidationAbstract ;
skos:prefLabel ?title ;
jolux:classifiedByTaxonomyEntry ?sr .
FILTER(CONTAINS(LCASE(?title), "code civil"))
FILTER(LANG(?title) = "fr")
}
LIMIT 10
Serveur MCP pour la recherche de jurisprudence suisse (1M+ décisions). Couvre les tribunaux fédéraux ET cantonaux.
Déjà configuré dans .opencode/mcp.json :
{
"mcpServers": {
"entscheidsuche": {
"command": "node",
"args": ["mcp-servers/entscheidsuche-mcp/build/index.js"]
}
}
}
| Outil | Description | Paramètres |
|---|---|---|
search_case_law | Recherche de décisions | query, size, spider, date_from, date_to |
get_document | Récupérer un document complet | doc_id, format (json/html/pdf) |
list_courts | Liste des tribunaux indexés | — |
Fédéraux :
CH_BGer — Tribunal fédéral (arrêts non publiés)CH_BGE — ATF (arrêts publiés)CH_BVGer — Tribunal administratif fédéralCH_BStGer — Tribunal pénal fédéralCH_BPatGer — Tribunal fédéral des brevetsCantonaux (exemples) :
CH_ZH_Obergericht — Obergericht ZürichCH_GE_Cour — Cour de justice GenèveCH_VD_TC — Tribunal cantonal VaudCH_BE_Obergericht — Obergericht BernUser: Cherche des décisions du Tribunal fédéral sur la protection des données depuis 2020
Agent: [Utilise search_case_law avec query="protection des données", spider="CH_BGer", date_from="2020-01-01"]
# Recherche
curl "https://entscheidsuche.ch/_search.php?query=Datenschutz&size=10"
# Document spécifique
curl "https://entscheidsuche.ch/docs/{court}/{year}/{doc_id}.json"
# Statut des tribunaux
curl "https://entscheidsuche.ch/status"
Serveur MCP pour accéder aux commentaires juridiques suisses open access. Premier commentaire non-profit de Suisse.
Déjà configuré dans .opencode/mcp.json :
{
"mcpServers": {
"onlinekommentar": {
"command": "node",
"args": ["mcp-servers/onlinekommentar-mcp/build/index.js"]
}
}
}
| Outil | Description | Paramètres |
|---|---|---|
search_commentaries | Recherche de commentaires | query, language, law_code |
get_commentary | Récupérer un commentaire par ID | id |
Allemand (DE), Français (FR), Italien (IT), Anglais (EN)
# Recherche
curl "https://onlinekommentar.ch/api/commentaries?search=Art.%20328%20CO&language=fr"
# Commentaire spécifique
curl "https://onlinekommentar.ch/api/commentaries/{id}"
| Canton | Type | URL | Format |
|---|---|---|---|
| Zürich | OGD | opendata.swiss (filter: zh) | JSON/CSV |
| Bern | OGD | opendata.swiss (filter: be) | JSON/CSV |
| Genève | SITG | ge.ch/sitg | GeoJSON |
| Basel-Stadt | OGD | data.bs.ch | JSON |
Note : La plupart des APIs cantonales concernent les données géographiques, pas la législation. Pour la législation, utiliser les sites officiels (voir
@sources-cantonales).
Fedlex fournit les liens vers tous les recueils cantonaux :
references/liens-cantonaux.md pour la liste complète@entscheidsuche (MCP) pour la recherche, bger.ch pour les documents officiels| Besoin | Outil recommandé | Commande/Action |
|---|---|---|
| Texte de loi en vigueur | CLI Fedlex | fedlex_sparql.py get 210 |
| Texte brut (sans HTML) | CLI Fedlex | fedlex_sparql.py get 210 --text |
| Télécharger en PDF | CLI Fedlex | fedlex_sparql.py get 210 -f pdf -o loi.pdf |
| Recherche par mots-clés | CLI Fedlex | fedlex_sparql.py search "..." |
| Version historique | CLI Fedlex | fedlex_sparql.py history 210 |
| Besoin | Outil recommandé | Commande/Action |
|---|---|---|
| Recherche TF | MCP entscheidsuche | search_case_law(query="...", spider="CH_BGer") |
| Recherche cantonale | MCP entscheidsuche | search_case_law(query="...", spider="CH_GE_Cour") |
| Document complet | MCP entscheidsuche | get_document(doc_id="...", format="pdf") |
| Besoin | Outil recommandé | Commande/Action |
|---|---|---|
| Commentaire d'article | MCP onlinekommentar | search_commentaries(query="Art. 328 CO") |
| Commentaire par ID | MCP onlinekommentar | get_commentary(id="...") |
| Besoin | Outil recommandé | Action |
|---|---|---|
| Recherche de loi | Web (site cantonal) | Voir @sources-cantonales |
| Jurisprudence cantonale | MCP entscheidsuche | search_case_law(spider="CH_{canton}_...") |
references/liens-cantonaux.md — Liens vers tous les recueils cantonauxreferences/sparql-examples.md — Exemples de requêtes SPARQL pour Fedlexscripts/fedlex_sparql.py — CLI pour FedlexPour le contenu juridique (quoi chercher) :
@sources-legislatives-federales — Législation fédérale@sources-cantonales — Législation cantonale@jurisprudence-suisse — Jurisprudence@sources-doctrinales — DoctrinePour les méthodologies :
@techniques-recherche-juridique — Opérateurs booléens, troncature@methodologie-recherche-jurisprudentielle — Méthode systématique