Skip to main content
Glama
metaneutrons

German Legal MCP Server

by metaneutrons

legis:toc

Retrieve a compact table of contents for German laws to navigate large legal documents efficiently. Specify jurisdiction and law identifier to get section numbers and headings.

Instructions

Get table of contents for a law — compact list of section numbers and headings. Much lighter than legis:get for navigating large laws. BUND: id is just the law abbreviation (e.g., "bgb", "stgb"). Länder: id from legis:search results.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesLaw identifier. BUND: law abbreviation (e.g., "bgb"). Länder: ID from legis:search.
stateYesJurisdiction (e.g., "BUND", "BW", "NW")
fromNoStart at section (e.g., "§ 823", "Art 1"). Inclusive.
toNoEnd at section (e.g., "§ 853"). Inclusive.
depthNoMax depth level (0=top structure only, 1=sections, 2=subsections, 3=norms)

Implementation Reference

  • The `handleToc` method in `LegisProvider` implements the logic for `legis:toc`, including calling the adapter's TOC function (or falling back to parsing the document) and applying optional depth and range filters.
    private async handleToc(args: Record<string, unknown>): Promise<ToolResult> {
      const { id, state, from, to, depth } = args as {
        id: string; state: string; from?: string; to?: string; depth?: number;
      };
      const adapter = this.getAdapter(state);
    
      let entries: TocEntry[];
      if (adapter.toc) {
        entries = await adapter.toc(state, id);
      } else {
        // Default: extract headings from full document markdown
        const entry = await adapter.get(state, id);
        entries = [];
        for (const line of entry.content.split('\n')) {
          const m = line.match(/^(#{1,6})\s+(.+)/);
          if (!m) continue;
          const d = m[1].length - 1; // h1→0, h2→1, etc.
          const nm = m[2].match(/^(§§?\s*\S+|Art\.?\s*\S+)\s*(.*)/);
          entries.push({ depth: d, num: nm?.[1] || '', title: nm?.[2] || m[2] });
        }
      }
    
      // Apply depth filter
      if (depth !== undefined) entries = entries.filter((e) => e.depth <= depth);
    
      // Apply range filter
      if (from || to) {
        const norm = (s: string) => s.replace(/\s+/g, '').toLowerCase();
        const fromN = from ? norm(from) : null;
        const toN = to ? norm(to) : null;
        let inRange = !fromN;
        entries = entries.filter((e) => {
          const n = norm(e.num);
          if (fromN && n === fromN) inRange = true;
          if (!inRange) return false;
          if (toN && n === toN) { inRange = false; return true; }
          return true;
        });
      }
    
      const lines = entries.map((e) => {
        const indent = '  '.repeat(e.depth);
        if (!e.num) return `${indent}**${e.title}**`;
        return e.title ? `${indent}${e.num} ${e.title}` : `${indent}${e.num}`;
      });
    
      return { content: [{ type: 'text', text: `${entries.length} entries:\n\n${lines.join('\n')}` }] };
    }
  • The `legis:toc` tool definition, including its input schema and description, is defined in `legisTools` array.
      name: 'legis:toc',
      description:
        'Get table of contents for a law — compact list of section numbers and headings. ' +
        'Much lighter than legis:get for navigating large laws. ' +
        'BUND: id is just the law abbreviation (e.g., "bgb", "stgb"). ' +
        'Länder: id from legis:search results.',
      inputSchema: z.object({
        id: z.string().describe('Law identifier. BUND: law abbreviation (e.g., "bgb"). Länder: ID from legis:search.'),
        state: stateEnum.describe('Jurisdiction (e.g., "BUND", "BW", "NW")'),
        from: z.string().optional().describe('Start at section (e.g., "§ 823", "Art 1"). Inclusive.'),
        to: z.string().optional().describe('End at section (e.g., "§ 853"). Inclusive.'),
        depth: z.number().optional().describe('Max depth level (0=top structure only, 1=sections, 2=subsections, 3=norms)'),
      }),
    },
Behavior3/5

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

With no annotations provided, the description must carry the full behavioral burden. It adds valuable context about performance ('Much lighter') and output structure ('compact list'), but omits safety characteristics (read-only status), rate limits, caching behavior, or error conditions that would be necessary for a complete behavioral picture.

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 tightly structured with zero waste: purpose/output (sentence 1), sibling comparison (sentence 2), and parameter semantics (sentences 3-4). Every clause delivers actionable information without redundancy.

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?

Given the domain complexity (17 jurisdictions, 5 parameters, no output schema), the description adequately covers the critical jurisdiction distinction and explains the lightweight return format. It could be improved by briefly describing the return structure or pagination, but successfully addresses the primary complexity (BUND vs Länder ID sourcing).

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

Parameters4/5

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

While the schema has 100% coverage (baseline 3), the description adds significant semantic value by explaining the jurisdiction-specific sourcing logic for 'id'—providing concrete examples for BUND ('bgb', 'stgb') and cross-referencing 'legis:search' for Länder. This domain context is essential for correct invocation.

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 opens with a specific verb-resource pair ('Get table of contents for a law') and clarifies the output format ('compact list of section numbers and headings'). It explicitly distinguishes from sibling 'legis:get' by noting this is 'Much lighter... for navigating large laws', clearly scoping its purpose.

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 explicit comparative guidance by contrasting with 'legis:get' (lighter weight for navigation vs presumably heavier full retrieval). It also gives jurisdiction-specific instructions for the 'id' parameter (BUND abbreviations vs Länder IDs from legis:search), effectively guiding when to use which sourcing pattern. However, it lacks explicit 'when not to use' negative constraints.

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