Skip to main content

Local stdio FastMCP server for Tidy3D

Project description

Tidy3D MCP

A local Model Context Protocol (MCP) server that lets clients drive the Flexcompute Tidy3D viewer and consume viewer artifacts without needing a browser session.

Capabilities

  • Authenticates against the remote FlexAgent MCP endpoint using OAuth.
  • Proxies viewer automation commands such as launching the viewer, rotating the camera, toggling structure visibility, running simulation health checks, and capturing screenshots.
  • Publishes viewer screenshots as MCP resources so downstream tools can fetch PNG artifacts or browse index manifests.

Requirements

  • Python 3.10 or newer
  • uv for dependency management
  • Network access to the target FlexAgent MCP deployment (defaults to the hosted https://flexagent.dev-simulation.cloud/ endpoint)

Installation

uv sync

This resolves the project environment and installs the tidy3d-mcp console entry point.

Usage

Start the server from the project root:

uv run tidy3d-mcp

The server listens on stdio for MCP requests and forwards them to the remote FlexAgent server. The first invocation prompts OAuth consent in a browser, then stores the token under the cache location shown in Configuration. Viewer screenshots are written to the .tidy3d-screenshots directory under the current working directory unless dest_folder_uri is supplied when calling the screenshot tools.

Integrating with MCP Hosts

  • VS Code / Cursor: Select the "Tidy3D MCP" binary (uv run tidy3d-mcp) when configuring an stdio MCP provider.
  • Custom hosts: Launch the command above and connect using the Model Context Protocol over the process stdio pipes.

Configuration

Environment variables control the server at startup:

Variable Purpose Default
REMOTE_MCP_URL Target MCP endpoint to proxy. https://flexagent.dev-simulation.cloud/

OAuth tokens persist under ~/.fastmcp/oauth-mcp-client-cache/<endpoint>/<workspace> to avoid re-authentication per session. Delete the cache directory to force a new OAuth consent flow.

Tools Exposed to Clients

Tool Description
start_viewer Launches the viewer for a simulation file and returns the resolved viewer_id.
rotate_viewer Rotates the active viewer toward the requested direction (e.g. +X, +Z).
set_viewer_structure_visibility Applies a boolean visibility array to the current viewer structures.
capture_screenshot Captures the current frame and returns a file URI to the stored PNG.
clear_screenshots Deletes cached screenshots for the viewer and reports the number removed.
check_simulation Returns validation warnings or errors reported by the viewer.

Resources Published

URI Description
screenshot://{viewer_id}/index.json JSON manifest listing available screenshot file URIs for the viewer.
screenshot://{viewer_id}/{name} Serves the raw PNG bytes for a specific screenshot.

Development Tips

  • Run uv run ruff check to lint the project and uv run ruff format to apply formatting.
  • The server relies on fastmcp.as_proxy; consult the upstream FastMCP documentation for advanced configuration such as custom authentication flows or additional transports.
  • When debugging viewer interactions, inspect the .tidy3d-screenshots directory to confirm that capture results are generated as expected.

Troubleshooting

  • OAuth consent window never opens: Ensure the machine can launch a browser and that pop-up blockers allow the OAuth window.
  • Viewer fails to start: Verify the simulation file exists, the MCP host provides the correct working directory, and the remote FlexAgent endpoint is reachable.
  • Stale screenshots: Use the clear_screenshots tool before capturing a new image or remove the cached files from the screenshot directory.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tidy3d_mcp-0.2.0.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tidy3d_mcp-0.2.0-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file tidy3d_mcp-0.2.0.tar.gz.

File metadata

  • Download URL: tidy3d_mcp-0.2.0.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.20

File hashes

Hashes for tidy3d_mcp-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ce963d117f824f08dc1d637fc686153ae8f46f3cb531549aef91bc2241a12668
MD5 0c7e2d1143572be9080e578619a038e4
BLAKE2b-256 4c6c4492ecb56b8dc6153ae32ab49ffedf9fb1f65af7cabd1fb9f62bf480b3dd

See more details on using hashes here.

File details

Details for the file tidy3d_mcp-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: tidy3d_mcp-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.20

File hashes

Hashes for tidy3d_mcp-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a00cbb4afa156e28f865bffcc97e63709887a0e7bda4c6bffb7306249557a7e5
MD5 b50a295a812aa6eb7fd9fc1285b16315
BLAKE2b-256 a6bfcf02d63b89baf70b21e66ae03d8c6cbb75edb7ecda0ad8fecd1d09b0bb38

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page