Skip to main content
Glama
stereosky

Lenses MCP Server

by stereosky

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

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
display_nameNo
tierNodevelopment
metadataNo

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)
  • Registers the environments tools, including 'create_environment', by calling register_environments on the MCP instance.
    register_environments(mcp)
  • 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):

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/stereosky/lenses-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server