ktx is a free, open source marketing & customer engagement project written in TypeScript and released under Apache-2.0. It has 1,628 GitHub stars, 110 forks and 52 open issues, and was last pushed 11 days ago. On this registry it ranks #57 of 76 tracked projects in Marketing & Customer Engagement, with 5 head-to-head comparisons available. It gained 23 stars over the last 30 tracked days.

What is ktx?

ktx is an open-source, Apache-2.0 licensed executable context layer, built and maintained by Kaelio in TypeScript, that lets AI agents such as Claude Code, Codex, Cursor, and OpenCode query analytical warehouses accurately using approved metric definitions, detected joinable columns, and company knowledge.

What it is

ktx is a self-improving context layer that sits on top of an existing SQL warehouse and teaches agents how to query it. Rather than letting a general-purpose agent re-explore the warehouse on every question, ktx builds and maintains the context the agent needs: approved metric definitions, joinable columns, and business knowledge drawn from wiki pages and analytics tooling. It lives in the analytics engineering and business intelligence ecosystem, and it presents itself to agents through a command-line interface and MCP tools.

The concrete problem it solves is metric drift. General-purpose agents invent their own metric logic and return numbers that do not match approved definitions, while traditional semantic layers require constant manual upkeep and do not absorb the rest of the company's knowledge. ktx replaces that manual maintenance by ingesting wiki content, organizing it, removing duplicates, and flagging contradictions for human review. It then maps the data stack by sampling tables, capturing metadata and usage patterns, detecting joinable columns, and annotating sources.

Key capabilities

  • Learns from company knowledge by ingesting wiki content, removing duplicates, and flagging contradictions across sources for human review.
  • Maps the data stack by sampling tables and capturing metadata and usage patterns, then detecting joinable columns.
  • Builds a semantic layer that combines raw tables and high-level metrics through a join graph, resolving chasm and fan traps automatically.
  • Serves agents at execution through CLI and MCP tools with combined full-text and semantic search across wiki and semantic-layer entities.
  • Searches context directly with commands such as ktx sl "revenue" for semantic sources and ktx wiki "refund policy" for local wiki pages.
  • Runs against PostgreSQL, Snowflake, BigQuery, ClickHouse, MySQL, SQL Server, SQLite, DuckDB, Amazon Athena, and MongoDB.
  • Integrates with dbt, MetricFlow, LookML, Looker, Metabase, Sigma, Notion, and Google Drive.
  • Is read-only by design.

Who uses it and how

  • Analytics and data teams whose business knowledge is scattered across dbt, Looker, Metabase, Notion, and team wikis, and who want agents to reuse canonical SQL instead of rewriting it on every prompt.
  • Teams working in a local project directory, where ktx setup creates or resumes a ktx project, configures providers and connections, builds context, and installs agent integration.
  • Workflows that check readiness with ktx status, which reports whether the LLM, embeddings, databases, context sources, and agent integration are configured, as in Agent integration ready: yes (codex:project).
  • Agent-driven setups where Claude Code, Codex, Cursor, or OpenCode install the skill via Run npx skills add Kaelio/ktx --skill ktx, and where ktx mcp start is run before the agent client opens.
  • Teams that want to supply their own model access, using their own LLM API keys or a local agent sign-in such as a Claude Pro/Max subscription through Claude Code, or local Codex authentication, with no extra usage billing from ktx.

Getting started

Install globally with npm install -g @kaelio/ktx, then run ktx setup to create or resume a local project and ktx status to confirm readiness. If ktx status prints ktx mcp start --project-dir ..., run that command before opening the agent client.

How it compares

The project's own comparison places ktx against general-purpose agents and traditional semantic layers. Against general-purpose agents, ktx adds automatically built warehouse context, detected joinable columns, trap resolution, approved reusable metric definitions, and wiki knowledge it absorbs and checks for contradictions; against traditional semantic layers, it automates the maintenance those systems require and adds CLI and MCP serving for agent execution. Both alternatives are weaker on at least one of these axes, according to that comparison.

When to use it โ€” and when not to

Skip ktx if there is no SQL warehouse, since it sits on top of one, and skip it if the need is a single ad-hoc query that psql or a notebook already handles. A self-hoster must operate more than a query client: a configured LLM provider for the model and embeddings, database connections, context sources such as dbt or a wiki, and an MCP server started for each agent client. The README is dense but the project also carries 52 open issues, so evaluators should check repository activity before depending on it.

project readme (upstream, from github) โ€” read inline

The context layer for data agents

npm version Codecov Tests Documentation Join the ktx Slack community License Y Combinator P25

Quickstart ยท CLI Reference ยท Agent Setup ยท Slack

Built and maintained by Kaelio


ktx is a self-improving context layer that teaches agents how to query your warehouse accurately - from approved metric definitions, joinable columns, and business knowledge it builds and maintains for you.

[!NOTE] Run ktx with your own LLM API keys or a local agent sign-in โ€” a Claude Pro/Max subscription through Claude Code, or your local Codex authentication. No extra usage billing from ktx.

Why ktx

General-purpose agents struggle on data tasks. They re-explore your warehouse on every question, invent their own metric logic, and return numbers that don't match approved definitions.

Traditional semantic layers don't fix this. They demand constant manual upkeep and don't absorb the rest of your company's knowledge.

ktx does both, automatically:

  • Learns from company knowledge. Ingests wiki content, organizes it, removes duplicates, and flags contradictions for human review.
  • Maps the data stack. Samples tables, captures metadata and usage patterns, detects joinable columns, and annotates sources so agents write better queries.
  • Builds a semantic layer. Combines raw tables and high-level metrics through a join graph that automatically resolves chasm and fan traps, so agents fetch metrics declaratively instead of rewriting canonical SQL each time.
  • Serves agents at execution. Exposes CLI and MCP tools with combined full-text and semantic search across wiki and semantic-layer entities.

How ktx compares

General-purpose agent Traditional semantic layer ktx
Builds warehouse context automatically โ€” โ€” โœ“
Detects joinable columns + resolves fan/chasm traps โ€” Manual โœ“
Approved, reusable metric definitions โ€” โœ“ โœ“
Absorbs wiki / Notion / team knowledge โ€” โ€” โœ“
Flags contradictions across sources โ€” โ€” โœ“
Ships CLI + MCP for agent execution Partial โ€” โœ“
Read-only by design n/a n/a โœ“

Who is ktx for

Use ktx if you:

  • Want agents like Claude Code, Codex, Cursor, or OpenCode to query your warehouse with approved metric definitions
  • Have business knowledge scattered across dbt, Looker, Metabase, Notion, and team wikis
  • Need agents to reuse canonical SQL instead of inventing it on every prompt

Skip ktx if you:

  • You don't have a SQL warehouse - ktx sits on top of one
  • You only need one ad-hoc query - psql or a notebook will do

Works with PostgreSQL, Snowflake, BigQuery, ClickHouse, MySQL, SQL Server, SQLite, DuckDB, Amazon Athena, and MongoDB. Integrates with dbt, MetricFlow, LookML, Looker, Metabase, Sigma, Notion, and Google Drive.

Quick Start

npm install -g @kaelio/ktx
ktx setup
ktx status

ktx setup creates or resumes a local ktx project, configures providers and connections, builds context, and installs agent integration.

Example ktx status after setup:

ktx project: /home/user/analytics
Project ready: yes
LLM ready: yes (claude-sonnet-4-6)
Embeddings ready: yes (text-embedding-3-small)
Databases configured: yes (warehouse)
Context sources configured: yes (dbt_main)
ktx context built: yes
Agent integration ready: yes (codex:project)

[!TIP] Already using an agent? Ask Claude Code, Codex, Cursor, or OpenCode from your project directory:

Run npx skills add Kaelio/ktx --skill ktx and use the ktx skill to install
and configure ktx in this project.

[!IMPORTANT] If ktx status prints ktx mcp start --project-dir ..., run it before opening your agent client.

Upgrading

Re-run the global install with the @latest tag:

npm install -g @kaelio/ktx@latest

First commands

Command Purpose
ktx setup Create, resume, or update a ktx project
ktx status Check project readiness
ktx ingest Build context for every configured connection
ktx sl "revenue" Search semantic sources
ktx wiki "refund policy" Search local wiki pages
ktx mcp start Start the MCP server for agent clients

See the CLI Reference for every command, flag, and option.

Project Layout

my-project/
โ”œโ”€โ”€ ktx.yaml                         # Project configuration
โ”œโ”€โ”€ semantic-layer/<connection-id>/  # YAML semantic sources
โ”œโ”€โ”€ wiki/global/                     # Shared business context
โ”œโ”€โ”€ wiki/user/<user-id>/             # User-scoped notes
โ”œโ”€โ”€ raw-sources/<connection-id>/     # Ingest artifacts and reports
โ””โ”€โ”€ .ktx/                            # Local state and secrets, git-ignored

Commit ktx.yaml, semantic-layer/, and wiki/. Keep .ktx/ local.

Project resolution defaults to KTX_PROJECT_DIR, then the nearest ktx.yaml, then the current directory. Pass --project-dir when scripting.

FAQ

  • Does ktx send my schema or query results to a hosted service? No. ktx runs locally. The only data leaving your machine is what you send to the LLM provider you configured.
  • Which LLM backends are supported? Anthropic API, Google Vertex AI, AI Gateway, the local Claude Code session through the Claude Agent SDK, and your local Codex authentication through the Codex SDK. See LLM configuration.
  • How is ktx different from a dbt or MetricFlow semantic layer? ktx ingests those layers and combines them with raw-table introspection and wiki content. Agents get one searchable surface instead of three disconnected ones - and ktx flags contradictions across sources.
  • Does ktx need a running server? There is no hosted service. The local MCP daemon runs on demand via ktx mcp start when an agent client needs it.
  • Is my warehouse safe? Yes. Connections are read-only - ktx never writes to your database.

Docs

Community

  • Slack โ€” ask questions, share what you're building, and chat with maintainers.
  • GitHub Issues โ€” report bugs and request features.
  • Contributing โ€” set up the repo, run tests, and open a PR.

Development

git clone https://github.com/kaelio/ktx.git
cd ktx
pnpm install
uv sync --all-groups
pnpm run build
pnpm run check

ktx is a pnpm + uv workspace:

Path Purpose
packages/cli TypeScript CLI and published npm package source
packages/cli/src/context Core context engine
packages/cli/src/llm LLM and embedding providers
packages/cli/src/connectors Database scan connectors
python/ktx-sl Semantic-layer query planning
python/ktx-daemon Portable compute service

Local development CLI:

pnpm run setup:dev
pnpm run link:dev
ktx-dev --help

Useful checks:

pnpm run type-check
pnpm run test
pnpm run dead-code
uv run pytest -q

Telemetry

ktx collects privacy-conscious usage telemetry to understand installs and improve setup, command reliability, and data-agent workflows. Catalog telemetry events do not record file paths, hostnames, SQL, schema names, table names, column names, error messages, raw environment values, or argv. Error reports use PostHog Error Tracking and can include stack frames and raw error messages, which may contain local file paths or the local username in those paths. ktx redacts secrets, credentials, database URLs, auth headers, argv, raw environment values, SQL text, row data, and user-typed prompt or MCP argument text from the explicit $exception payload. See Telemetry for the event catalog and opt-out options.

License

ktx is licensed under the Apache License, Version 2.0. See LICENSE.

Star History

Frequently asked questions

Is ktx free to use?

ktx is open source under the Apache-2.0 licence. There is no licence fee and no seat count โ€” you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does ktx do?

ktx is an executable context layer for data and analytics agents ๐Ÿ™ Allow Claude Code, Codex, or other AI agents to query analytical databases accurately and wi

What is ktx written in?

ktx is primarily written in TypeScript. Its source is publicly available at https://github.com/Kaelio/ktx, and it has 1,628 GitHub stars.