Skip to main content
Glama
self-tech-labs

Online Kommentar MCP Server

Get Commentary by ID

get_commentary_by_id

Retrieve specific Swiss legal commentary content using its unique ID to access detailed legal analysis from onlinekommentar.ch in multiple languages.

Instructions

Retrieves a specific commentary by its ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesThe ID of the commentary to retrieve.

Implementation Reference

  • The handler function for the 'get_commentary_by_id' tool. It fetches commentary data from the API using the provided ID, handles 404 and other errors, parses the JSON response, formats key details like title, authors, editors, and content into a readable text block, and returns it as tool content.
      async ({ id }: { id: string }) => {
        try {
            const response = await fetch(`${API_BASE_URL}/commentaries/${id}`, {
                headers: { "Accept": "application/json" }
            });
    
            if (!response.ok) {
                if (response.status === 404) {
                    return {
                        content: [{ type: "text", text: `Commentary with ID '${id}' not found.` }],
                        isError: true,
                    };
                }
                throw new Error(`API request failed with status ${response.status}`);
            }
    
            const data = (await response.json()) as { data: Commentary };
            const commentary = data.data;
            
            // Let's format the output nicely for the user
            const authors = commentary.authors.map(a => a.name).join(', ');
            const editors = commentary.editors ? commentary.editors.map(e => e.name).join(', ') : 'None listed';
            const resultText = `
    Title: ${commentary.title}
    ID: ${commentary.id}
    Language: ${commentary.language}
    Publication Date: ${commentary.date}
    Legislative Act: ${commentary.legislative_act.title}
    Legal Domain: ${commentary.legal_domain?.name || 'Not specified'}
    Authors: ${authors}
    Editors: ${editors}
    URL: ${commentary.html_link}
    Content:
    ${commentary.content || 'Full content not available in summary.'}
            `.trim();
    
            return {
                content: [{ type: "text", text: resultText }],
            };
        } catch (error) {
            const errorMessage = error instanceof Error ? error.message : "An unknown error occurred";
            return {
                content: [{ type: "text", text: `Error retrieving commentary: ${errorMessage}` }],
                isError: true,
            };
        }
      }
  • src/index.ts:91-99 (registration)
    Registers the 'get_commentary_by_id' tool with the MCP server, specifying the tool name, title, description, and input schema before passing the inline handler function.
    server.registerTool(
      "get_commentary_by_id",
      {
        title: "Get Commentary by ID",
        description: "Retrieves a specific commentary by its ID.",
        inputSchema: {
          id: z.string().describe("The ID of the commentary to retrieve."),
        },
      },
  • Zod input schema for the tool, defining a required 'id' parameter as a string with description.
    inputSchema: {
      id: z.string().describe("The ID of the commentary to retrieve."),
    },
  • TypeScript interface defining the structure of a Commentary object, used for type assertion in the handler's response parsing.
    interface Commentary {
      id: string;
      title: string;
      language: string;
      date: string;
      legislative_act: {
        id: string;
        title: string;
      };
      legal_domain?: {
        id: string;
        name: string;
      };
      authors: {
        id: string;
        name: string;
      }[];
      editors?: {
        id: string;
        name: string;
      }[];
      html_link: string;
      content?: string;
    }
  • Constant defining the base URL for the Online Kommentar API, used in fetch calls for both tools.
    const API_BASE_URL = "https://onlinekommentar.ch/api";
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states this is a retrieval operation, implying read-only behavior, but doesn't address permissions, error conditions, rate limits, or what happens if the ID doesn't exist. Significant behavioral context is missing.

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 a single, efficient sentence with zero wasted words. It's appropriately sized for a simple retrieval tool and gets straight to the point without unnecessary elaboration.

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

Completeness2/5

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

For a retrieval tool with no annotations and no output schema, the description is insufficient. It doesn't explain what a 'commentary' is, what format it returns, error handling, or how this differs from the sibling search tool. More context is needed for proper agent understanding.

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?

Schema description coverage is 100%, so the schema already fully documents the single 'id' parameter. The description doesn't add any additional parameter semantics beyond what's in the schema, meeting the baseline for high coverage.

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

Purpose4/5

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

The description clearly states the verb ('retrieves') and resource ('a specific commentary'), making the purpose unambiguous. However, it doesn't explicitly differentiate from the sibling 'search_commentaries' tool, which would be needed for a perfect score.

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

Usage Guidelines2/5

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

No guidance is provided about when to use this tool versus the sibling 'search_commentaries' tool. The description doesn't mention prerequisites, alternatives, or contextual constraints, leaving the agent without usage direction.

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/self-tech-labs/onlinekommentar-mcp'

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