Skip to main content
Glama
metaneutrons

German Legal MCP Server

by metaneutrons

eul:get_document

Retrieve full text of EU legislation from EUR-Lex by CELEX number. Extract specific articles, sections, or line ranges. Output content as Markdown or save directly to a file.

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

TableJSON Schema
NameRequiredDescriptionDefault
celexYesCELEX number (e.g., "32016R0679", "32001L0029", "12016E267")
languageYesLanguage code (default: DE)DE
sectionNoExtract section: "Art. 5", "Artikel 5-10", "Kapitel III", or "lines:100-200"
save_pathNoSave full document to this file path instead of returning content

Implementation Reference

  • The handleGetDocument method handles the 'eul:get_document' tool. It fetches EU legislation from EUR-Lex by CELEX number via HTTP GET, converts HTML to Markdown using EulConverter, optionally extracts a section (by article range, line range, or heading), and optionally saves to a file. Returns the full document in Markdown format.
    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 }] };
    }
  • The tool definition/schema for 'eul:get_document', specifying its description and inputSchema with Zod validation for celex (string), language (optional, default DE), section (optional), and save_path (optional).
    {
      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'),
      }),
    },
  • The eulTools array is exported and contains the tool definition for 'eul:get_document'. This array is returned by the EulProvider.getTools() method which is called by the MCP server's getAllTools() to list available tools.
    export const eulTools: ToolDefinition[] = [
      {
        name: 'eul:search',
        description:
          'Search EU legislation (directives, regulations, treaties) via EUR-Lex SPARQL endpoint. ' +
          'Returns CELEX numbers, titles, and dates.',
        inputSchema: z.object({
          query: z.string().describe('Search term in title (e.g., "Urheberrecht", "Datenschutz", "Verbraucherschutz")'),
          resource_type: z.enum(['any', 'directive', 'regulation', 'decision', 'treaty']).optional().default('any')
            .describe('Filter by type (default: any)'),
          language: z.string().optional().default('DE').describe('Language code (default: DE)'),
          limit: z.number().optional().default(10).describe('Maximum results (default: 10)'),
        }),
      },
      {
        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'),
        }),
      },
    ];
  • The handleToolCall method in EulProvider routes 'eul:get_document' to handleGetDocument. This is called from the main MCP server's CallToolRequestSchema handler via the centralized handleToolCall function.
    async handleToolCall(toolName: string, args: Record<string, unknown>): Promise<ToolResult> {
      if (toolName === 'eul:search') return this.handleSearch(args);
      if (toolName === 'eul:get_document') return this.handleGetDocument(args);
      return { content: [{ type: 'text', text: `Unknown tool: ${toolName}` }], isError: true };
    }
  • EulConverter is a helper class used by handleGetDocument to convert fetched HTML from EUR-Lex into Markdown using TurndownService with custom rules for ELI article titles, subtitles, section headings, and footnote markers.
    import TurndownService from 'turndown';
    
    export class EulConverter {
      private turndown: TurndownService;
    
      constructor() {
        this.turndown = new TurndownService({ headingStyle: 'atx' });
    
        // ELI article titles: <p class="oj-ti-art"> → ## Artikel N
        this.turndown.addRule('articleTitle', {
          filter: (node) => node.nodeName === 'P' && node.getAttribute('class') === 'oj-ti-art',
          replacement: (content) => `\n\n## ${content.trim()}\n\n`,
        });
    
        // ELI article subtitles: <p class="oj-sti-art"> → ### Subtitle
        this.turndown.addRule('articleSubtitle', {
          filter: (node) => node.nodeName === 'P' && node.getAttribute('class') === 'oj-sti-art',
          replacement: (content) => `### ${content.trim()}\n\n`,
        });
    
        // Section headings: oj-ti-section-1, oj-ti-section-2
        this.turndown.addRule('sectionTitle', {
          filter: (node) => {
            const cls = node.getAttribute('class') || '';
            return node.nodeName === 'P' && cls.startsWith('oj-ti-section-');
          },
          replacement: (content, node) => {
            const cls = (node as HTMLElement).getAttribute('class') || '';
            const level = cls.includes('section-1') ? '#' : '##';
            return `\n\n${level} ${content.trim()}\n\n`;
          },
        });
    
        // Footnote markers: <span class="oj-super oj-note-tag">
        this.turndown.addRule('footnoteTag', {
          filter: (node) => (node.getAttribute('class') || '').includes('oj-note-tag'),
          replacement: (content) => `[^${content.trim()}]`,
        });
      }
    
      convert(html: string): string {
        return this.turndown.turndown(html);
      }
    }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It transparently states the output format (Markdown) and explains the behavior of `section` and `save_path`. It does not mention side effects or restrictions, but as a read-only retrieval tool, this is acceptable. Slightly lower because no annotations exist to complement.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences, tightly packed with essential information. It is front-loaded with the core purpose and immediately provides actionable usage guidance. No unnecessary words or redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Despite the lack of output schema, the description covers the key aspects: what the tool retrieves, how to specify parameters, and the return format (Markdown). For a straightforward retrieval tool with 4 parameters, this is complete and leaves minimal ambiguity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, and the description adds significant value beyond the schema by providing examples for `section` (e.g., 'Art. 5', 'lines:100-200') and explaining the effect of `save_path` (saves to file instead of returning content). This enriches the agent's understanding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool retrieves EU legislation by CELEX number, with concrete examples (e.g., GDPR, InfoSoc). The verb 'Retrieve' and resource 'EU legislation from EUR-Lex' are specific, and the distinction from sibling 'eul:search' is implicit as this is for exact document retrieval.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear guidance on using parameters like `section` for partial content and `save_path` for file saving. It implies this tool is for retrieval by CELEX number, contrasting with the sibling 'eul:search'. However, it does not explicitly state when not to use this tool or mention alternatives beyond parameters.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/metaneutrons/german-legal-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server