Skip to main content
Glama
self-tech-labs

Online Kommentar MCP Server

Search Commentaries

search_commentaries

Search Swiss legal commentaries by query, language, and legislative act to find relevant legal analysis and interpretation.

Instructions

Searches for legal commentaries based on a query and filters.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
searchYesThe full-text search query.
languageNoContent language.
legislative_actNoFilter by legislative act ID.
sortNoSort order.
pageNoPage number for pagination.

Implementation Reference

  • The asynchronous handler function that executes the 'search_commentaries' tool. It builds query parameters, fetches data from the Online Kommentar API, processes the response, formats the commentaries into text, and handles errors appropriately.
    async (args: { search: string; language?: "en" | "de" | "fr" | "it"; legislative_act?: string; sort?: "title" | "-title" | "date" | "-date"; page?: number; }) => {
      const { search, language, legislative_act, sort, page } = args;
      const queryParams = new URLSearchParams({
          ...(search && { search }),
          ...(language && { language }),
          ...(legislative_act && { legislative_act }),
          ...(sort && { sort }),
          ...(page && { page: page.toString() }),
      });
    
      try {
          const response = await fetch(`${API_BASE_URL}/commentaries?${queryParams.toString()}`, {
              headers: { "Accept": "application/json" }
          });
    
          if (!response.ok) {
              throw new Error(`API request failed with status ${response.status}`);
          }
    
          const data = (await response.json()) as { data: Commentary[] };
          const commentaries = data.data;
          const resultText = commentaries.length > 0
              ? commentaries.map(c => `ID: ${c.id}\nTitle: ${c.title}\nDate: ${c.date}\nURL: ${c.html_link}`).join("\n\n")
              : "No commentaries found for the given criteria.";
    
          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 searching commentaries: ${errorMessage}` }],
              isError: true,
          };
      }
    }
  • Zod-based input schema defining parameters for the 'search_commentaries' tool: search query, optional filters for language, legislative act, sort order, and pagination.
    inputSchema: {
      search: z.string().describe("The full-text search query."),
      language: z.enum(["en", "de", "fr", "it"]).optional().describe("Content language."),
      legislative_act: z.string().optional().describe("Filter by legislative act ID."),
      sort: z.enum(["title", "-title", "date", "-date"]).optional().describe("Sort order."),
      page: z.number().optional().describe("Page number for pagination."),
    },
  • src/index.ts:39-88 (registration)
    Registration of the 'search_commentaries' tool on the MCP server, including name, metadata, input schema, and handler reference.
    server.registerTool(
      "search_commentaries",
      {
        title: "Search Commentaries",
        description: "Searches for legal commentaries based on a query and filters.",
        inputSchema: {
          search: z.string().describe("The full-text search query."),
          language: z.enum(["en", "de", "fr", "it"]).optional().describe("Content language."),
          legislative_act: z.string().optional().describe("Filter by legislative act ID."),
          sort: z.enum(["title", "-title", "date", "-date"]).optional().describe("Sort order."),
          page: z.number().optional().describe("Page number for pagination."),
        },
      },
      async (args: { search: string; language?: "en" | "de" | "fr" | "it"; legislative_act?: string; sort?: "title" | "-title" | "date" | "-date"; page?: number; }) => {
        const { search, language, legislative_act, sort, page } = args;
        const queryParams = new URLSearchParams({
            ...(search && { search }),
            ...(language && { language }),
            ...(legislative_act && { legislative_act }),
            ...(sort && { sort }),
            ...(page && { page: page.toString() }),
        });
    
        try {
            const response = await fetch(`${API_BASE_URL}/commentaries?${queryParams.toString()}`, {
                headers: { "Accept": "application/json" }
            });
    
            if (!response.ok) {
                throw new Error(`API request failed with status ${response.status}`);
            }
    
            const data = (await response.json()) as { data: Commentary[] };
            const commentaries = data.data;
            const resultText = commentaries.length > 0
                ? commentaries.map(c => `ID: ${c.id}\nTitle: ${c.title}\nDate: ${c.date}\nURL: ${c.html_link}`).join("\n\n")
                : "No commentaries found for the given criteria.";
    
            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 searching commentaries: ${errorMessage}` }],
                isError: true,
            };
        }
      }
    );
Behavior2/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 of behavioral disclosure. It states the tool 'searches' but doesn't clarify if this is a read-only operation, what the expected response format is, whether there are rate limits, authentication requirements, or pagination behavior beyond the 'page' parameter. This leaves significant gaps in understanding how the tool behaves in practice.

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 that directly states the tool's function without unnecessary words. It's front-loaded with the core action and resource, making it easy to parse quickly. Every part of the sentence contributes to understanding the tool's purpose.

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?

Given the complexity of a search tool with 5 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain what a 'legal commentary' is, the search scope, result format, or behavioral aspects like error handling. This leaves the agent with insufficient context to use the tool effectively beyond basic parameter input.

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 documents all parameters thoroughly. The description adds minimal value by mentioning 'filters' generically, but doesn't elaborate on specific parameters like 'legislative_act' or 'sort' beyond what the schema provides. This meets the baseline for high schema coverage, but doesn't enhance parameter understanding.

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 action ('searches for') and resource ('legal commentaries'), making the purpose understandable. It distinguishes from the sibling tool 'get_commentary_by_id' by indicating this is a search operation rather than retrieval by specific ID. However, it doesn't specify what constitutes a 'legal commentary' or the search scope beyond 'based on a query and filters,' which keeps it from being fully specific.

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?

The description provides no guidance on when to use this tool versus alternatives. It mentions 'filters' but doesn't specify which filters are available or when to apply them. There's no mention of prerequisites, limitations, or comparison to the sibling tool 'get_commentary_by_id,' leaving the agent without clear usage context.

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