Skip to main content
Glama
yoda-digital

Cerebra Legal MCP Server

by yoda-digital

legal_think

Analyze complex legal issues by breaking them into structured steps, verifying compliance requirements, and building comprehensive arguments with proper citations.

Instructions

A powerful tool for structured legal reasoning that helps analyze complex legal issues. This tool provides domain-specific guidance and templates for different legal areas including ANSC contestations, consumer protection, and contract analysis.

When to use this tool:

  • Breaking down complex legal problems into structured steps

  • Analyzing legal requirements and compliance

  • Verifying that all elements of a legal test are addressed

  • Building comprehensive legal arguments with proper citations

Key features:

  • Automatic detection of legal domains

  • Domain-specific guidance and templates

  • Support for legal citations and references

  • Revision capabilities for refining legal arguments

  • Thought quality feedback

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
thoughtYesThe main legal reasoning content
categoryNoCategory of legal reasoning (optional, will be auto-detected if not provided)
referencesNoReferences to laws, regulations, precedents, or previous thoughts (optional)
isRevisionNoWhether this thought revises a previous legal reasoning (optional)
revisesThoughtNumberNoThe thought number being revised (if isRevision is true)
requestGuidanceNoSet to true to receive domain-specific legal guidance
requestTemplateNoSet to true to receive a template for this type of legal reasoning
thoughtNumberYesCurrent thought number
totalThoughtsYesEstimated total thoughts needed
nextThoughtNeededYesWhether another thought step is needed

Implementation Reference

  • The primary handler function that implements the core logic for the 'legal_think' tool. It validates input, detects the legal domain, manages thought history, provides guidance/templates as needed, formats and logs the thought, and returns a structured JSON response.
    function processLegalThink(input: unknown): { content: Array<{ type: string; text: string }>; isError?: boolean } { try { const data = input as Record<string, unknown>; // Validate input if (!data.thought || typeof data.thought !== 'string') { throw new Error('Invalid thought: must be a string'); } if (!data.thoughtNumber || typeof data.thoughtNumber !== 'number') { throw new Error('Invalid thoughtNumber: must be a number'); } if (!data.totalThoughts || typeof data.totalThoughts !== 'number') { throw new Error('Invalid totalThoughts: must be a number'); } if (typeof data.nextThoughtNeeded !== 'boolean') { throw new Error('Invalid nextThoughtNeeded: must be a boolean'); } // Detect domain const domain = data.category as string || detectDomain(data.thought as string); // Add to thought history thoughtHistory.push({ ...data, domain, timestamp: new Date() }); // Determine if guidance or templates should be provided let guidance = undefined; let template = undefined; if (data.requestGuidance || data.thoughtNumber === 1) { guidance = domainGuidance[domain] || domainGuidance["legal_reasoning"]; } if (data.requestTemplate || data.thoughtNumber === 1) { template = domainTemplates[domain] || domainTemplates["legal_reasoning"]; } // Format the thought for logging const formattedThought = formatThought( data.thought as string, domain, data.thoughtNumber as number, data.totalThoughts as number, data.isRevision as boolean, data.revisesThoughtNumber as number ); // Log the formatted thought console.error(formattedThought); // Prepare response return { content: [{ type: "text", text: JSON.stringify({ thoughtNumber: data.thoughtNumber, totalThoughts: data.totalThoughts, nextThoughtNeeded: data.nextThoughtNeeded, detectedDomain: domain, guidance, template, thoughtHistoryLength: thoughtHistory.length }, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: JSON.stringify({ error: error instanceof Error ? error.message : String(error), status: 'failed' }, null, 2) }], isError: true }; } }
  • The input schema definition for the legal_think tool, specifying properties, types, descriptions, and required fields for input validation.
    inputSchema: { type: "object", properties: { thought: { type: "string", description: "The main legal reasoning content" }, category: { type: "string", enum: [ "analysis", "planning", "verification", "legal_reasoning", "ansc_contestation", "consumer_protection", "contract_analysis" ], description: "Category of legal reasoning (optional, will be auto-detected if not provided)" }, references: { type: "array", items: { type: "string" }, description: "References to laws, regulations, precedents, or previous thoughts (optional)" }, isRevision: { type: "boolean", description: "Whether this thought revises a previous legal reasoning (optional)" }, revisesThoughtNumber: { type: "integer", description: "The thought number being revised (if isRevision is true)" }, requestGuidance: { type: "boolean", description: "Set to true to receive domain-specific legal guidance" }, requestTemplate: { type: "boolean", description: "Set to true to receive a template for this type of legal reasoning" }, thoughtNumber: { type: "integer", description: "Current thought number", minimum: 1 }, totalThoughts: { type: "integer", description: "Estimated total thoughts needed", minimum: 1 }, nextThoughtNeeded: { type: "boolean", description: "Whether another thought step is needed" } }, required: ["thought", "thoughtNumber", "totalThoughts", "nextThoughtNeeded"] }
  • src/index.ts:15-92 (registration)
    The Tool object definition for 'legal_think', including name, description, and input schema, used for registration.
    const LEGAL_THINK_TOOL: Tool = { name: "legal_think", description: `A powerful tool for structured legal reasoning that helps analyze complex legal issues. This tool provides domain-specific guidance and templates for different legal areas including ANSC contestations, consumer protection, and contract analysis. When to use this tool: - Breaking down complex legal problems into structured steps - Analyzing legal requirements and compliance - Verifying that all elements of a legal test are addressed - Building comprehensive legal arguments with proper citations Key features: - Automatic detection of legal domains - Domain-specific guidance and templates - Support for legal citations and references - Revision capabilities for refining legal arguments - Thought quality feedback`, inputSchema: { type: "object", properties: { thought: { type: "string", description: "The main legal reasoning content" }, category: { type: "string", enum: [ "analysis", "planning", "verification", "legal_reasoning", "ansc_contestation", "consumer_protection", "contract_analysis" ], description: "Category of legal reasoning (optional, will be auto-detected if not provided)" }, references: { type: "array", items: { type: "string" }, description: "References to laws, regulations, precedents, or previous thoughts (optional)" }, isRevision: { type: "boolean", description: "Whether this thought revises a previous legal reasoning (optional)" }, revisesThoughtNumber: { type: "integer", description: "The thought number being revised (if isRevision is true)" }, requestGuidance: { type: "boolean", description: "Set to true to receive domain-specific legal guidance" }, requestTemplate: { type: "boolean", description: "Set to true to receive a template for this type of legal reasoning" }, thoughtNumber: { type: "integer", description: "Current thought number", minimum: 1 }, totalThoughts: { type: "integer", description: "Estimated total thoughts needed", minimum: 1 }, nextThoughtNeeded: { type: "boolean", description: "Whether another thought step is needed" } }, required: ["thought", "thoughtNumber", "totalThoughts", "nextThoughtNeeded"] } };
  • src/index.ts:821-827 (registration)
    Registration of the legal_think tool in the MCP listTools request handler.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ LEGAL_THINK_TOOL, LEGAL_ASK_FOLLOWUP_QUESTION_TOOL, LEGAL_ATTEMPT_COMPLETION_TOOL ], }));
  • src/index.ts:832-834 (registration)
    Dispatch/registration of the legal_think tool handler in the MCP callTool request handler.
    if (request.params.name === "legal_think") { return processLegalThink(request.params.arguments); }

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/yoda-digital/mcp-cerebra-legal-server'

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