Add a new tool#
This example shows how to add a new @app.tool(...) safely and make it visible
at the right stages of an MCP session.
Where to implement#
Add the tool implementation to
src/ansys/aedt/mcp/tools.py.Add the tool to the appropriate group in
src/ansys/aedt/mcp/toolsets.py.Document the tool behavior in Tools and capabilities.
Example: AEDT-dependent tool#
Use REQUIRES_AEDT_TAG when the tool cannot run before connection:
from fastmcp.server import Context
from ansys.aedt.mcp import app
from ansys.aedt.mcp.tools import REQUIRES_AEDT_TAG
@app.tool(tags={"aedt_tools", REQUIRES_AEDT_TAG}, timeout=120)
def my_new_tool(ctx: Context) -> str:
return "ok"
Example: Pre-connection tool#
Do not use REQUIRES_AEDT_TAG for tools that work before connecting:
from fastmcp.server import Context
from ansys.aedt.mcp import app
@app.tool(tags={"aedt_tools"}, timeout=30)
def check_local_environment(ctx: Context) -> str:
return "environment ready"
Runtime flags and their effect#
Server startup flags affect tool visibility and behavior:
--dynamic-tool-discovery: HideREQUIRES_AEDT_TAGtools until AEDT connects.--connect: Connect at startup and lock the session. In this mode,launch_aedt,connect_to_aedt, anddisconnect_from_aedtare disabled for the life of the process.--include-context: Register optional context tools such asget_guidelines_for.
Validation checklist#
Add or update tests in
tests/test_tools.py.Ensure the tool appears in a toolset definition (validated by
tests/test_toolsets.py).Run tests locally.
Verify that code coverage remains greater than 80%.
Update user-facing documentation.