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);
    }
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions key features like automatic domain detection, guidance/templates, citation support, revision capabilities, and thought quality feedback, which gives useful context about how the tool behaves. However, it doesn't address important behavioral aspects like whether this is a read-only analysis tool or if it modifies data, what permissions might be needed, or any rate limits.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear sections (purpose, when to use, key features) and each sentence adds value. It's appropriately sized for a complex tool with 10 parameters, though the 'Key features' section could be more concise as some items overlap with earlier content.

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

Completeness3/5

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

For a complex legal reasoning tool with 10 parameters and no annotations or output schema, the description provides good purpose and usage context but has significant gaps. It doesn't explain what the tool outputs (no output schema), doesn't address behavioral constraints, and while it mentions legal domains, it doesn't fully explain how the complex parameter set works together for the reasoning process.

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 10 parameters thoroughly. The description doesn't add any specific parameter information beyond what's in the schema - it mentions general capabilities like domain detection and revision, but doesn't explain how parameters like 'category' or 'isRevision' relate to these features. Baseline 3 is appropriate when the schema does the heavy lifting.

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 tool's purpose as 'structured legal reasoning that helps analyze complex legal issues' and mentions specific legal domains like ANSC contestations, consumer protection, and contract analysis. It distinguishes itself from siblings by focusing on reasoning rather than follow-up questions or completion attempts, though it doesn't explicitly contrast with them.

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 'When to use this tool' section provides clear guidance on four specific scenarios like breaking down complex legal problems and analyzing legal requirements. It doesn't mention when NOT to use it or explicitly name sibling tools as alternatives, but the context is well-defined for legal reasoning tasks.

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

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