list_regulations
Browse and explore EU regulations by category or view detailed structures of specific regulations like GDPR, AI Act, and DORA.
Instructions
List available regulations, optionally filtered by category. Without parameters, lists all regulations grouped by category. With a regulation specified, shows chapters and articles.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| regulation | No | Optional: specific regulation to get detailed structure for | |
| category | No | Optional: filter by category (e.g., "cybersecurity", "financial_services", "data_protection", "ai_and_technology", "product_safety", "sustainability", "healthcare", "critical_infrastructure", "digital_services", "automotive") |
Implementation Reference
- src/tools/list.ts:51-202 (handler)The `listRegulations` function is the core implementation that fetches regulation data from the database, handles filtering by category, and structures the response.
export async function listRegulations( db: DatabaseAdapter, input: ListInput ): Promise<ListResult> { const { regulation, category } = input; if (regulation) { // Get specific regulation with chapters const regResult = await db.query( `SELECT id, full_name, celex_id, effective_date FROM regulations WHERE id = $1`, [regulation] ); if (regResult.rows.length === 0) { return { regulations: [] }; } const regRow = regResult.rows[0] as { id: string; full_name: string; celex_id: string; effective_date: string | null; }; // Get articles grouped by chapter const articlesResult = await db.query( `SELECT article_number, title, chapter FROM articles WHERE regulation = $1 ORDER BY article_number::INTEGER`, [regulation] ); const articles = articlesResult.rows as Array<{ article_number: string; title: string | null; chapter: string | null; }>; // Group by chapter const chapterMap = new Map<string, Chapter>(); for (const article of articles) { const chapterKey = article.chapter || 'General'; if (!chapterMap.has(chapterKey)) { chapterMap.set(chapterKey, { number: chapterKey, title: `Chapter ${chapterKey}`, articles: [], }); } chapterMap.get(chapterKey)!.articles.push(article.article_number); } return { regulations: [{ id: regRow.id, full_name: regRow.full_name, celex_id: regRow.celex_id, effective_date: regRow.effective_date, article_count: articles.length, chapters: Array.from(chapterMap.values()), }], }; } // List all regulations with article counts const result = await db.query( `SELECT r.id, r.full_name, r.celex_id, r.effective_date, COUNT(a.regulation) as article_count FROM regulations r LEFT JOIN articles a ON a.regulation = r.id GROUP BY r.id, r.full_name, r.celex_id, r.effective_date ORDER BY r.id` ); const rows = result.rows as Array<{ id: string; full_name: string; celex_id: string; effective_date: string | null; article_count: number; }>; const allRegulations = rows.map(row => ({ id: row.id, full_name: row.full_name, celex_id: row.celex_id, effective_date: row.effective_date, article_count: Number(row.article_count), })); // Filter by category if specified if (category) { const catKey = category.toLowerCase(); if (!(catKey in REGULATION_CATEGORIES)) { const available = Object.keys(REGULATION_CATEGORIES).sort().join(', '); return { regulations: [], category_summary: `Category '${category}' not found. Available categories: ${available}`, }; } const catIds = new Set(REGULATION_CATEGORIES[catKey]); const filtered = allRegulations.filter(r => catIds.has(r.id)); return { regulations: filtered, category_summary: `${category} (${filtered.length} regulations)`, }; } // No category filter: return grouped by category const regById = new Map(allRegulations.map(r => [r.id, r])); const categorized = new Set<string>(); const lines: string[] = []; lines.push(`${allRegulations.length} regulations in ${Object.keys(REGULATION_CATEGORIES).length} categories\n`); for (const [catName, catIds] of Object.entries(REGULATION_CATEGORIES).sort()) { const catRegs = catIds .filter(id => regById.has(id)) .map(id => regById.get(id)!); if (catRegs.length === 0) continue; lines.push(`${catName} (${catRegs.length}):`); for (const r of catRegs) { lines.push(` ${r.id}: ${r.full_name} (${r.article_count} articles)`); categorized.add(r.id); } lines.push(''); } // List uncategorized regulations const uncategorized = allRegulations.filter(r => !categorized.has(r.id)); if (uncategorized.length > 0) { lines.push(`other (${uncategorized.length}):`); for (const r of uncategorized) { lines.push(` ${r.id}: ${r.full_name} (${r.article_count} articles)`); } } return { regulations: allRegulations, category_summary: lines.join('\n'), }; } - src/tools/list.ts:3-6 (schema)`ListInput` defines the accepted input parameters (regulation, category) for the tool.
export interface ListInput { regulation?: string; category?: string; } - src/tools/registry.ts:153-170 (registration)The `list_regulations` tool is registered here with its definition and calls the `listRegulations` handler.
name: 'list_regulations', description: 'List available regulations, optionally filtered by category. Without parameters, lists all regulations grouped by category. With a regulation specified, shows chapters and articles.', inputSchema: { type: 'object', properties: { regulation: { type: 'string', description: 'Optional: specific regulation to get detailed structure for', }, category: { type: 'string', description: 'Optional: filter by category (e.g., "cybersecurity", "financial_services", "data_protection", "ai_and_technology", "product_safety", "sustainability", "healthcare", "critical_infrastructure", "digital_services", "automotive")', }, }, }, handler: async (db, args) => { const input = (args ?? {}) as unknown as ListInput; return await listRegulations(db, input);