wgrib2-easy-mcp
wgrib2-easy-mcp is an MCP server for remotely executing wgrib2 commands via an MCP client. It facilitates file processing and provides tools for content listing, showing details, and accessing help, with outputs saved to a specified directory.
wgrib2-easy-mcp
A simple MCP server designed to execute wgrib2
commands remotely via an MCP Client. Processed files are saved to a designated output directory.
Features
- Remotely execute common
wgrib2
tasks via MCP. - Tools for listing contents, showing details, and accessing help.
- Simple configuration using environment variables.
- Outputs generated files (e.g., CSV, binary extracts - based on sample) to a specified directory.
Prerequisites
Before you begin, ensure you have the following installed on the server machine:
- Python 3.x
git
(for cloning the repository)uv
(Python project and virtual environment manager - required by the run command)wgrib2
: Thewgrib2
executable must be installed and accessible in the system'sPATH
.- An MCP Client environment capable of connecting to this server.
Installation
-
Clone the repository:
git clone https://github.com/yskmasumoto/wgrib2-easy-mcp.git cd wgrib2-easy-mcp
-
Install dependencies:
uv pip install -r requirements.txt
Configuration
- Environment Variables: Configure the server primarily through environment variables. It's recommended to use a
.env
file in the project root.OUTPUT_DIR
: Required. Specify the absolute path to the directory where generated files should be saved. Important: This directory must exist before starting the server. It will not be created automatically.WGRIB2_PATH
: Optional. Path to the wgrib2 executable (defaults to wgrib2 in PATH).TEST_GRIB2_FILE
: The path to the GRIB2 file referenced when executing the sample scriptsample.py
.
# example of .env
WGRIB2_PATH=/usr/local/bin/wgrib2
TEST_GRIB2_FILE=/path/to/your/file.grib2
OUTPUT_DIR=/path/to/output/dir
- MCP Configuration File: Users should refer to
config-examples/claude_desktop_config-example.json
for the MCP server startup commands.
Running the Server
Start the MCP server using the uv
command. This command also loads environment variables from a .env
file if present.
uv run --with python-dotenv --with mcp src/server.py
--with python-dotenv
: Enables loading of environment variables from.env
.--with mcp
: Activates MCP-specific integration (assumed functionality ofuv
task).server.py
: The main script that runs the server.
Once the server is running, the wgrib2-easy-mcp
tools will become available for invocation from connected MCP clients.
Usage
From an MCP Client
Connect your MCP client application to the running wgrib2-easy-mcp
server. You can then call the available tools (listed below), providing necessary arguments such as the path to the GRIB2 file. The server will execute the corresponding wgrib2
command and save any resulting output files to the configured OUTPUT_DIR
. The client will typically receive a confirmation or status message.
CLI Example Script
A sample Python script demonstrating basic usage patterns is provided in src/sample/sample.py
. This script showcases how the underlying functionalities might be used.
To run the example:
uv run src/sample/sample.py
Ensure the OUTPUT_DIR
environment variable is set and the directory exists before running the sample. The script will perform the following sequence of actions using a sample GRIB2 file:
- List the contents (inventory) of the GRIB2 file.
- Show detailed information about the file's messages.
- Extract a specific data element (e.g., Temperature 'TMP').
- Convert extracted data to CSV format.
- Extract latitude/longitude or grid range information.
- Convert extracted data to a raw binary format.
- Display help information (likely from
wgrib2
).
Results from these operations will be saved in the specified OUTPUT_DIR
.
Important: Please note that some functionalities demonstrated in this sample, particularly element extraction and file conversions (steps 3, 4, 6), correspond to features that are currently under development. These actions might not work as expected or may not be accessible via stable MCP tools at this time.
Available MCP Tools
The following tools are exposed by the server for use by MCP clients:
list_contents
: Lists the inventory of messages within a specified GRIB2 file (similar towgrib2 <grib_file>
).show_details
: Displays detailed information about the messages in a GRIB2 file (similar towgrib2 -V <grib_file>
).show_help
: Provides access towgrib2
's help documentation.
Note: The src/sample/sample.py
script demonstrates additional operations like element extraction and conversions (e.g., to CSV, binary). Please be aware that these more complex functionalities are currently under development. While shown in the sample for illustrative purposes, dedicated and stable MCP tools for these specific operations are not yet available. Future implementation might involve adding arguments to the tools listed above or introducing new, specific tools once development is complete.
Output Directory
All files generated through the MCP tools (e.g., CSV files, binary data) are saved directly into the directory specified by the OUTPUT_DIR
environment variable on the server. Remember to create this directory manually before launching the server.
License
This project is planned to be released under the MIT License. Please feel free to use, modify, and distribute it accordingly. Check the LICENSE
file (once added) for full details.