Skip to main content
Glama
README.md
# PyMemSim-MCP

[![PyPI Downloads](https://static.pepy.tech/badge/pymemsim-mcp/month)](https://pepy.tech/projects/pymemsim-mcp)
![PyPI](https://img.shields.io/pypi/v/pymemsim-mcp)
![Python Version](https://img.shields.io/pypi/pyversions/pymemsim-mcp.svg)
![License](https://img.shields.io/pypi/l/pymemsim-mcp)
[![MCP](https://img.shields.io/badge/Model_Context_Protocol-Compatible-orange)](https://modelcontextprotocol.io)

PyMemSim-MCP exposes PyMemSim membrane simulation capabilities through an MCP server.

## Overview ๐ŸŒ

PyMemSim-MCP is a next-generation framework that brings the Model Context Protocol into chemical engineering modeling and simulation, specifically for membrane-based separation systems.

Built on top of PyMemSim, this package introduces a model-source-driven architecture in which thermodynamic data, transport properties, and governing equations are defined externally in a structured, machine-readable format (e.g., YAML). These model sources are dynamically constructed using tools such as PyThermoLinkDB and PyThermoDB, and then supplied, alongside conventional inputs like temperature, pressure, and composition, to simulation workflows.

Unlike traditional tightly coupled simulation tools, PyMemSim-MCP decouples data, equations, and numerical solvers, enabling:

- โœ… Consistent and unit-safe thermodynamic definitions across simulations
- ๐Ÿ”— Flexible integration with multiple modeling packages and workflows
- โš™๏ธ Solver-agnostic execution of mass and heat balance equations
- ๐Ÿ” Transparent and interpretable simulation pipelines

A key innovation of PyMemSim-MCP is its compatibility with agentic workflows, where specialized agents can:

- ๐Ÿง  Extract and structure thermodynamic data from unstructured sources into validated model sources
- ๐Ÿค– Interact with MCP-enabled endpoints to perform simulations, sensitivity analysis, and optimization

This approach addresses critical gaps in current LLM-integrated engineering tools, where inconsistencies in data formats, units, and equations often lead to unreliable results. By enforcing a unified scientific contract, PyMemSim-MCP allows LLMs to control both conventional inputs and structured model sources before executing physics-based computations, significantly improving robustness and reproducibility.

PyMemSim-MCP is particularly suited for:

- ๐Ÿงช Membrane process modeling (e.g., hollow fiber modules, gas separation)
- ๐Ÿค AI-assisted simulation workflows
- ๐Ÿš€ Rapid prototyping and validation of process models
- ๐ŸŽ“ Educational and research applications in computational chemical engineering

Overall, PyMemSim-MCP represents a step toward trustworthy AI-driven simulation environments, where domain knowledge, data, and numerical methods are seamlessly integrated under a standardized and extensible framework.

## Requirements ๐Ÿ“‹

- Python `>=3.11`
- `pip` (or `uv`)

## Install the package ๐Ÿ“ฆ

```bash
pip install pymemsim-mcp
```

This installs the CLI entrypoint:

- `pymemsim-mcp`

## Start / Activate the MCP Server โ–ถ๏ธ

The server entrypoint is:

- module: `python -m pymemsim_mcp.server`
- script: `pymemsim-mcp`

Both support the same options.

### Case A: STDIO transport (recommended for MCP desktop/agent clients) ๐Ÿงต

```bash
pymemsim-mcp --mode stdio
```

Equivalent:

```bash
python -m pymemsim_mcp.server --mode stdio
```

### Case B: HTTP transport (for network-accessible clients) ๐ŸŒ

```bash
pymemsim-mcp --mode http --host 127.0.0.1 --port 8000 --path /mcp
```

Equivalent:

```bash
python -m pymemsim_mcp.server --mode http --host 127.0.0.1 --port 8000 --path /mcp
```

## CLI Options โŒจ๏ธ

- `--mode`: `stdio` or `http` (default: `stdio`)
- `--host`: HTTP bind host (default: `127.0.0.1`)
- `--port`: HTTP bind port (default: `8000`)
- `--path`: HTTP endpoint path (default: `/mcp`)

## MCP Client Configuration Examples ๐Ÿ”Œ

### STDIO client config (generic)

```json
{
  "mcpServers": {
    "pymemsim": {
      "command": "pymemsim-mcp",
      "args": ["--mode", "stdio"]
    }
  }
}
```

### HTTP client config (generic)

```json
{
  "mcpServers": {
    "pymemsim": {
      "url": "http://127.0.0.1:8000/mcp"
    }
  }
}
```

## Available Tool ๐Ÿงฉ

- `simulate_gas_hfm`: build thermo model source from reference content and run gas hollow-fiber membrane simulation.

## Agentic Workflows ๐Ÿค–

For AI-assisted and agentic membrane-process simulation, see **[PyMemSim-Agent](https://github.com/sinagilassi/PyMemSim-Agent)**.

PyMemSim-Agent provides a **harness-neutral instruction and workflow layer** designed to orchestrate PyMemSim-MCP through AI agents such as Codex, Claude, Gemini, and other agentic environments.

While **PyMemSim-MCP** exposes the scientific simulation capabilities through the Model Context Protocol (MCP), **PyMemSim-Agent** provides the reasoning rules, skills, prompts, examples, and workflows needed for an agent to use those capabilities systematically.

Together, they enable agentic workflows in which an AI agent can:

* ๐Ÿง  Interpret a membrane-separation problem and identify the required simulation inputs
* ๐Ÿ“š Build structured thermodynamic model sources from reference data
* โœ… Validate required properties, units, equations, and simulation inputs
* ๐Ÿ”ง Select and invoke the appropriate PyMemSim-MCP tools
* โš™๏ธ Execute physics-based membrane simulations
* ๐Ÿ“Š Interpret simulation outputs and engineering performance indicators
* ๐Ÿ” Perform iterative studies such as sensitivity analysis, operating-condition exploration, and optimization
* ๐Ÿงช Maintain a reproducible workflow connecting scientific references, model inputs, numerical simulation, and engineering interpretation

The overall architecture can therefore be viewed as:

```text
User / Engineering Problem
          โ”‚
          โ–ผ
   Agentic Harness
(Codex / Claude / Gemini / ...)
          โ”‚
          โ–ผ
    PyMemSim-Agent
 Instructions โ€ข Skills
 Prompts โ€ข Workflows
          โ”‚
          โ–ผ
     PyMemSim-MCP
      MCP Tools
          โ”‚
          โ–ผ
       PyMemSim
Physics-Based Simulation
          โ”‚
          โ–ผ
Engineering Results
```

๐Ÿ‘‰ **PyMemSim-Agent repository:**
https://github.com/sinagilassi/PyMemSim-Agent

## Development Quick Check โœ…

```bash
python -m py_compile pymemsim_mcp/server.py
python -m py_compile pymemsim_mcp/interface/gas_hfm.py
```

## Troubleshooting ๐Ÿฉบ

- `pymemsim-mcp: command not found`
  - Run `pip install -e .` in the active environment.
  - Confirm environment is activated.

- Port already in use (HTTP mode)
  - Change port, for example: `--port 8010`.

- Import errors
  - Reinstall dependencies: `pip install -e .`.

## โ“ FAQ

For any questions, contact me on [LinkedIn](https://www.linkedin.com/in/sina-gilassi/).

## ๐Ÿ“„ License

This project is licensed under the Apache License 2.0. See the [LICENSE](LICENSE) file for details.

## ๐Ÿ‘จโ€๐Ÿ’ป Authors

- [@sinagilassi](https://www.github.com/sinagilassi)

TDQS

B3.2/5.0

Scored across 3 tools

Disambiguation5/5

Each tool targets a clearly distinct operation: validating YAML content, analyzing feed flow rate bounds, and running a membrane simulation. There is no overlap in functionality.

Naming Consistency3/5

Tool names use snake_case but mix verb-noun patterns: 'check_yaml_reference' and 'simulate_gas_hfm' start with verbs, while 'hfm_feed_flow_rate_analyzer' is a noun phrase without a verb, creating inconsistency.

Tool Count5/5

With only 3 tools, the server is tightly scoped to core membrane simulation tasks. Each tool serves a necessary, non-redundant purpose.

Completeness3/5

The set covers validation, analysis, and simulation, but lacks tools for user input setup, result visualization, or parameter tuning, leaving notable gaps for a complete workflow.

Maintenance

ActivityMaintained
ResponsivenessNo issues