Skip to main content
Glama
r-huijts

OpenTK Model Context Protocol Server

by r-huijts

get_document_details

Retrieves structured metadata for Dutch parliamentary documents, including title, type, document number, dates, version, and links to PDF and official web pages, using a unique identifier.

Instructions

Retrieves metadata about a parliamentary document in a structured JSON format, without downloading the actual document content. Returns information including title, type, document number, dates, version number, and clickable links to both the PDF version and the official Tweede Kamer webpage. This tool is ideal for getting quick information about a document and obtaining the relevant links for further access. To actually download the document content, use the 'download_document' tool instead.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nummerYesDocument number (e.g., '2024D39058') - the unique identifier for the parliamentary document you want information about

Implementation Reference

  • src/index.ts:351-395 (registration)
    Registration of the 'get_document_details' MCP tool. Defines the tool name, description, input schema (document 'nummer'), and handler function that fetches HTML from the document page and extracts structured details using extractDocumentDetailsFromHtml.
      "get_document_details",
      "Retrieves metadata about a parliamentary document in a structured JSON format, without downloading the actual document content. Returns information including title, type, document number, dates, version number, and links to both the PDF version and the official Tweede Kamer webpage.",
      {
        nummer: z.string().describe("Document number (e.g., '2024D39058') - the unique identifier for the parliamentary document you want information about")
      },
      async ({ nummer }) => {
        try {
          const html = await apiService.fetchHtml(`/document.html?nummer=${encodeURIComponent(nummer)}`);
          if (!html) {
            return {
              content: [{
                type: "text",
                text: JSON.stringify({ error: `No content found for document ${nummer}` })
              }]
            };
          }
    
          const details = extractDocumentDetailsFromHtml(html, BASE_URL);
          if (!details) {
            return {
              content: [{
                type: "text",
                text: JSON.stringify({ error: `Failed to parse details for document ${nummer}` })
              }]
            };
          }
    
          return {
            content: [{
              type: "text",
              text: JSON.stringify(details, null, 2)
            }]
          };
        } catch (error: any) {
          return {
            content: [{
              type: "text",
              text: JSON.stringify({
                error: `Error fetching document details: ${error.message || 'Unknown error'}`
              })
            }]
          };
        }
      }
    );
  • Handler function for get_document_details tool: fetches the document.html page using apiService, extracts details using the helper function, formats as JSON, and returns as MCP content or error response.
    async ({ nummer }) => {
      try {
        const html = await apiService.fetchHtml(`/document.html?nummer=${encodeURIComponent(nummer)}`);
        if (!html) {
          return {
            content: [{
              type: "text",
              text: JSON.stringify({ error: `No content found for document ${nummer}` })
            }]
          };
        }
    
        const details = extractDocumentDetailsFromHtml(html, BASE_URL);
        if (!details) {
          return {
            content: [{
              type: "text",
              text: JSON.stringify({ error: `Failed to parse details for document ${nummer}` })
            }]
          };
        }
    
        return {
          content: [{
            type: "text",
            text: JSON.stringify(details, null, 2)
          }]
        };
      } catch (error: any) {
        return {
          content: [{
            type: "text",
            text: JSON.stringify({
              error: `Error fetching document details: ${error.message || 'Unknown error'}`
            })
          }]
        };
      }
    }
  • Input schema using Zod: requires 'nummer' string parameter for the document ID.
    {
      nummer: z.string().describe("Document number (e.g., '2024D39058') - the unique identifier for the parliamentary document you want information about")
    },
  • Core helper function that implements the document details extraction logic by parsing HTML with regex patterns to pull title, type, nummer, datum, bijgewerkt, versie, direct PDF link, Tweede Kamer link, and attachment info (bijlageBij). Uses shared extractValue utility.
    export function extractDocumentDetailsFromHtml(html: string, baseUrl: string): DocumentDetails | null {
      if (!html) {
        return null;
      }
    
      const details: DocumentDetails = {
        title: null,
        type: null,
        nummer: null,
        datum: null,
        bijgewerkt: null,
        versie: null,
        directLinkPdf: null,
        tweedekamerLink: null,
        bijlageBij: null,
      };
    
      // Extract basic info
      details.title = extractValue(html, /<hblock>\s*<h2>([\s\S]*?)<\/h2>/i);
      details.type = extractValue(html, /<\/hblock>[\s\S]*?<p><em>([\s\S]*?)<\/em><\/p>/i);
    
      // Extract metadata line
      const metadataMatch = html.match(/<p>Nummer: <b>(.*?)<\/b>, datum: <b>(.*?)<\/b>, bijgewerkt: <b>(.*?)<\/b>, versie: (\d+)/i);
      if (metadataMatch) {
        details.nummer = metadataMatch[1]?.trim() || null;
        details.datum = metadataMatch[2]?.trim() || null;
        details.bijgewerkt = metadataMatch[3]?.trim() || null;
        details.versie = metadataMatch[4] ? parseInt(metadataMatch[4], 10) : null;
      }
    
      // Extract links
      const directLinkMatch = html.match(/<a href="(getraw\/[^"']+)">Directe link naar document<\/a>/i);
      if (directLinkMatch && directLinkMatch[1]) {
        // Ensure the URL includes the /tkconv/ path
        const rawPath = directLinkMatch[1];
        // If baseUrl already includes /tkconv/, this will work correctly
        // If not, we need to add it manually
        if (baseUrl.endsWith('/tkconv')) {
          details.directLinkPdf = `${baseUrl}/${rawPath}`;
        } else if (baseUrl.includes('/tkconv/')) {
          details.directLinkPdf = new URL(rawPath, baseUrl).href;
        } else {
          // Ensure we have /tkconv/ in the path
          details.directLinkPdf = `${baseUrl}/tkconv/${rawPath}`;
        }
      }
      details.tweedekamerLink = extractValue(html, /<a href="(https:\/\/www\.tweedekamer\.nl\/[^"']+)">link naar pagina op de Tweede Kamer site<\/a>/i);
    
      // Extract bijlage bij info
      const bijlageMatch = html.match(/<p>Bijlage bij: <a href="(document\.html\?nummer=[^"]+)">([\s\S]*?)<\/a> \(([^)]+)\)<\/p>/i);
      if (bijlageMatch && bijlageMatch[1]) {
        details.bijlageBij = {
          title: bijlageMatch[2]?.trim() || null,
          nummer: bijlageMatch[3]?.trim() || null,
          link: new URL(bijlageMatch[1], baseUrl).href,
        };
      }
    
      return details;
    }
  • TypeScript interface defining the structure of the document details object returned by the tool's extraction logic.
    interface DocumentDetails {
      title: string | null;
      type: string | null;
      nummer: string | null;
      datum: string | null;
      bijgewerkt: string | null;
      versie: number | null;
      directLinkPdf: string | null;
      tweedekamerLink: string | null;
      bijlageBij: {
        title: string | null;
        nummer: string | null;
        link: string;
      } | null;
    }
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes what the tool returns (metadata without content, specific fields like title/type/number/dates/version/links) and clarifies the read-only nature (retrieves, not downloads). It could mention potential limitations like rate limits or authentication needs, but covers core behavior well.

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 efficiently structured with three sentences: the first states purpose and output, the second details returned information, and the third provides usage guidance. Every sentence adds value without redundancy, making it easy to parse and front-loaded with key information.

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

Completeness4/5

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

For a single-parameter read operation with no output schema, the description provides comprehensive context: what it does, what it returns, when to use it, and alternatives. It could benefit from mentioning the response structure more explicitly since there's no output schema, but it covers the essential information well given the tool's complexity.

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

Parameters3/5

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

The schema description coverage is 100%, with the single parameter 'nummer' well-documented in the schema as 'Document number (e.g., '2024D39058') - the unique identifier'. The description doesn't add parameter-specific information beyond what's in the schema, so it meets the baseline for high schema coverage.

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 specific action ('retrieves metadata'), resource ('parliamentary document'), and output format ('structured JSON format'). It explicitly distinguishes this tool from its sibling 'download_document' by specifying it does not download actual content, making the purpose unambiguous and well-differentiated.

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use this tool ('ideal for getting quick information about a document and obtaining the relevant links') and when not to use it ('To actually download the document content, use the 'download_document' tool instead'). This clear alternative recommendation helps the agent choose correctly between similar tools.

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

Related 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/r-huijts/opentk-mcp'

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