Skip to main content
Glama
yoda-digital

Cerebra Legal MCP Server

by yoda-digital

legal_attempt_completion

Formats legal analysis results into structured documents with proper citations and professional formatting for clear communication of findings and recommendations.

Instructions

A specialized tool for presenting legal analysis results and conclusions. This tool formats legal conclusions with proper structure, extracts and formats citations, and provides a professional legal document format.

When to use this tool:

  • When presenting the final results of a legal analysis

  • When summarizing legal findings and recommendations

  • When providing a structured legal opinion

  • When concluding a legal reasoning process

Key features:

  • Automatic detection of legal domains

  • Proper legal document formatting

  • Citation extraction and formatting

  • Structured sections for clear communication

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYesThe legal analysis result or conclusion
commandNoA CLI command to execute (optional)
contextNoAdditional context about the legal issue (optional)

Implementation Reference

  • The primary handler function for the 'legal_attempt_completion' tool. It validates input, detects the legal domain, formats the result using helper functions if needed, and returns a structured ToolResponse.
    function processLegalAttemptCompletion(input: unknown): { content: Array<{ type: string; text: string }>; isError?: boolean } { try { const data = input as Record<string, unknown>; // Validate input if (!data.result || typeof data.result !== 'string') { throw new Error('Invalid result: must be a string'); } // Detect domain from result and context const textToAnalyze = data.context ? `${data.result} ${data.context}` : data.result as string; const domain = detectDomain(textToAnalyze); // Format the result with proper legal structure let result = data.result as string; // If result doesn't have a good structure, apply template if (!hasGoodStructure(result)) { result = applyTemplateStructure(result, domain); } // Prepare response return { content: [{ type: "text", text: JSON.stringify({ result, command: data.command, detectedDomain: domain, formattedCitations: [] }, 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 }; } }
  • src/index.ts:133-167 (registration)
    Tool registration definition including name, description, and input schema. This object is returned in ListTools and dispatched in CallToolRequestHandler.
    const LEGAL_ATTEMPT_COMPLETION_TOOL: Tool = { name: "legal_attempt_completion", description: `A specialized tool for presenting legal analysis results and conclusions. This tool formats legal conclusions with proper structure, extracts and formats citations, and provides a professional legal document format. When to use this tool: - When presenting the final results of a legal analysis - When summarizing legal findings and recommendations - When providing a structured legal opinion - When concluding a legal reasoning process Key features: - Automatic detection of legal domains - Proper legal document formatting - Citation extraction and formatting - Structured sections for clear communication`, inputSchema: { type: "object", properties: { result: { type: "string", description: "The legal analysis result or conclusion" }, command: { type: "string", description: "A CLI command to execute (optional)" }, context: { type: "string", description: "Additional context about the legal issue (optional)" } }, required: ["result"] } };
  • TypeScript interfaces defining the input and output structures for the legal_attempt_completion tool.
    export interface LegalAttemptCompletionInput { result: string; command?: string; context?: string; } /** * Legal attempt completion response data */ export interface LegalAttemptCompletionResponse { result: string; command?: string; detectedDomain: string; formattedCitations: string[]; }
  • Helper function used by the handler to determine if the input result already has good legal structure, avoiding unnecessary reformatting.
    function hasGoodStructure(result: string): boolean { // Check for section headers (numbered or with clear titles) const hasNumberedSections = /\n\s*\d+\.\s+[A-Z]/.test(result); const hasTitledSections = /\n\s*[A-Z][a-zA-Z\s]+:/.test(result); // Check for bullet points const hasBulletPoints = /\n\s*[-•*]\s+/.test(result); // Check for clear paragraphs const hasClearParagraphs = result.split('\n\n').length >= 3; return (hasNumberedSections || hasTitledSections) && (hasBulletPoints || hasClearParagraphs); }
  • Helper function that applies domain-specific template structure to the result when the original lacks proper formatting.
    function applyTemplateStructure(result: string, domain: string): string { // Get domain-specific completion template const template = domainCompletionTemplates[domain] || domainCompletionTemplates["legal_reasoning"]; // Add a title based on domain let formattedResult = ''; switch (domain) { case 'ansc_contestation': formattedResult += 'Legal Analysis Summary:\n\n'; break; case 'consumer_protection': formattedResult += 'Consumer Protection Analysis:\n\n'; break; case 'contract_analysis': formattedResult += 'Contract Analysis Report:\n\n'; break; default: formattedResult += 'Legal Analysis Report:\n\n'; } // Add a brief introduction formattedResult += `${result}\n\n`; // Add template structure formattedResult += template.split('\n\n').slice(1).join('\n\n'); return formattedResult; }

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