Skip to main content
Glama

pyResToolbox MCP Server

stock_tank_gas_sg

Calculate specific gravity of gas liberated from oil at atmospheric conditions for sales gas quality, flare calculations, emissions estimation, and safety assessments.

Instructions

Calculate stock tank gas specific gravity.

Computes the specific gravity of gas liberated at stock tank conditions. This is the gas that comes out of solution when oil reaches atmospheric pressure and temperature.

Stock tank gas properties are needed for:

  • Sales gas quality specifications

  • Flare gas calculations

  • VOC emissions estimation

  • Safety assessments

Returns dimensionless specific gravity (air = 1.0).

Args: request: Stock tank gas parameters including oil properties and separator conditions

Returns: Dictionary with stock tank gas SG value(s), units, and inputs

Input Schema

NameRequiredDescriptionDefault
requestYes

Input Schema (JSON Schema)

{ "properties": { "request": { "$ref": "#/$defs/EvolvedGasSGRequest" } }, "required": [ "request" ], "type": "object" }

Implementation Reference

  • The handler function decorated with @mcp.tool(), implementing the stock_tank_gas_sg tool logic using the oil.sg_st_gas function.
    @mcp.tool() def stock_tank_gas_sg(request: EvolvedGasSGRequest) -> dict: """Calculate stock tank gas specific gravity. Computes the specific gravity of gas liberated at stock tank conditions. This is the gas that comes out of solution when oil reaches atmospheric pressure and temperature. Stock tank gas properties are needed for: - Sales gas quality specifications - Flare gas calculations - VOC emissions estimation - Safety assessments Returns dimensionless specific gravity (air = 1.0). Args: request: Stock tank gas parameters including oil properties and separator conditions Returns: Dictionary with stock tank gas SG value(s), units, and inputs """ # Calculate stock tank gas SG # Estimate separator GOR as 90% of total rsp = 800.0 * 0.9 sg_st = oil.sg_st_gas( psp=request.psep, rsp=rsp, api=request.api, sg_sp=request.sg_g, degf_sp=100.0, # Typical separator temp ) # Convert numpy array to list for JSON serialization if isinstance(sg_st, np.ndarray): value = sg_st.tolist() else: value = float(sg_st) return { "value": value, "method": "McCain correlation", "units": "dimensionless (air=1)", "inputs": request.model_dump(), }
  • Pydantic BaseModel defining the input parameters and validation for the stock_tank_gas_sg tool.
    class EvolvedGasSGRequest(BaseModel): """Request model for evolved gas specific gravity calculation.""" api: float = Field(..., gt=0, le=100, description="Oil API gravity (degrees)") degf: float = Field( ..., gt=-460, lt=1000, description="Temperature (degrees Fahrenheit)") sg_g: float = Field( ..., ge=0, le=3, description="Separator gas specific gravity") p: Union[float, List[float]] = Field( ..., description="Pressure (psia) - scalar or array") psep: float = Field(100.0, gt=0, description="Separator pressure (psia)") @field_validator("p") @classmethod def validate_pressure(cls, v): if isinstance(v, list): if not all(p > 0 for p in v): raise ValueError("All pressure values must be positive") else: if v <= 0: raise ValueError("Pressure must be positive") return v
  • The @mcp.tool() decorator registers the stock_tank_gas_sg function as an MCP tool.
    @mcp.tool()

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/gabrielserrao/pyrestoolbox-mcp'

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