Skip to main content
Glama
manasa-manoj-nbr

semantic-context-mcp

Semantic Context MCP

An MCP server that gives an LLM the meaning of a data warehouse, not just its schema.

A model with schema access sees a table called tbl_rev_fnl_v2 and a column called amt. It has no way to know whether that's gross or net, cents or dollars, or a table nobody has touched in 40 days — so it guesses, and the guess runs and returns a plausible, wrong number. This server closes that gap by exposing four tools backed by real derived metadata: ownership, freshness, column units, deprecation status, and column-level lineage.

Stack: Python · Model Context Protocol · dbt + DuckDB · SQLite (FTS5) · sentence-transformers · sqlglot · Anthropic API (tool use / eval harness) · pytest

Tool

Answers

search_tables

"Which table holds daily net revenue?"

describe_table

"What does one row mean, and what unit is this column in?"

trace_lineage

"Where did this number come from, and what breaks if I change it?"

check_health

"Is this table safe to rely on right now?"

time — see "Setup" below. Without it, search_tables still works, just as keyword-only BM25.

Where the metadata actually comes from

The credibility of a project like this rests entirely on whether the "meaning" it reports is real or hand-typed for the demo. It's mostly real:

Signal

Source

Human-authored?

Table purpose, grain, materialization

manifest.json

No

Test pass/fail

dbt build results

No

Model-level lineage

manifest.json's depends_on

No

Column-level lineage

sqlglot.lineage() over compiled SQL

No

Table search (keyword)

SQLite FTS5 / BM25 over name + description + columns

No

Table search (semantic)

Cosine similarity over MiniLM embeddings

No

Row counts, 7-day row deltas

Live DuckDB queries at ingestion time

No

Freshness (hours since latest data)

Recomputed live on every call

No

Null rates per column

Live DuckDB queries at ingestion time

No

Ownership

dbt meta.owner, else git blame on the model file

Partly

Column descriptions and units

dbt schema.yml

Yes — the same input any dbt project already has

Deprecation status + successor

dbt meta.status / meta.superseded_by

Yes

Only two rows are human-authored, and both are ordinary dbt metadata any real project already maintains — this isn't reading from a hand-curated demo file.

Column-level lineage resolves 35 of 36 columns (97%) in the fixture warehouse. The one exception sums a column with no table-qualifying prefix across a JOIN — genuinely ambiguous SQL that sqlglot correctly declines to guess on, falling back to model-level lineage instead. trace_lineage always names exactly where a fallback happened, in unresolved_notes — never silently.

The demo warehouse is dbt-labs/jaffle_shop_duckdb with four added "decoy" revenue models, since the stock fixture is too clean to show any ambiguity. The decoys are synthetic and labelled as such in fixture/ — the pipeline that derives metadata from them is not.

Related MCP server: Semantic BI MCP

Setup

Requires Python 3.12+ and uv. No GPU needed.

uv sync

This installs only what the server itself needs and gives you a fully working server: describe_table, trace_lineage, and check_health are fully live, and search_tables works in keyword (BM25) mode. Heavier, optional pieces are separate extras so the base install stays fast:

uv sync --extra search   # sentence-transformers + numpy -- semantic ranking for search_tables
uv sync --extra ingest   # sqlglot + duckdb -- only needed to (re)build catalog.db
uv sync --extra dbt      # dbt-core + dbt-duckdb -- only needed to build the fixture warehouse
uv sync --extra eval     # anthropic + pyyaml -- only needed to run the eval harness

uv run <anything> re-syncs the environment to match whatever --extra flags that invocation passes — running a bare uv run python ... after syncing extras in can silently drop them again. If a tool that was working starts raising ModuleNotFoundError, re-run the uv sync --extra ... line below rather than debugging the code.

Build the fixture warehouse

Needed once before the server has data to serve — without it, every tool call fails with a clear error telling you to run this.

uv sync --extra dbt --extra ingest --extra search
uv run python fixture/build_warehouse.py       # seed -> dbt build -> dbt docs generate
uv run python -m semantic_context_mcp.ingest    # manifest + catalog + run_results -> catalog.db

Re-running this sequence is always safe — both scripts fully replace their outputs rather than merging into them, and build_warehouse.py regenerates seed dates so the "stale" decoy table always looks stale relative to today. dbt's very first invocation in a fresh venv can sit silent for 20-30 seconds while it compiles bytecode for its own dependency tree before printing anything — build_warehouse.py prints a heads-up before that step so it doesn't look hung; subsequent runs are fast.

Run it

uv run semantic-context-mcp

The server speaks MCP over stdio and sits silently waiting for a client — that's correct behavior, not a hang. To exercise it directly without a client:

uv run python scripts/smoke_stdio.py

That script spawns the real server over the real transport and drives every tool through both happy-path and error-path calls, printing each result.

Try it as a data analyst would

uv run python -c "
from semantic_context_mcp.core import search, describe, health

for m in search.run('daily net revenue'):
    print(m.name, '-', m.purpose)

print()
print(describe.run('fct_revenue_daily').columns)
print()
print(health.run('tbl_rev_fnl_v2').summary)
"

Connect to Claude Desktop

Add to claude_desktop_config.json (%APPDATA%\Claude\claude_desktop_config.json on Windows, ~/Library/Application Support/Claude/claude_desktop_config.json on macOS):

{
  "mcpServers": {
    "semantic-context": {
      "command": "uv",
      "args": ["--directory", "/absolute/path/to/semantic-context-mcp", "run", "semantic-context-mcp"]
    }
  }
}

Restart Claude Desktop, then ask "What's our daily revenue table?"

Testing

uv run pytest

The suite covers synthetic unit tests (fast, no fixture needed, always run) and real-data integration tests that build the actual dbt/DuckDB warehouse and ingest it into catalog.db — the latter are what caught every real bug during development (a dbt artifact-ordering issue, a DuckDB NULL-vs-zero aggregation bug, a naive/aware datetime crash, a missing test hiding a staleness signal, and a false "lineage unresolved" report on a fully-resolved column). Two additional scripts exercise the protocol layer directly rather than through pytest:

uv run python scripts/smoke_stdio.py                       # real server, real MCP stdio transport
uv run python -m semantic_context_mcp.eval.mcp_path_smoke  # proves the eval harness matches the real server

Evaluation

eval/ measures whether having this server's tools available actually changes whether Claude picks the right table and states the right caveats, compared to schema access alone. Three arms, the same 25 questions, the same model and system prompt — only the tool set differs:

Arm

Tools

schema_only

table + column names and SQL types only — no metadata (the realistic baseline)

schema_and_server

schema-only tools, plus the four semantic tools

server_only

the four semantic tools alone

uv sync --extra eval
export ANTHROPIC_API_KEY=...                                       # or `ant auth login`
uv run python -m semantic_context_mcp.eval                         # all 3 arms, 25 questions x 3 runs
uv run python -m semantic_context_mcp.eval --questions 5 --runs 1  # a cheap smoke run
uv run python -m semantic_context_mcp.eval --dry-run               # exercises the harness, no API calls

Each question/run/arm writes a transcript to eval/runs/<timestamp>/, so any surprising result is checkable rather than trusted. Grading (eval/grading.py) is deliberately simple keyword/table-name matching over the model's final answer — not an LLM judge — and is fully unit-tested without any network access.

Repository layout

fixture/
  jaffle_shop_duckdb/    Cloned dbt project + models/decoys/*.sql (4 synthetic ambiguous tables)
  pristine_seeds/        Untouched original seed CSVs -- prepare_seeds.py's source of truth
  prepare_seeds.py       Shifts seed dates to end "yesterday", idempotently
  build_warehouse.py     seed -> dbt build -> dbt docs generate
src/semantic_context_mcp/
  models.py        Pydantic contract for all four tool returns
  errors.py        Errors written to be read by the model
  server.py        MCP adapter -- no logic
  core/            The actual logic; also what eval/tools.py calls
  ingest/          dbt artifacts + git + SQLite -> catalog.db
  eval/            Three-arm measurement harness (see "Evaluation" above)
scripts/
  smoke_stdio.py   Drives the real server over the real MCP transport
tests/             Contract, consistency, ingestion, eval, and stdout-purity guards

Available Tools

4 tools
check_healthA

Check whether a table is safe to rely on right now.

Call this before presenting any number derived from a table you have not already checked, and whenever a user mentions a table you did not choose yourself. Reports freshness, row-count movement, null rates, and dbt test results, plus a one-line verdict. A verdict of "deprecated" or "failing" means you should warn the user before using the table, not silently proceed.

Args: table: Table name, fully qualified or bare.

ParametersJSON Schema
NameRequiredDescriptionDefault
tableYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
notesNo
tableYes
testsNo
summaryYesOne line a human can act on
verdictYes
row_countNo
checked_atNo
null_ratesNoColumn name -> percentage of NULL values
freshness_hoursNoHours since the most recent event in the table
row_count_delta_7dNo
max_event_timestampNo

TDQS

A4.5/5.0
Behavior4/5

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

With no annotations, the description carries the full burden. It discloses what the tool reports (freshness, row-count movement, null rates, dbt test results, one-line verdict) and how to act on the verdict, which goes beyond a vague 'checks health'. It does not explicitly state read-only behavior or side effects, but the nature of the tool implies a safe inspection. This is solid but not exhaustive.

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 front-loaded with the main purpose, followed by clear usage guidance, a concise list of reported metrics, interpretation instructions, and the parameter description. Every sentence adds value and there is no redundancy or filler.

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 has a single parameter and an output schema, the description provides ample context: what the tool does, when to use it, what it returns (including specific metrics and verdict), and how to interpret results. It is fully self-contained and leaves no critical gaps for an agent to operate correctly.

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 coverage is 0%, but the description compensates with an Args section: 'table: Table name, fully qualified or bare.' This adds format guidance beyond the bare type of 'string' in the schema, giving the agent enough to construct a valid call.

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 begins with a specific verb+resource: 'Check whether a table is safe to rely on right now.' This clearly distinguishes the tool from siblings like search_tables, describe_table, and trace_lineage, which address different concerns (discovery, structure, lineage).

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 explicit when-to-use guidance: 'Call this before presenting any number derived from a table you have not already checked, and whenever a user mentions a table you did not choose yourself.' It also explains how to interpret verdicts. However, it does not explicitly state when not to use the tool or name alternatives, so it falls slightly short of a 5.

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

describe_tableA

Get the full meaning of one table: purpose, grain, owner, status, and columns.

Call this before using any table you have not already described in this conversation. The column unit field is the part that matters most — it distinguishes gross from net and cents from dollars, which the schema alone cannot tell you. A unit of "unknown" means nobody documented it; say so rather than guessing.

Args: table: Table name, fully qualified or bare (e.g. "main.fct_revenue_daily"). include_columns: Set False when you only need purpose, owner, and status.

ParametersJSON Schema
NameRequiredDescriptionDefault
tableYes
include_columnsNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
nameYes
grainNoWhat one row represents, e.g. 'one row per customer per day'
ownerNo
statusNo
columnsNo
purposeYes
row_countNo
truncatedNoTrue when the column list was cut to protect the context window
last_updatedNo
superseded_byNo
materializationNotable, view, incremental, ...
truncation_hintNoHow to retrieve the omitted columns when truncated is True

TDQS

A4.6/5.0
Behavior4/5

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

With no annotations provided, the description carries the full burden. It discloses the interpretive behavior of the `unit` field, explaining that it distinguishes gross/net and cents/dollars, and instructs the agent to say 'unknown' rather than guess when the unit is undocumented. This adds valuable context beyond the schema, but it doesn't cover other potential behaviors like error handling or access requirements.

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 front-loaded with the purpose, followed by usage guidance and a clearly structured Args section. Every sentence adds information, from the unit field warning to the parameter explanations, with no filler. It's concise yet complete.

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?

The description covers the essential context for using this tool: when to call it, what to expect (purpose, grain, owner, status, columns), and the key interpretation caveat about the unit field. Since an output schema is present, it doesn't need to enumerate return values. It's complete for the tool's complexity.

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 schema has no descriptions for the parameters (0% coverage), but the description compensates fully with an Args section. For `table`, it provides an example of a fully qualified name; for `include_columns`, it explains when to set it to False. This gives the agent the needed semantic detail.

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 starts with a clear, specific statement: 'Get the full meaning of one table: purpose, grain, owner, status, and columns.' This immediately identifies the verb, resource, and scope, distinguishing it from sibling tools like search_tables, which searches across tables, and trace_lineage, which follows relationships.

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 provides a clear usage rule: 'Call this before using any table you have not already described in this conversation.' It also gives conditional guidance for include_columns, saying to set False when only purpose, owner, and status are needed. However, it doesn't explicitly mention alternative tools or describe when not to use it beyond the already-described condition, so it lacks the full 5-level criteria.

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

search_tablesA

Find warehouse tables by describing what you want in plain English.

Call this before writing SQL whenever you are not certain which table holds the data — table names alone do not tell you whether a table is current, correct, or maintained. Returns candidates ranked by relevance, each with its owner and status. Deprecated tables are included and labelled, so you can recognize them in existing queries rather than assuming they are fine.

Args: query: What you are looking for, e.g. "daily net revenue" or "customer churn". limit: Maximum candidates to return (1-25).

ParametersJSON Schema
NameRequiredDescriptionDefault
limitNo
queryYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.8/5.0
Behavior5/5

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

With no annotations, the description carries the full burden of behavioral disclosure. It goes beyond a simple 'search' by revealing that results include deprecated tables (labeled), are ranked by relevance, and include owner and status. This helps the agent understand the return value and potential pitfalls, exceeding the minimum expected for a read-only search tool.

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 appropriately sized and well-structured: it opens with the purpose, then provides usage context, then describes return behavior, and finally lists arguments with examples. Every sentence adds value, with no redundancy or filler.

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 has only two simple parameters and no annotations, the description covers all essentials: when to call it, what it returns, and how parameters behave. The existence of an output schema means the description need not detail the return format, but it still mentions key output traits. It is complete for the tool's complexity.

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?

Schema description coverage is 0%, so the description must compensate. It fully explains both parameters: 'query' is described as 'What you are looking for, e.g. ...' and 'limit' is described as 'Maximum candidates to return (1-25).' This adds meaningful constraints and examples that are absent from the input schema.

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 starts with a clear, specific verb phrase: 'Find warehouse tables by describing what you want in plain English.' It identifies the resource (warehouse tables) and the method (natural language query), distinguishing it from sibling tools like describe_table or trace_lineage. The purpose is immediately obvious.

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 explicit guidance on when to use the tool: 'Call this before writing SQL whenever you are not certain which table holds the data.' It explains why table names alone are insufficient, but it does not explicitly name alternatives or state when not to use it. Clear context is provided, but exclusion/alternative guidance is missing.

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

trace_lineageA

Trace where a table or column's data comes from, and what depends on it.

Call this when you need to justify a number, when a value looks wrong and you need to find where it was computed, or before suggesting a change to a table so you can say what it would break. Pass column for column-level lineage. Edges marked model_only mean the SQL could not be parsed down to the column — the dependency is real, the precision is not.

Args: table: Table name, fully qualified or bare. column: Optional column to trace; omit for table-level lineage. direction: "up" for sources, "down" for dependents, "both" (default). depth: How many hops to follow (1-5).

ParametersJSON Schema
NameRequiredDescriptionDefault
depthNo
tableYes
columnNo
directionNoboth

Output Schema

ParametersJSON Schema
NameRequiredDescription
depthNo
tableYes
columnNo
upstreamNo
directionNo
downstreamNo
unresolved_notesNoPlaces where column-level resolution failed and why

TDQS

A4.6/5.0
Behavior4/5

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

With no annotations provided, the description carries the full burden. It discloses a key behavioral nuance: 'Edges marked model_only mean the SQL could not be parsed down to the column — the dependency is real, the precision is not.' This goes beyond the basic operation and warns about data-quality limitations.

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 compact, front-loaded with the primary purpose, then uses a short usage-rule sentence and a tight Args list. No filler; every sentence and parameter comment serves a purpose.

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?

Despite lack of annotations, the description covers purpose, usage triggers, parameter semantics, and a precision caveat. Since an output schema exists, the absence of return-format details is acceptable. The tool is fully specified for an agent to select and invoke correctly.

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 schema has 0% description coverage, but the Args section explains every parameter: table as 'fully qualified or bare', column as optional for table-level lineage, direction with valid values, and depth with a hop range. This adds meaning beyond the bare schema names and defaults.

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 opens with a specific verb and resource: 'Trace where a table or column's data comes from, and what depends on it.' This clearly defines lineage tracing and distinguishes it from sibling tools like search_tables, describe_table, and check_health.

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 explicit trigger scenarios: 'when you need to justify a number, when a value looks wrong and you need to find where it was computed, or before suggesting a change to a table so you can say what it would break.' It does not name alternatives directly (e.g., use describe_table for schema-only questions), but the context is clear enough.

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

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 4 tool updatesv0.1.0
    • First observedcheck_health
    • First observeddescribe_table
    • First observedsearch_tables
    • First observedtrace_lineage

TDQS

A4.7/5.0

Scored across 4 tools

Disambiguation5/5

Each tool addresses a distinct aspect of table understanding: search finds tables by description, describe explains meaning and columns, trace_lineage maps data flow, and check_health assesses reliability. There is no overlap between these purposes, so an agent can cleanly select the right tool for the job.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern with lowercase and underscores: search_tables, describe_table, trace_lineage, check_health. The verbs are specific and the nouns clearly indicate the target resource, making the API predictable.

Tool Count5/5

Four tools is a tight, well-scoped set for a semantic context server focused on warehouse table understanding. Each tool covers a necessary capability without redundancy or bloat, fitting comfortably within the ideal 3-15 range.

Completeness5/5

The tool surface covers the complete workflow for exploring and validating tables: discover via search, inspect via describe, understand dependencies via lineage, and assess trustworthiness via health. There are no obvious missing operations that would force an agent to work around gaps.

Maintenance

ActivitySlowing
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    B
    quality
    D
    maintenance
    An MCP server that bridges AI assistants with data warehouses through Cube.js to enable governed, natural language semantic analytics queries. It provides tools for metadata discovery and secure query execution while enforcing governance policies like PII blocking and access limits.
    3
    47 npm
    1
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    Model Context Protocol (MCP) server that gives AI assistants a safe, correct data-analyst capability over business metrics - without raw SQL improvisation.
    -