create_natural_language_simulation_config
Create structured simulation configurations from natural language descriptions, interpreting user requirements as technical parameters for traffic simulation.
Instructions
Converts a natural language description into a structured simulation configuration, interpreting user requirements into technical parameters for traffic simulation.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| description | Yes | ||
| ctx | No |
Implementation Reference
- src/fujitsu_sdt_mcp/server.py:608-680 (handler)The tool handler function that converts natural language descriptions into structured simulation configurations. Uses keyword matching to detect simulation type (traffic, escooter, road_pricing, generic) and extracts parameters like region, time range, scooter count, deployment strategy, pricing zone, and price model.
@mcp.tool() async def create_natural_language_simulation_config(description: str, ctx: Optional[Context] = None) -> Dict[str, Any]: """Converts a natural language description into a structured simulation configuration, interpreting user requirements into technical parameters for traffic simulation.""" try: if not description: return format_api_error(400, "Description required") config = { "simulationType": "unknown", "parameters": {} } description_lower = description.lower() if any(keyword in description_lower for keyword in ["traffic", "congestion", "road", "signal"]): config["simulationType"] = "traffic" regions = ["Tokyo", "Osaka", "Nagoya", "Fukuoka", "Sapporo", "Sendai", "Hiroshima", "Kyoto"] for region in regions: if region.lower() in description_lower: config["parameters"]["region"] = region break if "morning" in description_lower or "rush hour" in description_lower: config["parameters"]["timeRange"] = "morning_rush" elif "evening" in description_lower: config["parameters"]["timeRange"] = "evening_rush" elif "daytime" in description_lower: config["parameters"]["timeRange"] = "daytime" elif any(keyword in description_lower for keyword in ["scooter", "e-scooter", "electric"]): config["simulationType"] = "escooter" count_match = re.search(r'(\d+) scooters', description) if count_match: config["parameters"]["scooterCount"] = int(count_match.group(1)) if "demand" in description_lower: config["parameters"]["deploymentStrategy"] = "demand_based" elif "grid" in description_lower: config["parameters"]["deploymentStrategy"] = "grid_based" elif "transit" in description_lower: config["parameters"]["deploymentStrategy"] = "transit_focused" elif any(keyword in description_lower for keyword in ["pricing", "toll", "congestion charge"]): config["simulationType"] = "road_pricing" if "city center" in description_lower: config["parameters"]["pricingZone"] = "city_center" elif "wider area" in description_lower: config["parameters"]["pricingZone"] = "wider_area" elif "major roads" in description_lower: config["parameters"]["pricingZone"] = "major_roads" if "fixed" in description_lower: config["parameters"]["priceModel"] = "fixed" elif "time variable" in description_lower: config["parameters"]["priceModel"] = "time_variable" elif "congestion" in description_lower: config["parameters"]["priceModel"] = "congestion_variable" else: config["simulationType"] = "generic" config["parameters"]["description"] = description current_time = datetime.now().strftime("%Y%m%d_%H%M%S") config["name"] = f"{config['simulationType']}_{current_time}" return config except Exception as e: logger.error(f"Config generation error: {e}") return format_api_error(500, str(e)) - src/fujitsu_sdt_mcp/server.py:608-608 (registration)The tool is registered with the MCP server using @mcp.tool() decorator on line 608, which is how FastMCP discovers and exposes the tool.
@mcp.tool() - The input schema is defined by the function signature: takes a 'description' (str) parameter and optional 'ctx' (Context). Returns Dict[str, Any]. The docstring describes the purpose.
"""Converts a natural language description into a structured simulation configuration, interpreting user requirements into technical parameters for traffic simulation.""" - src/fujitsu_sdt_mcp/server.py:40-45 (helper)The format_api_error helper function used by the tool to return structured error responses.
def format_api_error(status_code: int, error_detail: str) -> Dict[str, Any]: return { "success": False, "status_code": status_code, "error": error_detail } - src/fujitsu_sdt_mcp/server.py:28-28 (registration)The FastMCP server instance ('fujitsu-digital-rehearsal') that registers the tool via the @mcp.tool() decorator.
mcp = FastMCP("fujitsu-digital-rehearsal")