Skip to main content
Glama

search_case_law

Search and retrieve Swiss court decisions using a structured query. Access legal documents from Swiss jurisdictions for analysis or reference, with options for pagination and result size.

Instructions

Search for Swiss court decisions using Entscheidsuche database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fromNoStarting position for pagination
queryYesSearch query for legal cases
sizeNoNumber of results to return (max 50)

Implementation Reference

  • The handler function that executes the 'search_case_law' tool logic. It limits the result size, calls the client's searchCases method, formats the results into a structured output, and handles errors.
    async ({ query, size = 10, from = 0 }) => { try { // Limit size to prevent abuse const limitedSize = Math.min(size, 50); const results = await client.searchCases(query, limitedSize, from); const formattedResults = results.hits.hits.map(hit => { const source = hit._source; return { signature: hit._id, court: source.hierarchy[1] || source.canton, language: source.attachment.language, date: source.date, case_number: source.reference[0] || '', title_de: source.title.de, title_fr: source.title.fr, title_it: source.title.it, abstract_de: source.abstract?.de || '', abstract_fr: source.abstract?.fr || '', abstract_it: source.abstract?.it || '', has_html: !!source.attachment.content_url, has_pdf: false, // PDF availability not indicated in new structure document_url: source.attachment.content_url, scrapedate: source.scrapedate }; }); const summary = `Found ${results.hits.total.value} total cases matching "${query}". Showing ${formattedResults.length} results starting from position ${from}.`; return { content: [ { type: "text", text: `${summary}\n\n${JSON.stringify(formattedResults, null, 2)}` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error searching case law: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } }
  • Input schema for the 'search_case_law' tool using Zod, defining parameters query, size, and from.
    inputSchema: { query: z.string().describe("Search query for legal cases"), size: z.number().optional().default(10).describe("Number of results to return (max 50)"), from: z.number().optional().default(0).describe("Starting position for pagination") }
  • src/index.ts:210-270 (registration)
    Registration of the 'search_case_law' tool with the MCP server, specifying the tool name, metadata, input schema, and handler function.
    "search_case_law", { title: "Search Swiss Case Law", description: "Search for Swiss court decisions using Entscheidsuche database", inputSchema: { query: z.string().describe("Search query for legal cases"), size: z.number().optional().default(10).describe("Number of results to return (max 50)"), from: z.number().optional().default(0).describe("Starting position for pagination") } }, async ({ query, size = 10, from = 0 }) => { try { // Limit size to prevent abuse const limitedSize = Math.min(size, 50); const results = await client.searchCases(query, limitedSize, from); const formattedResults = results.hits.hits.map(hit => { const source = hit._source; return { signature: hit._id, court: source.hierarchy[1] || source.canton, language: source.attachment.language, date: source.date, case_number: source.reference[0] || '', title_de: source.title.de, title_fr: source.title.fr, title_it: source.title.it, abstract_de: source.abstract?.de || '', abstract_fr: source.abstract?.fr || '', abstract_it: source.abstract?.it || '', has_html: !!source.attachment.content_url, has_pdf: false, // PDF availability not indicated in new structure document_url: source.attachment.content_url, scrapedate: source.scrapedate }; }); const summary = `Found ${results.hits.total.value} total cases matching "${query}". Showing ${formattedResults.length} results starting from position ${from}.`; return { content: [ { type: "text", text: `${summary}\n\n${JSON.stringify(formattedResults, null, 2)}` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error searching case law: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } } );
  • Supporting method in EntscheidungsucheClient that performs the actual API search to the Entscheidsuche endpoint, used by the tool handler.
    async searchCases(query: string, size: number = 10, from: number = 0): Promise<SearchResult> { const searchBody = { query: { simple_query_string: { query: query, default_operator: "and" } }, size, from, sort: [{ date: { order: "desc" } }] }; const response = await fetch(this.searchEndpoint, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify(searchBody) }); if (!response.ok) { throw new Error(`Search failed: ${response.status} ${response.statusText}`); } return await response.json(); }

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/self-tech-labs/entscheidsuche-MCP-server'

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