start_simulation
Start a traffic simulation using a dataset configuration; returns the simulation ID and initial status.
Instructions
Launches a new traffic simulation using the provided simulation dataset configuration, returning the simulation ID and initial status.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| simdata_id | Yes | ||
| ctx | No |
Implementation Reference
- src/fujitsu_sdt_mcp/server.py:456-470 (handler)The MCP tool handler for 'start_simulation'. Validates input, creates an HTTP client, delegates to the API client, and returns the result.
@mcp.tool() async def start_simulation(simdata_id: str, ctx: Optional[Context] = None) -> Dict[str, Any]: """Launches a new traffic simulation using the provided simulation dataset configuration, returning the simulation ID and initial status.""" try: if not simdata_id: return format_api_error(400, "simdataId required") async with await get_http_client() as client: api_client = FujitsuSocialDigitalTwinClient(client) result = await api_client.start_simulation(simdata_id) return result except Exception as e: logger.error(f"Simulation start error: {e}") return format_api_error(500, str(e)) - The schema/interface is defined via the @mcp.tool() decorator and the function signature: takes simdata_id (str) and optional ctx, returns a dict.
@mcp.tool() async def start_simulation(simdata_id: str, ctx: Optional[Context] = None) -> Dict[str, Any]: """Launches a new traffic simulation using the provided simulation dataset configuration, returning the simulation ID and initial status.""" try: if not simdata_id: return format_api_error(400, "simdataId required") async with await get_http_client() as client: api_client = FujitsuSocialDigitalTwinClient(client) result = await api_client.start_simulation(simdata_id) return result except Exception as e: logger.error(f"Simulation start error: {e}") return format_api_error(500, str(e)) - src/fujitsu_sdt_mcp/server.py:456-457 (registration)The @mcp.tool() decorator above the function registers it as an MCP tool named 'start_simulation'.
@mcp.tool() async def start_simulation(simdata_id: str, ctx: Optional[Context] = None) -> Dict[str, Any]: - src/fujitsu_sdt_mcp/server.py:70-83 (helper)API client method 'start_simulation' that calls POST /api/simulations with {'simdataId': simdata_id}. Used by the handler and also by create_simulation_from_usecase.
async def start_simulation(self, simdata_id: str) -> Dict[str, Any]: try: response = await self.client.post( "/api/simulations", json={"simdataId": simdata_id} ) response.raise_for_status() return format_simulation_result(response.json()) except httpx.HTTPStatusError as e: logger.error(f"Simulation start error: {e}") return format_api_error(e.response.status_code, str(e)) except Exception as e: logger.error(f"Unexpected error starting simulation: {e}") return format_api_error(500, str(e))