MCP ExplorerExplorer

Mcp For Tikz

@bee4comeon a month ago
0 MIT
FreeCommunity
AI Systems
MCP for TikZ Feynman generates LaTeX TikZ-Feynman code from natural language descriptions.

Overview

What is Mcp For Tikz

MCP-for-Tikz- is an AI-driven tool designed to automatically generate LaTeX TikZ-Feynman diagram code from natural language descriptions. It aims to simplify the process for researchers and students creating Feynman diagrams in LaTeX.

Use cases

Use cases include generating Feynman diagrams for research papers, educational materials, and presentations, as well as assisting students in learning and visualizing complex physical processes.

How to use

To use MCP-for-Tikz-, clone the repository, create and activate a Conda environment, install the required dependencies, set up your API key in the .env file, prepare the knowledge base data source, and build the local knowledge base.

Key features

Key features include natural language to TikZ code conversion, local knowledge base retrieval, and integration with Google Gemini API for enhanced code generation.

Where to use

MCP-for-Tikz- can be used in academic and research settings, particularly in fields related to physics and computational science where Feynman diagrams are commonly utilized.

Content

Particle Physics Agent

AI-powered Feynman Diagram Generator - Built with Google Agent Development Kit (ADK)

Version
License
Python

Table of Contents

Overview

An intelligent multi-agent system that generates TikZ Feynman diagram code from natural language descriptions. Features physics validation through MCP integration, local knowledge base search, and supports both Chinese and English input.

Hackathon Submission

Hosted Project

Demo Local URL: http://localhost:8000 (Local hosting - requires setup as described below)

Demo Public URL: https://particle-physics-agent-service-354229141951.us-central1.run.app/dev-ui/?app=feynmancraft_adk

Note: This project runs locally due to API key requirements and specialized dependencies. Follow the Quick Setup guide below for local deployment and testing.

Public Repository

GitHub Repository: https://github.com/bee4come/Particle-Physics-Agent

Language Support

This project fully supports English language use as required, with additional Chinese language support for enhanced accessibility.

Project Summary

Features and Functionality

The Particle Physics Agent is a sophisticated AI system that transforms natural language descriptions of particle physics processes into professional, compilable TikZ-Feynman LaTeX code. Key functionality includes:

  • Natural Language Processing: Converts English and Chinese descriptions into structured physics concepts
  • Multi-Agent Orchestration: Six specialized agents collaborate through Google’s ADK framework
  • Physics Validation: Real-time validation using Particle Data Group (PDG) data via MCP protocol
  • Knowledge Base Search: Vector-based similarity search through 150+ curated examples
  • Error Correction: Automated validation with iterative correction (up to 3 attempts)
  • Quality Assurance: 95%+ success rate for generating compilable diagram code

Technologies Used

  • Google Agent Development Kit (ADK) 1.0.0: Multi-agent orchestration framework
  • Google Gemini 2.0 Flash: Advanced language model for all agent operations
  • Model Context Protocol (MCP): Standardized integration with physics databases
  • TikZ-Feynman: Professional LaTeX package for physics diagrams
  • Annoy: High-performance vector similarity search engine
  • Pydantic: Data validation and serialization

Data Sources Overview

  1. Particle Data Group (PDG): Authoritative particle physics database accessed via ParticlePhysics MCP Server
  2. Curated Knowledge Base: 150+ professionally selected Feynman diagram examples with TikZ code
  3. Physics Rules Database: Custom validation rules for conservation laws and particle interactions
  4. Vector Embeddings: Semantic search capabilities for example retrieval

Findings and Learnings

Through development, we discovered several key insights:

Technical Breakthroughs:

  • Sequential multi-agent execution with validation loops significantly outperforms parallel processing for complex code generation (95% vs 70% success rate)
  • MCP protocol provides excellent standardization for integrating specialized physics tools
  • Vector similarity search with curated examples reduces AI hallucination and improves accuracy
  • Iterative error correction with up to 3 attempts ensures reliable code generation

Development Challenges Solved:

  • Built robust TikZ-Feynman syntax validation requiring specialized environment
  • Balanced comprehensive physics validation with performance optimization
  • Implemented multilingual support while maintaining technical accuracy across languages
  • Created reliable error recovery mechanisms for complex diagram generation

Performance Achievements:

  • 95%+ diagram generation success rate with guaranteed compilation
  • Sub-30 second generation time for complex multi-particle interactions
  • 100% physics validation accuracy through MCP integration
  • Support for both English and Chinese technical input

Innovation Impact:
This project represents the first known implementation of Google’s ADK for scientific applications and demonstrates novel use of MCP for particle physics validation, creating a practical tool for researchers and educators worldwide.

Key Features

  • Multi-Agent Architecture: 6 specialized agents working collaboratively
  • Physics Validation: MCP-enhanced validation using ParticlePhysics MCP Server and local physics rules
  • Knowledge Base: Vector search with 150+ curated physics examples
  • Natural Language: Chinese and English input support
  • High-Quality Output: Professional TikZ-Feynman LaTeX code generation with 95%+ success rate
  • Quality Assurance: Automatic validation and error correction (up to 3 attempts)

Quick Setup

Prerequisites

  • Python 3.9+
  • Google AI API Key
  • Conda (recommended)

Installation

git clone https://github.com/bee4come/Particle-Physics-Agent.git
cd Particle-Physics-Agent
conda create --name fey python=3.11 -y
conda activate fey
pip install -r requirements.txt

Configuration

Create .env file:

GOOGLE_API_KEY="your_google_ai_api_key_here"
GOOGLE_CLOUD_PROJECT="your-gcp-project-id"

Launch Web Interface

# Direct launch
adk web --port=8000 --host=127.0.0.1 feynmancraft_adk

Access at: http://localhost:8000

How It Works

Agent Workflow

User Input → Planning → Knowledge Retrieval → Physics Validation
                ↓              ↓                   ↓
           Code Generation → Syntax Validation → Final Output

Specialized Agents

  • PlannerAgent: Natural language parsing and task orchestration
  • KBRetrieverAgent: Knowledge base search and retrieval
  • PhysicsValidatorAgent: Physics validation with MCP tools from ParticlePhysics MCP Server and local physics rule database
  • DiagramGeneratorAgent: Expert TikZ-Feynman code generation
  • TikZValidatorAgent: Syntax validation
  • FeedbackAgent: Result synthesis and quality assurance

Example Usage

Input:

“Generate a Feynman diagram for electron-positron annihilation producing two photons”

Process:

  1. Parse natural language request
  2. Search knowledge base for relevant examples
  3. Validate physics correctness using MCP tools
  4. Generate optimized TikZ code
  5. Validate syntax
  6. Return complete, compilable diagram code

Technology Stack

Core Framework

  • Google ADK 1.0.0: Multi-agent orchestration framework
  • Google Gemini: Advanced language model (gemini-2.0-flash)
  • MCP Integration: Particle physics tools via ParticlePhysics MCP Server

Physics & Data

  • TikZ-Feynman: Professional physics diagram generation
  • PDG (Particle Data Group): Authoritative physics database access
  • Local Knowledge Base: 150+ curated Feynman diagram examples

Machine Learning & Search

  • Annoy: High-performance vector similarity search
  • Pydantic: Data validation and serialization
  • NumPy/SciPy: Scientific computing

Web & Integration

  • Modern web framework: For application interface

Data Sources

1. Particle Data Group (PDG)

  • Access via ParticlePhysics MCP Server
  • Comprehensive particle properties, masses, lifetimes
  • Decay channels and branching ratios
  • Latest physics data and measurements

2. Curated Knowledge Base

  • 150+ hand-selected Feynman diagram examples
  • Professional TikZ-Feynman code samples
  • Physics process descriptions and explanations
  • Vector embeddings for semantic search

3. Physics Rules Database

  • Conservation law validation rules
  • Particle interaction constraints
  • Standard Model compliance checks
  • Custom physics validation logic

System Architecture

Architecture Diagram

The following diagram illustrates the complete system architecture, showing how different technologies interact within the multi-agent framework:

graph TB
    subgraph "User Interface"
        UI[Web Interface<br/>Modern Framework]
    end
    
    subgraph "Google ADK Framework"
        ROOT[Root Agent<br/>Orchestrator]
        PA[Planner Agent<br/>NL Processing]
        KBA[KB Retriever Agent<br/>Vector Search]
        PVA[Physics Validator Agent<br/>MCP Integration]
        DGA[Diagram Generator Agent<br/>TikZ Generation]
        TVA[TikZ Validator Agent<br/>Syntax Validation]
        FA[Feedback Agent<br/>Result Synthesis]
    end
    
    subgraph "External Services"
        GEMINI[Google Gemini 2.0<br/>Language Model]
        MCP[ParticlePhysics MCP Server<br/>Physics Validation]
        PDG[Particle Data Group<br/>Physics Database]
    end
    
    subgraph "Local Data Sources"
        KB[Knowledge Base<br/>150+ Examples]
        VDB[Vector Database<br/>Annoy Index]
        PR[Physics Rules<br/>Local Validation]
        EMB[Embeddings<br/>Semantic Search]
    end
    
    subgraph "Processing & Validation"
        COMP[Code Compiler<br/>TikZ-Feynman]
        VC[Validation Loop<br/>Error Correction]
    end
    
    subgraph "Output"
        OUTPUT[TikZ Diagram Code<br/>Compilable Output]
    end
    
    UI --> ROOT
    ROOT --> PA
    PA --> KBA
    KBA --> PVA
    PVA --> DGA
    DGA --> TVA
    TVA --> FA
    FA --> ROOT
    
    ROOT <--> GEMINI
    PA <--> GEMINI
    KBA <--> GEMINI
    PVA <--> GEMINI
    DGA <--> GEMINI
    TVA <--> GEMINI
    FA <--> GEMINI
    
    KBA <--> KB
    KBA <--> VDB
    KBA <--> EMB
    
    PVA <--> MCP
    PVA <--> PR
    MCP <--> PDG
    
    TVA <--> COMP
    TVA <--> VC
    
    VC --> DGA
    FA --> OUTPUT
    
    style ROOT fill:#e1f5fe
    style GEMINI fill:#fff3e0
    style MCP fill:#f3e5f5
    style KB fill:#e8f5e8
    style OUTPUT fill:#fff8e1

Multi-Agent Coordination

The system follows a sophisticated workflow with validation loops ensuring 100% compilable output:

  1. Sequential Processing: Discovered that sequential agent execution with validation loops produces higher quality results than parallel processing for complex code generation tasks
  2. Error Recovery: Iterative correction loops (up to 3 attempts) improved success rates from ~70% to ~95%
  3. Physics Integration: MCP protocol provides excellent standardization for external tool integration

Key Achievements

  • High Success Rate: 95%+ diagram generation success rate with proper compilation
  • Physics Accuracy: 100% physics validation through MCP integration
  • Performance: Sub-30 second generation time for complex diagrams
  • Multilingual Support: Breakthrough in supporting multiple languages for technical physics content

Innovation Highlights

  1. First ADK Implementation: Pioneer implementation of Google’s Agent Development Kit for physics applications
  2. MCP Physics Integration: Novel use of Model Context Protocol for particle physics validation
  3. Validation Loop Architecture: Innovative error correction mechanism ensuring compilable output
  4. Multilingual Physics AI: Advanced support for Chinese and English technical content

Development Insights

Technical Findings

  1. Multi-Agent Benefits: Sequential execution with validation loops produces superior results for complex code generation
  2. Knowledge Base Optimization: Vector similarity search with curated examples outperformed purely generative approaches
  3. Error Handling: Robust validation environment with proper error reporting was crucial for success

Challenges Solved

  1. Syntax Validation: Built comprehensive TikZ-Feynman syntax validation
  2. Physics Accuracy: Balanced comprehensive validation with performance optimization
  3. Multi-language Processing: Maintained physics accuracy across language barriers

Future Improvements

  • Integration with additional physics databases (CERN, arXiv)
  • Support for more diagram types (energy level diagrams, decay chains)
  • Interactive diagram editing capabilities
  • Batch processing for research applications

License

Dual-licensed under MIT and Apache 2.0 licenses.

Acknowledgments

  • ParticlePhysics MCP Server - Comprehensive MCP server providing specialized particle physics tools across 8 modules for PDG data access

Maintainers

@bee4come
@uzerone

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers