Learn About FlexAgent MCP

Frederik Schubert, Ph.D.
Published 16 Oct 2025

This article is written by Dr. Frederik Schubert, Dr Emerson Melo, and Dr. Qing Hu.


If you ask ChatGPT to generate a power splitter simulation model using tidy3d, it will output something like this after researching and coding for about 4 minutes:

import numpy as np, tidy3d as td, tidy3d.web as web, gdstk
lda0=1.55; freqs=td.C_0/np.linspace(1.5,1.6,101); f0=td.C_0/lda0; fwidth=0.5*(freqs.max()-freqs.min())
si=td.material_library["cSi"]["Palik_Lossless"]; sio2=td.material_library["SiO2"]["Palik_Lossless"]
t=0.22; w1=0.5; w2=0.5; w3=0.6; w4=0.7; w5=0.9; w6=1.26; w7=w8=w9=w10=1.4; w11=1.31; w12=w13=1.2
l_in=1; l_junc=2; l_bend=6; h_bend=2; l_out=1; inf_eff=100
x=np.linspace(l_in,l_in+l_junc,13); y=np.array([w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11,w12,w13])
x=np.concatenate((x,np.flipud(x))); y=np.concatenate((y/2,-np.flipud(y/2))); V=np.transpose(np.vstack((x,y)))
junction=td.Structure(geometry=td.PolySlab(vertices=V,axis=2,slab_bounds=(0,t)),medium=si)
xs=l_in+l_junc; x=np.linspace(xs,xs+l_bend,100)
y=(x-xs)*h_bend/l_bend-h_bend*np.sin(2*np.pi*(x-xs)/l_bend)/(2*np.pi)+w13/2-w1/2
x=np.append(x,inf_eff); y=np.append(y,y[-1]); cell=gdstk.Cell("bends")
...

This might be correct Python code, but it is neither readable nor educational about Tidy3D APIs. We already have an excellent example notebook for this, but ChatGPT did not find it or chose to ignore it. This is particularly relevant for APIs that have undergone recent changes or are not well-documented online.

FlexAgent MCP enables users to seamlessly browse our up-to-date documentation and adapt the examples using the AI agent of their choice. Additionally, the Cursor extension Tidy3D Viewer enables a seamless setup of the MCP in the cursor and provides additional tools to view the simulation and help the AI agent.

 

What is MCP?

MCP stands for Model Context Protocol and is a standard that defines how to interact with Large Language Models (LLMs), which serve as the foundation of current AI systems. The main goal of the protocol is to establish a text-based schema for communicating with external tools, such as APIs or local software. Many MCP servers exist, and users can select from several AI clients that support MCP.

After a MCP server is added to a MCP client’s configuration, each conversation with the AI agent through that client includes a hidden prefix (similar to the system prompt) that describes the available tools to the agent. The agent then decides when to generate the MCP signature that triggers an external tool execution (e.g. the agent might generate mcp__flexagent__search "how to use tidy3d?" if there is a tool called search by an MCP server called flexagent. This highlights a limitation of this approach: adding too many MCP servers and tools can confuse the agent. Another key point is that adding an MCP injects arbitrary (potentially malicious) context into your AI agent, which can pose a security risk. This is less of a concern for our own FlexAgent MCP but more relevant for other MCP servers you might add.

 

What is FlexAgent MCP?

 

The FlexAgent MCP is part of the flexagent-services API and deployed on AWS EC2. It exposes one tool called search_flexcompute_docs which allows it to search the documentation of Tidy3d , Photonforge , and Flow360 and external libraries such as gdstk and other future additions (If you need some software as part of your development workflow that is not well supported by current LLMs out-of-the-box, you can propose it for addition to that list).

One crucial aspect of MCPs is PROMOTING. The AI agent won’t use the MCP unless the current query matches the advertised functionality of the MCP server. Use the phrase Use flexagent to ... to trigger the usage of the FlexAgent MCP. A more convenient way is to create a AGENTS.md file to instruct the AI agent to do this without manual intervention.

So, FlexAgent MCP is essentially an 🤖 AI-powered assistance tool - a Physics-informed assistance feature through Cursor agent and Tidy3D MCP integrationThe extension integrates with Cursor's agent to provide physics-aware assistance for electromagnetic simulations. Unlike generic coding assistants, this integration understands Tidy3D workflows and can control the 3D viewer.

 

What are the main features of FlexAgent MCP?

 
  • AI-Enhanced Workflows – Agent assistance with Tidy3D expertise through integrated MCP server

  • Structured Assistance – Step-by-step guidance from learning to optimization

  • Trusted Knowledge Base – Direct integration with [Tidy3D's comprehensive documentation](https://docs.flexcompute.com/projects/tidy3d/en/latest/index.html)

  • Editor-Native Viewer – No context switching between tools

  • Live Code Synchronization – See geometry changes instantly as you type

  • AI-Controlled Visualization – Let the agent navigate and explain the 3D scene

 

FlexAgent application scenarios


The command Tidy3D: Run Tidy3D Workspace Setup deploys FlexAgent rules under .cursor/rules/ that transform the agent into a physics-aware simulation partner. These are structured workflows relying on Tidy3D's trusted documentation.

  • Learning - "Explain me how Tidy3D FDTD updates the fields in this notebook"

  • Troubleshooting - "I want to fix the structure related validation error"

  • Customization - "Replace the FluxMonitor with a ModeMonitor"

  • Build from Scratch - "Create a basic y-junction waveguide simulation setup"

  • Result Analysis - "Plot all the electric field components"

 

Further Read:

Using FlexAgent MCP within Cursor

 

You Might Also Like
Flow360 Feature Update: Solution Interpolation on a New Mesh

Flow360 Feature Update: Solution Interpolation on a New Mesh

31 Jul 2025 By Jolie Duquene
Learn Electromagnetic Simulation in One Minute: Quick Video Guides for the Multiphysics Solver Workbenches

Learn Electromagnetic Simulation in One Minute: Quick Video Guides for the Multiphysics Solver Workbenches

25 Jul 2025 By Qing Hu, PhD
Flow360 Feature Update: Streamline Visualization

Flow360 Feature Update: Streamline Visualization

14 Jul 2025 By Yago Lopez