Skip to main content
Glama

get_article

Retrieve specific article text from EU regulations like GDPR or AI Act. Use after search_regulations to access full legal content with optional recitals.

Instructions

Retrieve the full text of a specific article from a regulation. WARNING: Token usage varies (500-70,000 tokens per article). Large articles are automatically truncated at 50,000 characters (~12,500 tokens) with a notice. Use search_regulations first to find relevant articles.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
regulationYesRegulation ID (e.g., "GDPR", "NIS2", "DORA")
articleYesArticle number (e.g., "17", "23")
include_recitalsNoOptional: include related recitals alongside the article text (default: false)

Implementation Reference

  • The core 'getArticle' function that executes the database query to retrieve an article.
    export async function getArticle(
      db: DatabaseAdapter,
      input: GetArticleInput
    ): Promise<Article | null> {
      const { regulation, article } = input;
    
      const sql = `
        SELECT
          regulation,
          article_number,
          title,
          text,
          chapter,
          recitals,
          cross_references
        FROM articles
        WHERE regulation = $1 AND article_number = $2
      `;
    
      const result = await db.query(sql, [regulation, article]);
    
      if (result.rows.length === 0) {
        return null;
      }
    
      const row = result.rows[0] as {
        regulation: string;
        article_number: string;
        title: string | null;
        text: string;
        chapter: string | null;
        recitals: string | null;
        cross_references: string | null;
      };
    
      // Token management: Truncate very large articles to prevent context overflow
      const MAX_CHARS = 50000; // ~12,500 tokens (safe for 200k context window)
      const originalLength = row.text.length;
      const tokenEstimate = Math.ceil(originalLength / 4); // ~4 chars per token
      let text = row.text;
      let truncated = false;
    
      if (originalLength > MAX_CHARS) {
        text = row.text.substring(0, MAX_CHARS) + '\n\n[... Article truncated due to length. Original: ' + originalLength + ' chars (~' + tokenEstimate + ' tokens). Use search_regulations to find specific sections.]';
        truncated = true;
      }
    
      return {
        regulation: row.regulation,
        article_number: row.article_number,
        title: row.title,
        text,
        chapter: row.chapter,
        recitals: row.recitals ? JSON.parse(row.recitals) : null,
        cross_references: row.cross_references ? JSON.parse(row.cross_references) : null,
        truncated,
        original_length: truncated ? originalLength : undefined,
        token_estimate: truncated ? tokenEstimate : undefined,
      };
    }
  • The input interface defining the parameters for the get_article tool.
    export interface GetArticleInput {
      regulation: string;
      article: string;
      include_recitals?: boolean;
    }
  • The registration of the 'get_article' tool in the central registry, including its description, input schema, and handler wrapper.
    {
      name: 'get_article',
      description: 'Retrieve the full text of a specific article from a regulation. WARNING: Token usage varies (500-70,000 tokens per article). Large articles are automatically truncated at 50,000 characters (~12,500 tokens) with a notice. Use search_regulations first to find relevant articles.',
      inputSchema: {
        type: 'object',
        properties: {
          regulation: {
            type: 'string',
            description: 'Regulation ID (e.g., "GDPR", "NIS2", "DORA")',
          },
          article: {
            type: 'string',
            description: 'Article number (e.g., "17", "23")',
          },
          include_recitals: {
            type: 'boolean',
            description: 'Optional: include related recitals alongside the article text (default: false)',
          },
        },
        required: ['regulation', 'article'],
      },
      handler: async (db, args) => {
        const input = args as unknown as GetArticleInput;
        const article = await getArticle(db, input);
        if (!article) {
          throw new Error(`Article ${input.article} not found in ${input.regulation}`);
        }
        return article;
      },
    },

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/Ansvar-Systems/eu-regulations'

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