Skip to main content
Glama

create_model

Create semantic models from database tables or query definitions, specifying columns, measures, and data sources to enable intent-based database queries.

Instructions

Create a new semantic model, either from a database table or from a query.

From a table (provide sql_table or sql): create_model(name="orders", sql_table="public.orders", data_source="mydb", columns=[...], measures=[...])

From a query (provide query): create_model(name="monthly_summary", query={"source_model": "orders", "measures": ["*:count", "amount:sum"], "time_dimensions": [{"dimension": "created_at", "granularity": "month"}]}) Columns are auto-introspected from the query result.

Args: name: Unique model name (lowercase, underscores). sql_table: Database table name, e.g. "public.orders". sql: Alternative to sql_table — a custom SQL expression for the model's source. data_source: Name of the datasource (from list_datasources). description: What this model represents. columns: List of column definitions. Each: {"name": "col", "sql": "col", "type": "string"}. Types: string, number, time, date, boolean. Optional fields: primary_key, unique (single-column uniqueness that is not the PK; primary_key already implies it), allowed_aggregations (whitelist), filter (CASE WHEN inside aggregation), label, description, hidden, meta. measures: List of named formula definitions on the model. Each: {"name": "aov", "formula": "revenue:sum / *:count", "label": "...", "description": "...", "meta": {...}}. Queries can reference these by bare name (e.g. {"formula": "aov"}). meta is an optional opaque dict for caller bookkeeping (e.g. linking the formula back to a source identifier). query: A SLayer query dict (or list of stage dicts for a multi-stage backing query). When provided, the query is saved as the model's source_queries and the model becomes query-backed. Mutually exclusive with sql_table, sql, columns, and measures. variables: Default values for {var} placeholders in the backing query. Saved as query_variables on the model. Only meaningful when query is provided.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlNo
nameYes
queryNo
columnsNo
measuresNo
sql_tableNo
variablesNo
data_sourceNo
descriptionNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. First observedv0.10.0

TDQS

A4.5/5.0
Behavior4/5

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

With no annotations to lean on, the description carries the full burden for behavioral disclosure. It explains mutual exclusivity, that query-backed models save source_queries, that columns are auto-introspected from query results, and how variables map to query_variables. It does not detail failure conditions, idempotency, duplicate-name behavior, or permission requirements, but it is substantially transparent for a create operation.

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

Conciseness4/5

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

The description is long, but the tool's complexity justifies most of the length. It is well-structured with clear mode examples followed by an Args section. Some examples partially duplicate the function signature, but overall the information is organized and front-loaded with the core decision between table-based and query-based creation.

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

Completeness5/5

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

Given the tool's complexity, the absence of annotations, and 0% schema description coverage, the description provides nearly everything needed to invoke the tool correctly: parameter semantics, nested dict schemas, mode selection, mutual exclusivity, auto-introspection behavior, and variable handling. The output schema covers return-value expectations, so the description need not explain them.

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

Parameters5/5

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

The input schema has 0% description coverage, so the description is the only documentation for all 9 parameters. It comprehensively explains each parameter with examples, nested object structures, allowed types, constraints like uniqueness, and mutual exclusivity rules. This far exceeds what the bare schema provides.

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: creating a new semantic model. It also disambiguates from siblings by describing the two supported inputs (table-backed vs query-backed) and explicitly calling them 'new' models, which distinguishes this from edit_model and other sibling tools.

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

Usage Guidelines4/5

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

The description gives clear context on when to use table-based vs query-based creation, and references list_datasources as the source for data_source values. However, it does not explicitly state when not to use this tool versus closely related siblings like edit_model or ingest_datasource_models, so the guidance is strong but not explicit about exclusions.

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

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/MotleyAI/slayer'

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