Skip to main content
Glama
Semantic Rails MCP Server

Semantic Rails MCP Server

Official

upsert_model

DestructiveIdempotent

Create or update a semantic model and its graph entity, merging fields and configuring calendars, keys, entities, and preferences for governed analytics.

Instructions

Upsert a model and its graph entity. calendar: true makes it the package calendar for calendar_id (default "default", which a package with calendars needs), its columns ordinary dimensions; time.fill and time buckets stay Gregorian. false reverts it. calendar_id on a regular model binds its times to a calendar (only the default in this release). Fields merge into an existing model: a dimension, time or measure given only label, description, synonyms or meta keeps its other fields; given more, it is rewritten. replace: true rewrites the model from the arguments, keeping its id, entities, calendar_id, zero_through (how far its tables are loaded), one_per_key, prefer_over and distinct_from. dropped_fields lists what a rewrite drops. one_per_key: true reads a relation whose rows repeat the key as one row per primary_key, each column the key's one value (NULL where its rows disagree); put columns that vary on a row-grain model of the same relation. prefer_over: look-alike model ids it answers for; [] removes. primary_key [] makes a row-grain model (no key); entities ({parent: {} or {expr: column}}) merges parent entities. Relate models with upsert_relationship.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "project_path": "<project_path>",
      "model_id": "<model_id>",
      "entity_key": "<entity_key>",
      "relation": "<relation>",
      "primary_key": "<primary_key>",
      "expected_revision": "<expected_revision>",
      "idempotency_key": "<idempotency_key>"
    },
    "name": "upsert_model"
  }
}

Input Schema

NameRequiredDescriptionDefault
groupNocore
labelNo
timesNo
dry_runNo
replaceNo
calendarNo
entitiesNo
measuresNo
model_idYes
relationYes
dimensionsNo
entity_keyYes
calendar_idNo
descriptionNo
full_reportNotrue: the whole report, not a summary
one_per_keyNo
prefer_overNo
primary_keyYes
project_pathYes
idempotency_keyYes
expected_revisionYes

Output Schema

NameRequiredDescriptionDefault
okYes
errorNo
parseNo
errorsNo
statusYes
changesYes
dry_runYes
revisionYes
project_pathYes
base_revisionYes
changed_filesYes
route_changesNo
workspace_rootNo
idempotency_keyYes
current_revisionYes
expected_revisionYes
idempotent_replayYes
proposed_revisionYes
route_decisions_addedNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv0.3.4
    • changedInput schema / properties / full_report / description
      Previous value: -"true: the whole report (default: a summary; see its report field)"New value: +"true: the whole report, not a summary"
    • addedInput schema / properties / prefer_over
      Added value: +{
      +  "anyOf": [
      +    {
      +      "items": {
      +        "type": "string"
      +      },
      +      "type": "array"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null
      +}
  2. Changed7 schema fields changedv0.3.2
    • addedInput schema / properties / entities
      Added value: +{
      +  "anyOf": [
      +    {
      +      "additionalProperties": true,
      +      "type": "object"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null
      +}
    • addedInput schema / properties / full_report
      Added value: +{
      +  "default": false,
      +  "description": "true: the whole report (default: a summary; see its report field)",
      +  "type": "boolean"
      +}
    • removedInput schema / properties / joins
      Removed value: -{
      -  "anyOf": [
      -    {
      -      "additionalProperties": true,
      -      "type": "object"
      -    },
      -    {
      -      "type": "null"
      -    }
      -  ],
      -  "default": null
      -}
    • addedInput schema / properties / one_per_key
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "boolean"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null
      +}
    • addedOutput schema / $defs / ArchitectFileChange / properties / diff_truncated
      Added value: +{
      +  "default": false,
      +  "type": "boolean"
      +}
    • addedOutput schema / properties / route_changes
      Added value: +{
      +  "items": {
      +    "additionalProperties": true,
      +    "type": "object"
      +  },
      +  "type": "array"
      +}
    • addedOutput schema / properties / route_decisions_added
      Added value: +{
      +  "items": {
      +    "additionalProperties": true,
      +    "type": "object"
      +  },
      +  "type": "array"
      +}
  3. Changed50 schema fields changedv0.3.1
    • addedInput schema / properties / calendar
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "boolean"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null
      +}
    • addedInput schema / properties / calendar_id
      Added value: +{
      +  "default": "",
      +  "type": "string"
      +}
    • removedInput schema / properties / description / title
      Removed value: -"Description"
    • removedInput schema / properties / dimensions / title
      Removed value: -"Dimensions"
    • removedInput schema / properties / dry_run / title
      Removed value: -"Dry Run"
    • removedInput schema / properties / entity_key / title
      Removed value: -"Entity Key"
    • removedInput schema / properties / expected_revision / title
      Removed value: -"Expected Revision"
    • removedInput schema / properties / group / title
      Removed value: -"Group"
    • removedInput schema / properties / idempotency_key / title
      Removed value: -"Idempotency Key"
    • removedInput schema / properties / joins / title
      Removed value: -"Joins"
    • addedInput schema / properties / label
      Added value: +{
      +  "default": "",
      +  "type": "string"
      +}
    • removedInput schema / properties / measures / title
      Removed value: -"Measures"
    • removedInput schema / properties / model_id / title
      Removed value: -"Model Id"
    • removedInput schema / properties / primary_key / title
      Removed value: -"Primary Key"
    • removedInput schema / properties / project_path / title
      Removed value: -"Project Path"
    • removedInput schema / properties / relation / title
      Removed value: -"Relation"
    • addedInput schema / properties / replace
      Added value: +{
      +  "default": false,
      +  "type": "boolean"
      +}
    • removedInput schema / properties / times / title
      Removed value: -"Times"
    • removedInput schema / title
      Removed value: -"upsert_modelArguments"
    • removedOutput schema / $defs / ArchitectFileChange / properties / after_bytes / title
      Removed value: -"After Bytes"
    • removedOutput schema / $defs / ArchitectFileChange / properties / after_sha256 / title
      Removed value: -"After Sha256"
    • removedOutput schema / $defs / ArchitectFileChange / properties / before_bytes / title
      Removed value: -"Before Bytes"
    • removedOutput schema / $defs / ArchitectFileChange / properties / before_sha256 / title
      Removed value: -"Before Sha256"
    • removedOutput schema / $defs / ArchitectFileChange / properties / content_encoding / title
      Removed value: -"Content Encoding"
    • removedOutput schema / $defs / ArchitectFileChange / properties / diff / title
      Removed value: -"Diff"
    • removedOutput schema / $defs / ArchitectFileChange / properties / operation / title
      Removed value: -"Operation"
    • removedOutput schema / $defs / ArchitectFileChange / properties / path / title
      Removed value: -"Path"
    • removedOutput schema / $defs / ArchitectFileChange / properties / proposed_content / title
      Removed value: -"Proposed Content"
    • removedOutput schema / $defs / ArchitectFileChange / title
      Removed value: -"ArchitectFileChange"
    • removedOutput schema / $defs / ArchitectMutationIssue / properties / code / title
      Removed value: -"Code"
    • removedOutput schema / $defs / ArchitectMutationIssue / properties / details / title
      Removed value: -"Details"
    • removedOutput schema / $defs / ArchitectMutationIssue / properties / message / title
      Removed value: -"Message"
    • removedOutput schema / $defs / ArchitectMutationIssue / title
      Removed value: -"ArchitectMutationIssue"
    • removedOutput schema / properties / base_revision / title
      Removed value: -"Base Revision"
    • removedOutput schema / properties / changed_files / title
      Removed value: -"Changed Files"
    • removedOutput schema / properties / changes / title
      Removed value: -"Changes"
    • removedOutput schema / properties / current_revision / title
      Removed value: -"Current Revision"
    • removedOutput schema / properties / dry_run / title
      Removed value: -"Dry Run"
    • removedOutput schema / properties / errors / title
      Removed value: -"Errors"
    • removedOutput schema / properties / expected_revision / title
      Removed value: -"Expected Revision"
    • removedOutput schema / properties / idempotency_key / title
      Removed value: -"Idempotency Key"
    • removedOutput schema / properties / idempotent_replay / title
      Removed value: -"Idempotent Replay"
    • removedOutput schema / properties / ok / title
      Removed value: -"Ok"
    • removedOutput schema / properties / parse / title
      Removed value: -"Parse"
    • removedOutput schema / properties / project_path / title
      Removed value: -"Project Path"
    • removedOutput schema / properties / proposed_revision / title
      Removed value: -"Proposed Revision"
    • removedOutput schema / properties / revision / title
      Removed value: -"Revision"
    • removedOutput schema / properties / status / title
      Removed value: -"Status"
    • removedOutput schema / properties / workspace_root / title
      Removed value: -"Workspace Root"
    • removedOutput schema / title
      Removed value: -"ArchitectMutationResult"
  4. First observedv0.2.0

TDQS

A3.6/5.0
Behavior4/5

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

Annotations already flag destructiveHint=true and idempotentHint=true, and the description adds substantive detail beyond them: a rewrite preserves id, entities, calendar_id, zero_through, one_per_key, prefer_over and distinct_from, dropped_fields lists what is lost, and calendar:false reverts. Concurrency/auth behavior of expected_revision and idempotency_key is left undisclosed, which keeps it from a 5.

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

Conciseness3/5

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

Front-loads the purpose, then degrades into a dense run-on of parameter notes with telegraphic fragments ('[] removes', 'time.fill and time buckets stay Gregorian'). Most sentences earn their place, but the lack of grouping or ordering makes it harder to scan than its length warrants.

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

Completeness3/5

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

Output schema exists, so return values needn't be explained, and destructive/calendar behavior is covered well. For a destructive 21-parameter mutation tool, though, omitting dry_run (a safe-preview escape hatch), expected_revision and idempotency_key leaves an agent without the concurrency and safety story it needs.

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?

Schema description coverage is only 5% across 21 params, so the burden falls on the description, and it carries most of it: merge-vs-rewrite rules per field, one_per_key row-collapsing semantics, prefer_over as look-alike model ids, entities parent syntax, primary_key []. It leaves dry_run, expected_revision, idempotency_key, group and full_report entirely unexplained, which is a real gap for 21 parameters.

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

Purpose4/5

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

Opens with a concrete verb+resource: 'Upsert a model and its graph entity,' and later names the sibling boundary ('Relate models with upsert_relationship'). It never contrasts itself with suggest_model or upsert_metric, but the core verb/resource pair is unambiguous.

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

Usage Guidelines3/5

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

Gives conditional guidance for individual flags (calendar:true makes it the package calendar, replace:true rewrites, primary_key [] makes a row-grain model) and routes relationship work to upsert_relationship. It does not say when to choose this tool over suggest_model or when a merge call is preferable to a rewrite beyond the implied flag semantics.

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