Loading...
Loading...
Context layer for data and analytics AI agents with semantic layer, skills, and memory via MCP
npx skill4agent add aradotso/mcp-skills ktx-ai-data-agentsSkill by ara.so — MCP Skills collection.
npm install -g @kaelio/ktxnpx @kaelio/ktx setupktx setupktx statusktx 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)ktx setupmy-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)ktx.yamlsemantic-layer/wiki/.ktx/ktx ingestktx ingest --connection-id warehousektx ingest --forcektx sl "revenue"
ktx sl "monthly active users"
ktx sl "customer churn rate"ktx wiki "refund policy"
ktx wiki "customer segmentation"ktx mcp startktx mcp start --project-dir /path/to/projectversion: 1
project:
name: analytics
description: Company data warehouse and analytics
llm:
provider: anthropic
model: claude-sonnet-4-6
# API key stored in .ktx/secrets.yaml
embeddings:
provider: openai
model: text-embedding-3-small
# API key stored in .ktx/secrets.yaml
connections:
warehouse:
type: postgres
description: Main data warehouse
# Connection details in .ktx/secrets.yaml
context_sources:
dbt_main:
type: dbt
path: ./dbt
connection_id: warehouse
looker_models:
type: lookml
path: ./looker
connection_id: warehouse
notion_docs:
type: notion
# Notion token in .ktx/secrets.yamlconnections:
warehouse:
type: postgres
description: Production warehouse
host: db.example.com
port: 5432
database: analytics
schema: public
# username and password in .ktx/secrets.yamlllm:
provider: anthropic
model: claude-sonnet-4-6llm:
provider: vertex
model: claude-sonnet-4-6
project: my-gcp-project
location: us-central1llm:
provider: ai-gateway
endpoint: https://gateway.example.com/v1
model: claude-sonnet-4-6llm:
provider: claude-agent-sdk.ktx/secrets.yamlllm:
api_key: ${ANTHROPIC_API_KEY}
embeddings:
api_key: ${OPENAI_API_KEY}
connections:
warehouse:
username: ${DB_USERNAME}
password: ${DB_PASSWORD}semantic-layer/<connection-id>/semantic-layer/warehouse/revenue_metrics.yamlversion: 1
name: revenue_metrics
description: Core revenue and ARR metrics
connection_id: warehouse
metrics:
- name: monthly_recurring_revenue
description: Total MRR from active subscriptions
type: sum
sql: |
SELECT SUM(amount)
FROM subscriptions
WHERE status = 'active'
AND billing_period = 'monthly'
- name: annual_recurring_revenue
description: ARR (MRR * 12)
type: derived
sql: |
SELECT monthly_recurring_revenue * 12
dependencies:
- monthly_recurring_revenue
dimensions:
- name: subscription_plan
description: Subscription tier (free, pro, enterprise)
column: subscriptions.plan_name
- name: customer_segment
description: Customer business segment
column: customers.segmentversion: 1
name: customer_orders
description: Customer and order entities with relationship
connection_id: warehouse
entities:
- name: customers
description: Customer accounts
table: public.customers
primary_key: customer_id
- name: orders
description: Order transactions
table: public.orders
primary_key: order_id
foreign_keys:
- column: customer_id
references: customers.customer_id
joins:
- from: orders
to: customers
type: many_to_one
on: orders.customer_id = customers.customer_id# Search for revenue-related metrics
ktx sl "revenue"
# Get specific metric definition
ktx sl "monthly_recurring_revenue" --exact
# List all metrics in a source
ktx sl --source revenue_metricswiki/global/mkdir -p wiki/global
cat > wiki/global/refund-policy.md <<EOF
# Refund Policy
Our refund policy allows:
- Full refund within 30 days
- Partial refund (50%) within 90 days
- No refunds after 90 days
Process: Customer contacts support → Support approves → Finance processes
EOFwiki/user/<user-id>/mkdir -p wiki/user/alice
cat > wiki/user/alice/analysis-notes.md <<EOF
# Q1 2026 Revenue Analysis Notes
Key findings:
- Enterprise segment grew 40% QoQ
- Churn increased in SMB segment
- Marketing attribution needs review
EOFktx wiki "refund policy"
ktx wiki "customer segmentation"
ktx wiki "analysis notes" --user aliceRun npx skills add Kaelio/ktx --skill ktx and use the ktx skill to install
and configure ktx in this project.{
"mcpServers": {
"ktx": {
"command": "ktx",
"args": ["mcp", "start", "--project-dir", "/path/to/project"]
}
}
}ktx_search_semantic_layerktx_search_wikiktx_get_metric_definitionktx_get_join_pathktx_validate_queryWhat was our MRR last month?ktx_search_semantic_layer("monthly recurring revenue")ktx_get_metric_definition("monthly_recurring_revenue")Show me average order value by customer segmentktx_search_semantic_layer("order value")ktx_search_semantic_layer("customer segment")ktx_get_join_path("orders", "customers")How should I handle refunds in the revenue analysis?ktx_search_wiki("refund policy")ktx_search_semantic_layer("revenue")context_sources:
dbt_main:
type: dbt
path: ./dbt
connection_id: warehouse
manifest_path: ./dbt/target/manifest.json # Optionalcontext_sources:
looker_models:
type: lookml
path: ./looker
connection_id: warehousecontext_sources:
metabase_instance:
type: metabase
url: https://metabase.example.com
connection_id: warehouse
# API key in .ktx/secrets.yamlcontext_sources:
notion_docs:
type: notion
database_id: abc123...
# Token in .ktx/secrets.yamlktx statusktx mcp start --project-dir ...ktx ingest --connection-id warehouse --dry-run.ktx/secrets.yamlconnections:
warehouse:
username: ${DB_USERNAME}
password: ${DB_PASSWORD}export DB_USERNAME=myuser
export DB_PASSWORD=mypassword
ktx ingest --connection-id warehouseexport ANTHROPIC_API_KEY=sk-ant-...
ktx setupktx.yamlllm:
provider: anthropic
model: claude-sonnet-4-6ktx ingest --force # Will test LLM during ingestionktx ingest --forceraw-sources/<connection-id>/cat raw-sources/warehouse/ingestion.logktx statusktx ingestls -la semantic-layer/warehouse/ktx sl "revenue" # Instead of "mrr_monthly_q1"ktx sl generate --name customer_health --connection-id warehousesemantic-layer/warehouse/customer_health.yamlanalytics/
├── production/
│ └── ktx.yaml
├── staging/
│ └── ktx.yaml
└── development/
└── ktx.yamlktx ingest --project-dir ./production
ktx ingest --project-dir ./staging#!/bin/bash
ktx ingest --dry-run --connection-id warehouse
if [ $? -ne 0 ]; then
echo "ktx validation failed"
exit 1
fiKTX_PROJECT_DIRANTHROPIC_API_KEYOPENAI_API_KEYGOOGLE_APPLICATION_CREDENTIALSDB_USERNAMEDB_PASSWORDgit clone https://github.com/kaelio/ktx.git
cd ktx
pnpm install
uv sync --all-groups
pnpm run buildpnpm run setup:dev
pnpm run link:dev
ktx-dev --helppnpm run test
uv run pytest -qimport { Connector } from '@kaelio/ktx/connectors';
export class CustomConnector extends Connector {
async connect(): Promise<void> {
// Establish connection
}
async introspect(): Promise<SchemaMetadata> {
// Return table/column metadata
}
async sample(table: string, limit: number): Promise<Row[]> {
// Return sample rows
}
async detectJoins(): Promise<JoinCandidate[]> {
// Detect foreign key relationships
}
}ktx.yamlconnectors:
custom:
module: ./connectors/custom.ts
type: customroles/bigquery.dataViewerktx ingest --dry-run --connection-id warehouse