Skip to content

Latest commit

 

History

History

README.md

eGRID MCP AGENT

This is an MCP version of the eGrid Agentic AI example

Introduction

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.

Solution Overview

soln_overview

Get Started

Prerequisites

  1. AWS Command Line Interface (CLI), follow instructions here. Make sure to setup credentials, follow instructions here.
  2. Install UV
  3. Install Python 3.11 or above in UV
  4. 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

Setup Agent for MCP Client

# 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 .

Setup for eGrid Analysis MCP Server

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"

Start the MCP Server

uv run egrid_mcp_server.py

Run MCP client built with Bedrock Inline Agent to Interact with MCP Server

python3 run_egrid_agent_mcp_client.py

Expected Results

Power Flow Analysis

You need to download the power flow cases from GridCal project repo "Grids_and_Profiles/grids/" folder

Agent Response PF

Agent Response for Prompt to Run Power Flow Analysis

MCP Server Response PF

MCP Server Response for Prompt to Run Power Flow Analysis