# Nyquist Stability Margin Calculator AI Agent Connect

> Nyquist Stability Margin Calculator MCP gives your AI agent the mathematical tools needed to evaluate closed-loop stability. It handles encirclement counts, calculates gain and phase margins, and identifies frequency crossings to determine how close a system is to instability.

## Overview
- **Category:** engineering
- **Price:** Free
- **Endpoint:** https://edge.vinkius.com/vk_preview_Z8KRluPmCtmmuFKi2WRG8SSd2O3yfrozXMDpncNB/ai-agent-connect
- **Tags:** nyquist, stability, control-theory, frequency-response, engineering-tools

## Description

You can now hand off complex frequency response data to your AI client for immediate stability analysis. This MCP provides the mathematical heavy lifting for linear time-invariant (LTI) system evaluation. Instead of manually plotting Nyquist diagrams, you can ask your agent to calculate net encirclements of the critical point (-1, 0) or find the exact distance to instability. It works by processing frequency samples to determine if a system is stable or if it lacks sufficient safety buffers. You can use it to find gain and phase margins, locate where the response hits the unit circle, or check how close the frequency response gets to the critical point. It is a specialized tool for control theory workflows where precision in stability margins is non-negotiable.

## Tools

### analyze_nyquist_stability
This tool determines if a system is stable by calculating the net encirclements of the critical point.

### calculate_stability_margins
Use this to find the specific gain and phase margins that define a system's safety buffers.

### evaluate_system_residuals
This tool calculates how close the frequency response gets to the critical point (-1, 0).

### identify_frequency_crossings
This tool locates the exact points where the response intersects the unit circle or critical axes.

## Prompt Examples

**Prompt:** 
```
Analyze the stability of a system with these frequency samples: [{'re': -0.5, 'im': 0.5}, {'re': -1.2, 'im': -0.2}] and 0 unstable open-loop poles using linear interpolation.
```

**Response:** 
```
The system is stable with 0 net encirclements of the critical point.
```

**Prompt:** 
```
Calculate the stability margins for the following frequency response data using spline interpolation.
```

**Response:** 
```
The gain margin is 6.2 dB and the phase margin is 45.5 degrees, with a gain crossover frequency of 12.4 Hz.
```

**Prompt:** 
```
How close is the frequency response to the critical point (-1, 0)?
```

**Response:** 
```
The minimum distance to the critical point is 0.15 units, occurring at a frequency of 5.2 rad/s.
```

## Capabilities

### Stability Assessment
Your agent uses this to count encirclements and confirm closed-loop stability.

### Margin Calculation
Your agent calculates gain and phase margins to quantify system safety buffers.

### Proximity Analysis
Your agent finds the minimum distance between the frequency response and the critical point.

### Crossing Identification
The tool locates where the response intersects the unit circle or critical axes.

## Use Cases

### Stability Verification
Confirm if a closed-loop system is stable based on open-loop pole counts and frequency samples.

### Safety Buffer Quantification
Determine how much gain or phase can change before a system becomes unstable.

### Frequency Response Mapping
Find where a system response intersects the unit circle or critical axes.

### Proximity Checking
Measure how close a frequency response comes to the (-1, 0) critical point.

## Benefits

- Automates encirclement counts for LTI systems.
- Provides exact gain and phase margin values from frequency data.
- Identifies critical frequency crossings without manual plotting.
- Calculates minimum distance to the critical point for proximity analysis.

## How It Works

Connect your client to Vinkius and start sending frequency data to your agent.

1. Connect your MCP-compatible client to Vinkius.
2. Provide frequency response samples or open-loop pole data to your agent.
3. Your agent invokes the necessary stability or margin tool.
4. The MCP performs the mathematical calculation and returns the results.

## Frequently Asked Questions

**What kind of systems can this MCP analyze?**
This MCP is designed for linear time-invariant (LTI) systems.

**How do I calculate gain and phase margins?**
You can use the `calculate_stability_margins` tool to find these safety buffers from your frequency response data.

**Can I find the distance to the critical point?**
Yes, the `evaluate_system_residuals` tool calculates the minimum distance to the critical point (-1, 0).

**Which AI clients can use this MCP?**
You can use this with any MCP-compatible client like Claude, Cursor, or Windsurf.

**Does it support interpolation?**
The tools can use linear or spline interpolation to process frequency samples.

**How do I determine if my system is stable?**
You can use the `analyze_nyquist_stability` tool. It calculates the net encirclements of the critical point and compares them to the number of unstable open-loop poles to determine stability.

**What are gain and phase margins?**
Gain and phase margins are safety buffers. The gain margin is how much gain can increase before instability, and the phase margin is how much phase lag can be added. Use `calculate_stability_margins` to find these values.

**Can I find where the response crosses the unit circle?**
Yes, the `identify_frequency_crossings` tool specifically locates frequencies where the magnitude is one (unit circle) or the imaginary component is zero.
