Code2MCP-FoamAgent / README.md
kabudadada
Update README: convert to English, simplify environment config, and update secrets section
3de53ca
metadata
title: Code2MCP-FoamAgent
emoji: 🧪
colorFrom: blue
colorTo: green
sdk: docker
sdk_version: 4.26.0
app_file: app.py
pinned: false

Code2MCP-FoamAgent

MCP (Model Context Protocol) service wrapper for Foam-Agent, providing natural language-based OpenFOAM CFD simulation workflows.

Features

  • 🧪 Natural language CFD simulation requirements
  • 🤖 Multi-agent workflow automation
  • 📊 Automatic error detection and correction
  • 🔧 Custom mesh support (GMSH .msh files)
  • 🌐 Multiple LLM provider support

Quick Start

1. Environment Configuration

Environment variables are configured in Hugging Face Spaces secrets. No local configuration needed.

2. Install Dependencies

Using conda (Recommended)

# Create conda environment
conda env create -f environment.yml

# Activate environment
conda activate openfoamAgent

# Install additional MCP dependencies
pip install fastapi uvicorn[standard] fastmcp

3. Run MCP Service

python Foam-Agent/mcp_output/start_mcp.py

4. Docker Deployment

Using environment variables

# Build image
docker build -t code2mcp-foamagent .

# Run container (set environment variables)
docker run -p 7860:7860 \
  -e OPENAI_API_KEY=your_api_key_here \
  -e OPENAI_BASE_URL=https://api.openai.com/v1 \
  code2mcp-foamagent

5. Hugging Face Spaces Deployment

Environment variables are configured in Hugging Face Spaces secrets. The service is ready to use once deployed.

Note: Due to Hugging Face Spaces limitations, OpenFOAM may not run completely, but the MCP service itself can work normally.

Usage

Basic CFD Simulation

# Run simple CFD simulation
result = run_foam_agent(
    requirements="Do an incompressible lid driven cavity flow...",
    output_dir="./output"
)

Using Custom Mesh

# Use custom GMSH mesh file
result = run_foam_agent(
    requirements="Simulate flow over a tandem wing...",
    output_dir="./output",
    custom_mesh="./tandem_wing.msh"
)

Complete Benchmark

# Run complete Foam-Agent benchmark
result = run_foam_benchmark(
    openfoam_path="/opt/openfoam10",
    requirements="Your CFD requirements...",
    output_dir="./output"
)

Environment Secrets

Variable Description Required
OPENAI_API_KEY OpenAI API key Yes
OPENAI_BASE_URL OpenAI API base URL No

System Requirements

  • Python 3.11+
  • OpenFOAM v10
  • OpenAI API key or other LLM provider
  • Preprocessed OpenFOAM database

Troubleshooting

  1. Check system status: Use check_foam_agent_status tool
  2. Verify API configuration: Ensure API key and URL are correctly set
  3. Check dependencies: Ensure all Python packages are properly installed
  4. OpenFOAM environment: Ensure OpenFOAM is properly installed and configured

License

MIT License