---
title: Serving Agents
description: Expose your context to Claude Code, Cursor, Codex, and other coding agents.
---

Once you've built and refined your context, the final step is exposing it to
coding agents. KTX provides machine-readable CLI commands for direct terminal
access from Claude Code, Cursor, Codex, OpenCode, and custom agent workflows.

## CLI Commands

KTX provides a set of machine-readable commands under `ktx agent`. These return
JSON output designed for programmatic consumption.

### Available commands

```bash
# List available tools and their descriptions
ktx agent tools --json

# Get project context for planning
ktx agent context --json
```

**Semantic layer:**

```bash
# List sources
ktx agent sl list --json
ktx agent sl list --json --connection-id my-postgres

# Read a source
ktx agent sl read orders --json --connection-id my-postgres

# Run a query from a JSON file
ktx agent sl query --json \
  --connection-id my-postgres \
  --query-file query.json \
  --execute \
  --max-rows 100
```

**Knowledge:**

```bash
# Search knowledge pages
ktx agent wiki search "revenue recognition" --json --limit 10

# Read a specific page
ktx agent wiki read order-status-definitions --json
```

**SQL execution:**

```bash
# Execute read-only SQL with a row limit
ktx agent sql execute --json \
  --connection-id my-postgres \
  --sql-file query.sql \
  --max-rows 500
```

## Setting Up Your Agent

The fastest way to connect an agent is through the setup wizard:

```bash
ktx setup
```

The agents step auto-detects installed tools and generates the right
configuration. For manual setup or per-tool details, see the
[Agent Clients](/docs/integrations/agent-clients) integration page.

After configuration, the agent can immediately call KTX commands to list
sources, search knowledge, and query your semantic layer.
