create_environment
Create a new Lenses environment for managing Kafka data across clusters. Specify name, tier (development/staging/production), and metadata to configure the environment.
Instructions
Creates a new Lenses environment.
Args: name: The name of the new environment. Must be a valid resource name (lowercase alphanumeric or hyphens, max 63 chars). display_name: The display name of the environment. If not provided, 'name' will be used. tier: The environment tier. Options: "development", "staging", "production". Default: "development". metadata: Additional metadata as key-value pairs.
Returns: The created environment object including the agent_key for setup.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| display_name | No | ||
| tier | No | development | |
| metadata | No |
Implementation Reference
- The handler function for the 'create_environment' tool. It validates inputs, constructs a payload, and makes a POST request to the Lenses API to create a new environment.@mcp.tool() async def create_environment( name: str, display_name: Optional[str] = None, tier: str = "development", metadata: Optional[Dict[str, Any]] = None ) -> Dict[str, Any]: """ Creates a new Lenses environment. Args: name: The name of the new environment. Must be a valid resource name (lowercase alphanumeric or hyphens, max 63 chars). display_name: The display name of the environment. If not provided, 'name' will be used. tier: The environment tier. Options: "development", "staging", "production". Default: "development". metadata: Additional metadata as key-value pairs. Returns: The created environment object including the agent_key for setup. """ if not name: raise ValueError("Environment name is required") # Validate name format if not name.replace('-', '').isalnum() or name.startswith('-') or name.endswith('-') or len(name) > 63: raise ValueError("Name must be lowercase alphanumeric or hyphens, not start/end with hyphens, max 63 chars") valid_tiers = ["development", "staging", "production"] if tier not in valid_tiers: raise ValueError(f"Tier must be one of: {', '.join(valid_tiers)}") payload = { "name": name, "tier": tier } if display_name: payload["display_name"] = display_name if metadata: payload["metadata"] = metadata return await api_client._make_request("POST", "/api/v1/environments", payload)
- src/lenses_mcp/server.py:28-28 (registration)Registers the environments tools, including 'create_environment', by calling register_environments on the MCP instance.register_environments(mcp)
- src/lenses_mcp/server.py:12-12 (registration)Imports the register_environments function used to register the 'create_environment' tool.from tools.environments import register_environments
- Input schema defined by the function parameters, including types and defaults, used by FastMCP for tool schema.async def create_environment( name: str, display_name: Optional[str] = None, tier: str = "development", metadata: Optional[Dict[str, Any]] = None ) -> Dict[str, Any]:
- The registration function that defines and registers the create_environment tool using @mcp.tool() decorator.def register_environments(mcp: FastMCP):