Skip to main content
Glama
pab1it0

adx-mcp-server

get_table_schema

Retrieve column names, data types, and metadata for Azure Data Explorer tables to understand database structure and prepare queries.

Instructions

Retrieves the schema information for a specified table in the Azure Data Explorer database, including column names, data types, and other schema-related metadata.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
table_nameYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The core handler function that implements the logic for the get_table_schema tool. It validates configuration, creates a Kusto client, executes the table | getschema KQL query, formats the results, and handles errors.
    async def get_table_schema(table_name: str) -> List[Dict[str, Any]]:
        """Get schema information for a specific table."""
        logger.info("Getting table schema", table_name=table_name, database=config.database)
    
        if not config.cluster_url or not config.database:
            logger.error("Missing ADX configuration")
            raise ValueError("Azure Data Explorer configuration is missing. Please set ADX_CLUSTER_URL and ADX_DATABASE environment variables.")
    
        try:
            client = get_kusto_client()
            query = f"{table_name} | getschema"
            result_set = client.execute(config.database, query)
            results = format_query_results(result_set)
            logger.info("Schema retrieved successfully", table_name=table_name, column_count=len(results))
            return results
        except Exception as e:
            logger.error("Failed to get table schema", table_name=table_name, error=str(e), exception_type=type(e).__name__)
            raise
  • The @mcp.tool decorator registers the get_table_schema function as an MCP tool with FastMCP, providing the tool's description used for tool discovery.
    @mcp.tool(description="Retrieves the schema information for a specified table in the Azure Data Explorer database, including column names, data types, and other schema-related metadata.")
  • Helper function used by get_table_schema to format the raw Kusto query result set into a standardized list of dictionaries with column names as keys.
    def format_query_results(result_set) -> List[Dict[str, Any]]:
        """
        Format Kusto query results into a list of dictionaries.
    
        Args:
            result_set: Raw result set from KustoClient
    
        Returns:
            List of dictionaries with column names as keys
        """
        if not result_set or not result_set.primary_results:
            logger.debug("Empty or null result set received")
            return []
    
        try:
            primary_result = result_set.primary_results[0]
            columns = [col.column_name for col in primary_result.columns]
    
            formatted_results = []
            for row in primary_result.rows:
                record = {}
                for i, value in enumerate(row):
                    record[columns[i]] = value
                formatted_results.append(record)
    
            logger.debug("Query results formatted", row_count=len(formatted_results), columns=columns)
            return formatted_results
        except Exception as e:
            logger.error(
                "Error formatting query results",
                error=str(e),
                exception_type=type(e).__name__
            )
            raise
  • Helper function called by get_table_schema to obtain an authenticated KustoClient instance for executing queries against the ADX cluster.
    def get_kusto_client() -> KustoClient:
        """
        Create and configure a Kusto client with appropriate Azure credentials.
    
        Prioritizes WorkloadIdentityCredential when running in AKS with workload identity,
        falls back to DefaultAzureCredential for other authentication methods.
    
        Returns:
            KustoClient: Configured Kusto client instance
        """
        tenant_id = os.environ.get('AZURE_TENANT_ID')
        client_id = os.environ.get('AZURE_CLIENT_ID')
        token_file_path = os.environ.get('ADX_TOKEN_FILE_PATH', '/var/run/secrets/azure/tokens/azure-identity-token')
    
        if tenant_id and client_id:
            logger.info(
                "Using WorkloadIdentityCredential",
                client_id=client_id,
                tenant_id=tenant_id,
                token_file_path=token_file_path
            )
            try:
                credential = WorkloadIdentityCredential(
                    tenant_id=tenant_id,
                    client_id=client_id,
                    token_file_path=token_file_path
                )
            except Exception as e:
                logger.warning(
                    "Failed to initialize WorkloadIdentityCredential, falling back",
                    error=str(e),
                    exception_type=type(e).__name__
                )
                credential = DefaultAzureCredential()
        else:
            logger.info("Using DefaultAzureCredential (missing WorkloadIdentity credentials)")
            credential = DefaultAzureCredential()
    
        try:
            kcsb = KustoConnectionStringBuilder.with_azure_token_credential(
                connection_string=config.cluster_url,
                credential=credential
            )
            client = KustoClient(kcsb)
            logger.debug("Kusto client initialized successfully", cluster_url=config.cluster_url)
            return client
        except Exception as e:
            logger.error(
                "Failed to create Kusto client",
                error=str(e),
                exception_type=type(e).__name__,
                cluster_url=config.cluster_url
            )
            raise
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool retrieves schema information, implying a read-only operation, but does not disclose other traits like error handling, performance, or authentication needs. The description adds minimal behavioral context beyond the basic action.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, well-structured sentence that efficiently conveys the tool's purpose and scope without unnecessary words. It is front-loaded with the main action and includes all essential details, making it highly concise and effective.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (1 parameter) and the presence of an output schema, the description is reasonably complete. It covers the purpose and parameter semantics adequately, though it lacks usage guidelines and detailed behavioral transparency. The output schema likely handles return values, reducing the need for description coverage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 1 parameter with 0% description coverage, so the description must compensate. It adds meaning by specifying that 'table_name' refers to 'a specified table in the Azure Data Explorer database', clarifying the parameter's context. However, it does not provide format details or constraints, leaving some gaps.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('Retrieves') and resource ('schema information for a specified table in the Azure Data Explorer database'), and distinguishes it from siblings by focusing on schema metadata rather than query execution, table listing, or data sampling. It explicitly mentions what is included: 'column names, data types, and other schema-related metadata'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'get_table_details' or 'list_tables'. It does not mention prerequisites, such as needing the table name, or exclusions, such as not being suitable for querying data. Usage is implied by the purpose but not explicitly stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/pab1it0/adx-mcp-server'

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