KTXDocs
Integrations

Agent Clients

Set up KTX with Claude Code, Cursor, Codex, and OpenCode.

KTX integrates with coding agents through two channels that can be used independently or together:

  • MCP server — A persistent Model Context Protocol server that exposes KTX tools (semantic queries, knowledge search, SQL execution) directly to the agent
  • CLI skills — Command definitions that teach the agent how to invoke KTX via the terminal

Run ktx setup and select your agent targets, or configure manually using the snippets below.

Claude Code

Install via ktx setup

During setup, select Claude Code from the agent targets. KTX writes:

ModeFile
CLI skills.claude/skills/ktx/SKILL.md
MCP server.mcp.json (under mcpServers.ktx)

Both project-scoped and global installations are supported. Global installs write to ~/.claude/skills/ktx/SKILL.md.

Manual MCP configuration

Add KTX to .mcp.json at your project root:

.mcp.json
{
  "mcpServers": {
    "ktx": {
      "command": "ktx",
      "args": [
        "--project-dir", "/path/to/ktx-project",
        "serve",
        "--mcp", "stdio",
        "--semantic-compute",
        "--execute-queries"
      ],
      "env": {}
    }
  }
}

Replace /path/to/ktx-project with your KTX project directory. For a pinned local checkout, use the absolute path to the built CLI as the command and arguments generated by ktx setup.

Manual CLI skills configuration

Create .claude/skills/ktx/SKILL.md:

.claude/skills/ktx/SKILL.md
---
name: ktx
description: Use local KTX semantic context, wiki knowledge, and safe SQL execution for this project.
---

Available commands:
- `ktx agent context --json --project-dir /path/to/project`
- `ktx agent sl list --json --project-dir /path/to/project`
- `ktx agent sl read '<sourceName>' --json --project-dir /path/to/project`
- `ktx agent sl query --json --project-dir /path/to/project --connection-id '<id>' --query-file '<path>' --execute --max-rows 100`
- `ktx agent wiki search '<query>' --json --project-dir /path/to/project`
- `ktx agent wiki read '<pageId>' --json --project-dir /path/to/project`
- `ktx agent sql execute --json --project-dir /path/to/project --connection-id '<id>' --sql-file '<path>' --max-rows 100`

Workflow tips

  • Claude Code discovers skills automatically from .claude/skills/ — no restart needed after setup
  • The MCP server starts on-demand when Claude Code first calls a KTX tool
  • Use --semantic-compute to enable query planning and execution
  • Global installation (~/.claude/skills/ktx/SKILL.md) makes KTX available in all projects without per-project setup

Cursor

Install via ktx setup

During setup, select Cursor from the agent targets. KTX writes:

ModeFile
CLI rules.cursor/rules/ktx.mdc
MCP server.cursor/mcp.json (under mcpServers.ktx)

Cursor supports project-scoped installation only.

Manual MCP configuration

Create or edit .cursor/mcp.json:

.cursor/mcp.json
{
  "mcpServers": {
    "ktx": {
      "command": "ktx",
      "args": [
        "--project-dir", "/path/to/ktx-project",
        "serve",
        "--mcp", "stdio",
        "--semantic-compute",
        "--execute-queries"
      ],
      "env": {}
    }
  }
}

Manual CLI rules configuration

Create .cursor/rules/ktx.mdc with the same content structure as the Claude Code SKILL.md file — Cursor rules use the .mdc extension but support the same markdown format with command definitions.

Workflow tips

  • After adding MCP config, restart Cursor or reload the window for the server to connect
  • Cursor rules in .cursor/rules/ are automatically loaded into agent context
  • MCP tools appear in Cursor's tool list once the server is running
  • Project-scoped only — no global installation option

Codex

Install via ktx setup

During setup, select Codex from the agent targets. KTX writes:

ModeFile
CLI skills.agents/skills/ktx/SKILL.md
MCP server.agents/mcp/ktx.json (under mcpServers.ktx)

Both project-scoped and global installations are supported. Global installs write to $CODEX_HOME/skills/ktx/SKILL.md (defaults to ~/.codex/skills/ktx/SKILL.md).

Manual MCP configuration

Create or edit .agents/mcp/ktx.json:

.agents/mcp/ktx.json
{
  "mcpServers": {
    "ktx": {
      "command": "ktx",
      "args": [
        "--project-dir", "/path/to/ktx-project",
        "serve",
        "--mcp", "stdio",
        "--semantic-compute",
        "--execute-queries"
      ],
      "env": {}
    }
  }
}

Manual CLI skills configuration

Create .agents/skills/ktx/SKILL.md with the same content structure as Claude Code's SKILL.md.

Workflow tips

  • Set CODEX_HOME environment variable to customize the global installation directory
  • Codex shares the .agents/ directory structure with the universal format — one install covers both
  • Global installation makes KTX available across all Codex sessions

OpenCode

Install via ktx setup

During setup, select OpenCode from the agent targets. KTX writes:

ModeFile
CLI commands.opencode/commands/ktx.md
MCP server.opencode/mcp.json (under mcpServers.ktx)

OpenCode supports project-scoped installation only.

Manual MCP configuration

Create or edit .opencode/mcp.json:

.opencode/mcp.json
{
  "mcpServers": {
    "ktx": {
      "command": "ktx",
      "args": [
        "--project-dir", "/path/to/ktx-project",
        "serve",
        "--mcp", "stdio",
        "--semantic-compute",
        "--execute-queries"
      ],
      "env": {}
    }
  }
}

Manual CLI commands configuration

Create .opencode/commands/ktx.md with the same command definitions as Claude Code's SKILL.md.

Workflow tips

  • OpenCode reads commands from .opencode/commands/ on startup
  • Project-scoped only — no global installation option
  • Commands file uses standard markdown format (.md extension)

MCP server reference

All agent clients connect to the same KTX MCP server. The server exposes these tools:

ToolDescription
connection_listList configured database connections
connection_testTest a database connection
knowledge_searchSemantic + full-text search across knowledge pages
knowledge_readRead a specific knowledge page
knowledge_writeWrite or update a knowledge page
sl_list_sourcesList semantic layer sources
sl_read_sourceRead a semantic source definition
sl_write_sourceWrite or update a semantic source
sl_validateValidate a source against the database schema
sl_queryExecute a semantic layer query
ingest_triggerTrigger an ingestion run
ingest_statusCheck ingestion status
ingest_reportView an ingestion report
ingest_replayReplay a past ingestion session
scan_triggerTrigger a structural, enriched, or relationship scan
scan_statusCheck scan status
scan_reportView a completed scan report
scan_list_artifactsList artifacts produced by a scan
scan_read_artifactRead a scan artifact
memory_captureCapture reusable context from an agent conversation when memory capture is enabled
memory_capture_statusCheck a memory capture run

Server flags

FlagDescriptionDefault
--project-dirKTX project directory; otherwise KTX uses KTX_PROJECT_DIR, the nearest ktx.yaml, or the current directoryAuto-detected
--mcp stdioTransport mode (stdio only)Required
--semantic-computeEnable semantic layer queriesfalse
--execute-queriesAllow read-only SQL executionfalse
--semantic-compute-urlRemote compute endpoint URL
--database-introspection-urlLive schema introspection endpoint
--memory-captureRecord agent interactionsfalse
--memory-modelLLM model for memory processing

Security constraints

  • SQL execution is always read-only
  • Agent CLI SQL execution requires an explicit --max-rows limit from 1 to 1000; MCP semantic queries default to a 1000-row cap
  • Secrets and credentials are never exposed in tool responses
  • The server runs as a child process of the agent client (no network exposure)

Comparison

Claude CodeCursorCodexOpenCode
MCP supportYesYesYesYes
CLI skillsYesYes (.mdc)YesYes
Global installYesNoYesNo
Config location.mcp.json.cursor/mcp.json.agents/mcp/ktx.json.opencode/mcp.json
Skills location.claude/skills/.cursor/rules/.agents/skills/.opencode/commands/