Skip to main content
Glama
semlayer MCP server

semlayer MCP server

context_for_question

Read-onlyIdempotent

Returns the semantic-layer context relevant to a natural-language question—tables, columns, keys, filters, metrics, routing guidance, and unconfirmed assumptions—so you can write correct SQL.

Instructions

START EVERY QUESTION ABOUT THE USER'S DATA HERE.

    Including when you are not sure a layer is loaded: if none is, this
    answers with `status` instead of failing, so there is no reason to
    decide for yourself that there is nothing to query. Deciding that
    without calling anything is how a user with a 36-table layer loaded
    was told the server had no data.

    Returns the part of the layer that bears on this question -- the
    tables it selected, their columns, keys, required filters and
    metrics, the routing knowledge for choosing between them -- plus
    `open_questions`: the claims underneath that nobody has confirmed.

    Write your SQL from this, `check_sql` it, then `run_sql`. Put the
    open questions under your answer as assumptions.
    

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": {
      "question": "<question>"
    },
    "name": "context_for_question"
  }
}

Input Schema

NameRequiredDescriptionDefault
questionYesThe user's question in their own words, as plain language and not SQL: 'what was net revenue by region last quarter'.

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.1.1
    • addedInput schema / properties / question / description
      Added value: +"The user's question in their own words, as plain language and not SQL: 'what was net revenue by region last quarter'."
  2. First observedv0.1.0

TDQS

A4.3/5.0
Behavior4/5

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

Annotations already establish read-only, idempotent, non-destructive behavior, so the bar is lower, but the description adds a genuinely non-obvious trait: when no layer is loaded it returns `status` rather than failing. It also characterizes `open_questions` as unconfirmed claims underneath the answer, which is behavioral context not present in the annotations. Return-value detail overlaps somewhat with the existing output schema, so it stops short of 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.

Conciseness4/5

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

The imperative opening is front-loaded in caps and the workflow instructions follow in logical order. The 36-table anecdote is motivating but comparatively wordy, and the description could shed a clause without losing meaning.

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?

For a single-parameter entry-point tool with an output schema, the description covers purpose, failure-mode behavior, return shape in semantic terms, and downstream workflow. It does not discuss context size limits or how much of a large layer is returned, which is the one remaining gap for a tool that must scale to a 36-table layer.

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

Parameters3/5

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

Schema coverage is 100% and the single `question` parameter is already documented as plain language rather than SQL, with an example. The description adds no format, length, or phrasing guidance beyond what the schema states, so the baseline of 3 applies.

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 states a specific verb and resource: it returns the portion of the loaded layer relevant to a question, including tables, columns, keys, required filters, metrics and routing knowledge. It also names its place in the pipeline relative to check_sql and run_sql, so an agent can distinguish it from siblings without opening a schema.

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

Usage Guidelines5/5

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

It gives an explicit trigger ("START EVERY QUESTION ABOUT THE USER'S DATA HERE") and an explicit anti-pattern to avoid (deciding on your own that no layer is loaded, with a concrete failure anecdote as justification). It also sequences the follow-on tools: write SQL from this, `check_sql` it, then `run_sql`.

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