This is an MCP version of the eGrid Agentic AI example
This tutorial demonstrates an MCP agent implementation that integrates multiple power system analysis tools via an MCP server. The server utilizes FastMCP for its foundation, while the client leverages the Amazon Bedrock Inline Agent SDK. The example showcases tool integration using open source power system software such as OpenDSS (DSS-Python) and GridCal to illustrate the operational workflow.
- AWS Command Line Interface (CLI), follow instructions here. Make sure to setup credentials, follow instructions here.
- Install UV
- Install Python 3.11 or above in UV
- Enable Amazon Bedrock model access.
Note
If you don't set up your AWS profile as instructed in step 1. An exception botocore.exceptions.ProfileNotFound will raise
when you run InlineAgent_hello test below
# Retrieve the Inline Agent SDK
git clone https://github.com/awslabs/amazon-bedrock-agent-samples.git
cd amazon-bedrock-agent-samples/src/InlineAgent
# Activate the virtual environment (install python virtualenv first if not installed)
python3 -m venv .venv
source .venv/bin/activate
# Install the SDK packages
python3 -m pip install -e .
# Test run; ensure you have access to Claude 3.5 Haiku model via Bedrock
InlineAgent_hello us.anthropic.claude-3-5-haiku-20241022-v1:0
# Retrieve the tutorial
git clone https://github.com/IEEE-PES-TF-Cloud4PowerGrid/cloud_adoption_tutorials.git
cd cloud_adoption_tutorials/egrid_mcp_agent/
# Install dependencies for the sample
python3 -m pip install -e .Note
You can host the MCP server for various power system analysis tools either on your local machine or a remote server.
When deploying the MCP server on a remote machine, update the API_BASE_URL by substituting localhost with the server's public IP address or domain name.
Verify that TCP port 8000 is open and reachable from the machine running the agent, then transfer the egrid_mcp_server.py script to the remote server.
# install dependencies
uv add dss-python GridCalEngine numpy matplotlib "fastmcp>=0.1.0"uv run egrid_mcp_server.pypython3 run_egrid_agent_mcp_client.pyYou need to download the power flow cases from GridCal project repo "Grids_and_Profiles/grids/" folder
Agent Response for Prompt to Run Power Flow Analysis
MCP Server Response for Prompt to Run Power Flow Analysis


