Skip to main content
Glama

LangExtract MCP Server

by larsenweigle

generate_visualization

Create interactive HTML visualizations from extracted data using JSONL files. Highlights entities in context with color coding and hover details, ideal for analyzing large datasets.

Instructions

Generate interactive HTML visualization from extraction results.

Creates an interactive HTML file that shows extracted entities highlighted in their original text context. The visualization is self-contained and can handle thousands of entities with color coding and hover details.

Args: jsonl_file_path: Path to the JSONL file containing extraction results output_html_path: Optional path for the HTML output (default: auto-generated)

Returns: Dictionary with HTML file path and generation details

Raises: ToolError: If visualization generation fails

Input Schema

NameRequiredDescriptionDefault
jsonl_file_pathYes
output_html_pathNo

Input Schema (JSON Schema)

{ "properties": { "jsonl_file_path": { "title": "Jsonl File Path", "type": "string" }, "output_html_path": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Output Html Path" } }, "required": [ "jsonl_file_path" ], "type": "object" }

Implementation Reference

  • The core handler function for the 'generate_visualization' tool. It is decorated with @mcp.tool for registration. Reads extraction results from a JSONL file and generates an interactive HTML visualization using langextract's lx.visualize() function, saving it to an HTML file.
    @mcp.tool def generate_visualization( jsonl_file_path: str, output_html_path: str | None = None ) -> dict[str, str]: """ Generate interactive HTML visualization from extraction results. Creates an interactive HTML file that shows extracted entities highlighted in their original text context. The visualization is self-contained and can handle thousands of entities with color coding and hover details. Args: jsonl_file_path: Path to the JSONL file containing extraction results output_html_path: Optional path for the HTML output (default: auto-generated) Returns: Dictionary with HTML file path and generation details Raises: ToolError: If visualization generation fails """ try: # Validate input file exists input_path = Path(jsonl_file_path) if not input_path.exists(): raise ToolError(f"Input file not found: {jsonl_file_path}") # Generate visualization using langextract html_content = lx.visualize(str(input_path)) # Determine output path if output_html_path: output_path = Path(output_html_path) else: output_path = input_path.parent / f"{input_path.stem}_visualization.html" # Ensure output directory exists output_path.parent.mkdir(parents=True, exist_ok=True) # Write HTML file with open(output_path, 'w', encoding='utf-8') as f: f.write(html_content) return { "message": "Visualization generated successfully", "html_file_path": str(output_path.absolute()), "file_size_bytes": len(html_content.encode('utf-8')) } except Exception as e: raise ToolError(f"Failed to generate visualization: {str(e)}")

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/larsenweigle/langextract-mcp'

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