eul:get_document
Retrieve EU legislation documents by CELEX number from EUR-Lex. Extract specific sections or save full text to files for legal research and analysis.
Instructions
Retrieve EU legislation from EUR-Lex by CELEX number (e.g., "32016R0679" for GDPR, "32001L0029" for InfoSoc). Returns full text in Markdown. Use section for partial content: "Art. 5", "Artikel 5", or "lines:100-200". Use save_path to save to file instead of returning content.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| celex | Yes | CELEX number (e.g., "32016R0679", "32001L0029", "12016E267") | |
| language | Yes | Language code (default: DE) | DE |
| section | No | Extract section: "Art. 5", "Artikel 5-10", "Kapitel III", or "lines:100-200" | |
| save_path | No | Save full document to this file path instead of returning content |
Implementation Reference
- src/providers/eul/provider.ts:81-117 (handler)The handleGetDocument method performs the actual retrieval of the EUR-Lex document, handles conversion to markdown, section extraction, and optional file saving.
private async handleGetDocument(args: Record<string, unknown>): Promise<ToolResult> { const { celex, language = 'DE', section, save_path } = args as { celex: string; language?: string; section?: string; save_path?: string; }; logger.info('Fetching EUR-Lex document', { celex, language }); const response = await axios.get(`${CELLAR_BASE}/${celex}`, { headers: { 'Accept': 'text/html, application/xhtml+xml', 'Accept-Language': `${language.toLowerCase()}, en;q=0.8`, }, maxRedirects: 5, responseType: 'text', }); const markdown = this.converter.convert(response.data); validateConversion(markdown, 'EUR-Lex'); if (section) { const extracted = this.extractSection(markdown, section); if (!extracted) { return { content: [{ type: 'text', text: `Section "${section}" not found.` }], isError: true }; } return { content: [{ type: 'text', text: extracted }] }; } const fullDoc = `# ${celex}\n\n---\n\n${markdown}`; if (save_path) { const { writeFile } = await import('fs/promises'); await writeFile(save_path, fullDoc, 'utf-8'); return { content: [{ type: 'text', text: `Saved to ${save_path}\n\nCELEX: ${celex}\nLanguage: ${language}` }] }; } return { content: [{ type: 'text', text: fullDoc }] }; } - Definition and input schema for the 'eul:get_document' tool.
{ name: 'eul:get_document', description: 'Retrieve EU legislation from EUR-Lex by CELEX number (e.g., "32016R0679" for GDPR, "32001L0029" for InfoSoc). ' + 'Returns full text in Markdown. Use `section` for partial content: "Art. 5", "Artikel 5", or "lines:100-200". ' + 'Use `save_path` to save to file instead of returning content.', inputSchema: z.object({ celex: z.string().describe('CELEX number (e.g., "32016R0679", "32001L0029", "12016E267")'), language: z.string().optional().default('DE').describe('Language code (default: DE)'), section: z.string().optional().describe('Extract section: "Art. 5", "Artikel 5-10", "Kapitel III", or "lines:100-200"'), save_path: z.string().optional().describe('Save full document to this file path instead of returning content'), }), }, - src/providers/eul/provider.ts:35-35 (registration)Registration of the 'eul:get_document' tool in the provider's handleToolCall method.
if (toolName === 'eul:get_document') return this.handleGetDocument(args);