🌐

ktx

Self-improving context layer for AI agents · teach Claude Code, Codex, Cursor & OpenCode to query data warehouses accurately. 自我进化的上下文层 · 教会 Claude Code、Codex、Cursor 和 OpenCode 精准查询数据仓库。
Kaelio/ktx · ⭐ 951 stars⭐ 951 星 Apache-2.0 · TypeScript
View on GitHub 在 GitHub 上查看 Documentation 文档
⚡ Quick Install⚡ 快速安装
npm install -g @kaelio/ktx

Then run ktx setup to start the interactive configuration wizard. 然后运行 ktx setup 启动交互式配置向导。

🧩 Core Capabilities🧩 核心能力

🔌 Database Ingestion🔌 数据库接入

Scan PostgreSQL, Snowflake, BigQuery, ClickHouse, MySQL, SQL Server, SQLite — extract schemas, foreign keys, profiles.扫描 PostgreSQL、Snowflake、BigQuery、ClickHouse、MySQL、SQL Server、SQLite — 提取 schema、外键、数据画像。

📐 Semantic Layer📐 语义层

YAML-based measures, dimensions, joins & segments. Validate, search, and compile SQL from approved definitions.基于 YAML 的度量、维度、连接和分段。验证、搜索并从已批准的定义编译 SQL。

📚 Wiki & Knowledge📚 Wiki 知识库

Structured markdown pages with frontmatter (tags, refs, usage mode). Full CRUD + hybrid search.带 frontmatter(标签、引用、使用模式)的结构化 Markdown 页面。完整 CRUD + 混合搜索。

🔎 Hybrid Search (RRF)🔎 混合搜索 (RRF)

Reciprocal Rank Fusion across semantic, lexical, dictionary & token lanes. Configurable weights, k=60 default.跨语义、词法、字典和 token 通道的倒数排名融合。可配置权重,默认 k=60。

🧠 MCP Server🧠 MCP 服务器

Model Context Protocol tools for agents: search, read, query, execute SQL (read-only enforced).为智能体提供模型上下文协议工具:搜索、读取、查询、执行 SQL(强制只读)。

📊 Query History📊 查询历史

Analyze historic SQL from Snowflake, BigQuery, PostgreSQL — detect table usage, common patterns, scope membership.分析来自 Snowflake、BigQuery、PostgreSQL 的历史 SQL — 检测表使用、常见模式、范围成员。

🔗 Relationship Discovery🔗 关系发现

Multi-signal join detection: name similarity, type compatibility, value overlap, embedding similarity, profile uniqueness.多信号连接检测:名称相似度、类型兼容性、值重叠、嵌入相似度、画像唯一性。

📦 Ingest Pipeline📦 摄取管道

Fetch → chunk → work units → reconcile → finalize. Isolated git worktrees, collision-safe with timestamp suffixes.获取 → 分块 → 工作单元 → 协调 → 完成。隔离的 git worktree,带时间戳后缀防冲突。

🚀 Usage Example🚀 使用示例
# Initialize configuration
ktx setup

# Ingest a PostgreSQL database
ktx ingest postgresql://user:pass@host:5432/mydb

# Search the semantic layer
ktx search "monthly active users by region"

# Start MCP server for agent integration
ktx mcp --port 3100

# List all semantic layer sources
ktx semantic list
📡 Data Flow📡 数据流
🔧 ktx.yaml 📥 Ingest 🧩 Chunk ⚙️ Work units 🤝 Reconcile ✅ Finalize
📄 Semantic YAML + 📝 Wiki MD + 🔎 Evidence index 🤖 Agent query
⚙️ Hybrid Search (RRF)⚙️ 混合搜索 (RRF)

score = Σ (weightlane / (k + ranklane)) 得分 = Σ (权重通道 / (k + 排名通道))

semantic weight=2.0
dictionary weight=2.0
lexical weight=1.5
token weight=0.75
k=60
🧮 RRF Score Calculator🧮 RRF 得分计算器

Enter ranks for each lane (1-based). Click calculate to see the fused RRF score. 输入每个通道的排名(从1开始)。点击计算查看融合后的 RRF 得分。

Share

Submit to AI Directories

Futurepedia AI Tool Hunt Awesome AI Tools ToolPilot AI Infinity

Nebula AI Tool Base