Skip to main content
Glama

get_entities

Extract real-world business entities, such as customers or transactions, linked to specified metrics for analysis like churn or revenue modeling.

Instructions

Entities are real-world concepts in a business such as customers, transactions, and ad campaigns. Analysis is often focused around specific entities, such as customer churn or annual recurring revenue modeling.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
metricsYes

Implementation Reference

  • The MCP tool handler for get_entities. Decorated with @dbt_mcp_tool which provides schema via type hints and description. Delegates execution to SemanticLayerFetcher.
    @dbt_mcp_tool( description=get_prompt("semantic_layer/get_entities"), title="Get Entities", read_only_hint=True, destructive_hint=False, idempotent_hint=True, ) async def get_entities( context: SemanticLayerToolContext, metrics: list[str], search: str | None = None ) -> list[EntityToolResponse]: return await context.semantic_layer_fetcher.get_entities( metrics=metrics, search=search )
  • List of semantic layer tools including get_entities, used to register the tools with the MCP server via register_sl_tools function.
    SEMANTIC_LAYER_TOOLS = [ list_metrics, list_saved_queries, get_dimensions, get_entities, query_metrics, get_metrics_compiled_sql, ]
  • Core logic for fetching entities via GraphQL query in SemanticLayerFetcher.get_entities, with caching by metrics key.
    async def get_entities( self, metrics: list[str], search: str | None = None ) -> list[EntityToolResponse]: metrics_key = ",".join(sorted(metrics)) if metrics_key not in self.entities_cache: entities_result = await submit_request( await self.config_provider.get_config(), { "query": GRAPHQL_QUERIES["entities"], "variables": { "metrics": [{"name": m} for m in metrics], "search": search, }, }, ) entities = [ EntityToolResponse( name=e.get("name"), type=e.get("type"), description=e.get("description"), ) for e in entities_result["data"]["entitiesPaginated"]["items"] ] self.entities_cache[metrics_key] = entities return self.entities_cache[metrics_key]
  • GraphQL query definition for fetching entities, referenced as GRAPHQL_QUERIES["entities"] in the fetcher.
    "entities": """ query GetEntities($environmentId: BigInt!, $metrics: [MetricInput!]!, $search: String) { entitiesPaginated(environmentId: $environmentId, metrics: $metrics, search: $search) { items { description name type } } } """,
  • Tool name constant definition used for registration and policy.
    GET_ENTITIES = "get_entities"

Other Tools

Related 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/dbt-labs/dbt-mcp'

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