mtv-agent 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. mtv_agent-0.1.0/.gitignore +29 -0
  2. mtv_agent-0.1.0/.python-version +1 -0
  3. mtv_agent-0.1.0/Makefile +69 -0
  4. mtv_agent-0.1.0/PKG-INFO +16 -0
  5. mtv_agent-0.1.0/README.md +232 -0
  6. mtv_agent-0.1.0/config.json.example +43 -0
  7. mtv_agent-0.1.0/docs/development.md +147 -0
  8. mtv_agent-0.1.0/docs/installation.md +83 -0
  9. mtv_agent-0.1.0/docs/llm-backends.md +186 -0
  10. mtv_agent-0.1.0/docs/quickstart.md +159 -0
  11. mtv_agent-0.1.0/mtv_agent/__init__.py +3 -0
  12. mtv_agent-0.1.0/mtv_agent/__main__.py +5 -0
  13. mtv_agent-0.1.0/mtv_agent/agent.py +294 -0
  14. mtv_agent-0.1.0/mtv_agent/cli.py +161 -0
  15. mtv_agent-0.1.0/mtv_agent/config.py +224 -0
  16. mtv_agent-0.1.0/mtv_agent/data/config.json.example +43 -0
  17. mtv_agent-0.1.0/mtv_agent/data/playbooks/browse-source-vms.md +111 -0
  18. mtv_agent-0.1.0/mtv_agent/data/playbooks/check-cluster-health.md +154 -0
  19. mtv_agent-0.1.0/mtv_agent/data/playbooks/check-mtv-health.md +104 -0
  20. mtv_agent-0.1.0/mtv_agent/data/playbooks/configure-vddk-image.md +91 -0
  21. mtv_agent-0.1.0/mtv_agent/data/playbooks/create-migration-target.md +77 -0
  22. mtv_agent-0.1.0/mtv_agent/data/playbooks/create-vsphere-provider.md +117 -0
  23. mtv_agent-0.1.0/mtv_agent/data/playbooks/migration-status-report.md +142 -0
  24. mtv_agent-0.1.0/mtv_agent/data/playbooks/monitor-migration-plan.md +160 -0
  25. mtv_agent-0.1.0/mtv_agent/data/playbooks/show-migration-network-traffic.md +138 -0
  26. mtv_agent-0.1.0/mtv_agent/data/playbooks/troubleshoot-migration.md +199 -0
  27. mtv_agent-0.1.0/mtv_agent/data/skills/mtv-cli-docs/SKILL.md +119 -0
  28. mtv_agent-0.1.0/mtv_agent/data/skills/mtv-docs/SKILL.md +286 -0
  29. mtv_agent-0.1.0/mtv_agent/data/skills/observe-metrics/SKILL.md +257 -0
  30. mtv_agent-0.1.0/mtv_agent/data/skills/observe-metrics-reference/SKILL.md +451 -0
  31. mtv_agent-0.1.0/mtv_agent/lib/__init__.py +0 -0
  32. mtv_agent-0.1.0/mtv_agent/lib/bash_tool.py +65 -0
  33. mtv_agent-0.1.0/mtv_agent/lib/chat_store.py +121 -0
  34. mtv_agent-0.1.0/mtv_agent/lib/llm.py +70 -0
  35. mtv_agent-0.1.0/mtv_agent/lib/mcp_client.py +194 -0
  36. mtv_agent-0.1.0/mtv_agent/lib/mcp_manager.py +133 -0
  37. mtv_agent-0.1.0/mtv_agent/lib/memory.py +60 -0
  38. mtv_agent-0.1.0/mtv_agent/lib/playbooks.py +58 -0
  39. mtv_agent-0.1.0/mtv_agent/lib/skills.py +82 -0
  40. mtv_agent-0.1.0/mtv_agent/lib/system_prompt.py +70 -0
  41. mtv_agent-0.1.0/mtv_agent/lib/text_utils.py +56 -0
  42. mtv_agent-0.1.0/mtv_agent/lib/tool_registry.py +60 -0
  43. mtv_agent-0.1.0/mtv_agent/lib/virtual_tools.py +78 -0
  44. mtv_agent-0.1.0/mtv_agent/main.py +496 -0
  45. mtv_agent-0.1.0/mtv_agent/orchestrator.py +432 -0
  46. mtv_agent-0.1.0/playbooks/browse-source-vms.md +111 -0
  47. mtv_agent-0.1.0/playbooks/check-cluster-health.md +154 -0
  48. mtv_agent-0.1.0/playbooks/check-mtv-health.md +104 -0
  49. mtv_agent-0.1.0/playbooks/configure-vddk-image.md +91 -0
  50. mtv_agent-0.1.0/playbooks/create-migration-target.md +77 -0
  51. mtv_agent-0.1.0/playbooks/create-vsphere-provider.md +117 -0
  52. mtv_agent-0.1.0/playbooks/migration-status-report.md +142 -0
  53. mtv_agent-0.1.0/playbooks/monitor-migration-plan.md +160 -0
  54. mtv_agent-0.1.0/playbooks/show-migration-network-traffic.md +138 -0
  55. mtv_agent-0.1.0/playbooks/troubleshoot-migration.md +199 -0
  56. mtv_agent-0.1.0/pyproject.toml +29 -0
  57. mtv_agent-0.1.0/scripts/run.sh +148 -0
  58. mtv_agent-0.1.0/skills/mtv-cli-docs/SKILL.md +119 -0
  59. mtv_agent-0.1.0/skills/mtv-docs/SKILL.md +286 -0
  60. mtv_agent-0.1.0/skills/observe-metrics/SKILL.md +257 -0
  61. mtv_agent-0.1.0/skills/observe-metrics-reference/SKILL.md +451 -0
  62. mtv_agent-0.1.0/uv.lock +1188 -0
  63. mtv_agent-0.1.0/web/.prettierrc +4 -0
  64. mtv_agent-0.1.0/web/README.md +185 -0
  65. mtv_agent-0.1.0/web/eslint.config.js +18 -0
  66. mtv_agent-0.1.0/web/index.html +16 -0
  67. mtv_agent-0.1.0/web/package-lock.json +2383 -0
  68. mtv_agent-0.1.0/web/package.json +33 -0
  69. mtv_agent-0.1.0/web/src/components/agent-app.ts +327 -0
  70. mtv_agent-0.1.0/web/src/components/agent-chat.ts +351 -0
  71. mtv_agent-0.1.0/web/src/components/agent-sidebar.ts +496 -0
  72. mtv_agent-0.1.0/web/src/components/card-search-bar.ts +160 -0
  73. mtv_agent-0.1.0/web/src/components/chart-card.ts +447 -0
  74. mtv_agent-0.1.0/web/src/components/chat-composer.ts +266 -0
  75. mtv_agent-0.1.0/web/src/components/chat-message.ts +208 -0
  76. mtv_agent-0.1.0/web/src/components/context-editor.ts +205 -0
  77. mtv_agent-0.1.0/web/src/components/detail-pane.ts +828 -0
  78. mtv_agent-0.1.0/web/src/components/markdown-renderer.ts +248 -0
  79. mtv_agent-0.1.0/web/src/components/mcp-manager.ts +86 -0
  80. mtv_agent-0.1.0/web/src/components/model-selector.ts +84 -0
  81. mtv_agent-0.1.0/web/src/components/resize-handle.ts +94 -0
  82. mtv_agent-0.1.0/web/src/components/skill-selector.ts +55 -0
  83. mtv_agent-0.1.0/web/src/components/text-renderer.ts +33 -0
  84. mtv_agent-0.1.0/web/src/components/theme-picker.ts +216 -0
  85. mtv_agent-0.1.0/web/src/components/thinking-indicator.ts +65 -0
  86. mtv_agent-0.1.0/web/src/components/tool-call-card.ts +536 -0
  87. mtv_agent-0.1.0/web/src/components/tool-policy-editor.ts +236 -0
  88. mtv_agent-0.1.0/web/src/components/top-bar.ts +131 -0
  89. mtv_agent-0.1.0/web/src/index.ts +20 -0
  90. mtv_agent-0.1.0/web/src/services/api-client.ts +176 -0
  91. mtv_agent-0.1.0/web/src/services/chat-utils.ts +108 -0
  92. mtv_agent-0.1.0/web/src/services/stream-client.ts +148 -0
  93. mtv_agent-0.1.0/web/src/services/stream-handler.ts +192 -0
  94. mtv_agent-0.1.0/web/src/state/app-state.ts +324 -0
  95. mtv_agent-0.1.0/web/src/styles/reset.css +76 -0
  96. mtv_agent-0.1.0/web/src/styles/shared.ts +63 -0
  97. mtv_agent-0.1.0/web/src/styles/themes.ts +280 -0
  98. mtv_agent-0.1.0/web/src/utils/highlight-utils.ts +125 -0
  99. mtv_agent-0.1.0/web/src/utils/table/detectors/detect-fixed-width.ts +17 -0
  100. mtv_agent-0.1.0/web/src/utils/table/detectors/detect-json.ts +9 -0
  101. mtv_agent-0.1.0/web/src/utils/table/detectors/detect-markdown.ts +15 -0
  102. mtv_agent-0.1.0/web/src/utils/table/detectors/index.ts +17 -0
  103. mtv_agent-0.1.0/web/src/utils/table/index.ts +18 -0
  104. mtv_agent-0.1.0/web/src/utils/table/normalize.ts +29 -0
  105. mtv_agent-0.1.0/web/src/utils/table/parsers/index.ts +13 -0
  106. mtv_agent-0.1.0/web/src/utils/table/parsers/parse-fixed-width.ts +39 -0
  107. mtv_agent-0.1.0/web/src/utils/table/parsers/parse-json.ts +61 -0
  108. mtv_agent-0.1.0/web/src/utils/table/parsers/parse-markdown.ts +54 -0
  109. mtv_agent-0.1.0/web/src/utils/table/pipeline.ts +16 -0
  110. mtv_agent-0.1.0/web/src/utils/table/render.ts +8 -0
  111. mtv_agent-0.1.0/web/src/utils/table/types.ts +9 -0
  112. mtv_agent-0.1.0/web/src/utils/timeseries/extract.ts +60 -0
  113. mtv_agent-0.1.0/web/src/utils/timeseries/index.ts +3 -0
  114. mtv_agent-0.1.0/web/src/utils/timeseries/parser.ts +25 -0
  115. mtv_agent-0.1.0/web/src/utils/timeseries/types.ts +8 -0
  116. mtv_agent-0.1.0/web/src/utils/tool-registry/card-id.ts +20 -0
  117. mtv_agent-0.1.0/web/src/utils/tool-registry/handlers/debug-help.ts +18 -0
  118. mtv_agent-0.1.0/web/src/utils/tool-registry/handlers/debug-read.ts +69 -0
  119. mtv_agent-0.1.0/web/src/utils/tool-registry/handlers/index.ts +18 -0
  120. mtv_agent-0.1.0/web/src/utils/tool-registry/handlers/metrics-help.ts +18 -0
  121. mtv_agent-0.1.0/web/src/utils/tool-registry/handlers/metrics-read.ts +56 -0
  122. mtv_agent-0.1.0/web/src/utils/tool-registry/handlers/mtv-help.ts +18 -0
  123. mtv_agent-0.1.0/web/src/utils/tool-registry/handlers/mtv-read.ts +92 -0
  124. mtv_agent-0.1.0/web/src/utils/tool-registry/handlers/mtv-write.ts +18 -0
  125. mtv_agent-0.1.0/web/src/utils/tool-registry/index.ts +15 -0
  126. mtv_agent-0.1.0/web/src/utils/tool-registry/parsers/index.ts +5 -0
  127. mtv_agent-0.1.0/web/src/utils/tool-registry/parsers/log-parser.ts +9 -0
  128. mtv_agent-0.1.0/web/src/utils/tool-registry/parsers/markdown-parser.ts +7 -0
  129. mtv_agent-0.1.0/web/src/utils/tool-registry/parsers/raw-parser.ts +8 -0
  130. mtv_agent-0.1.0/web/src/utils/tool-registry/parsers/table-parser.ts +11 -0
  131. mtv_agent-0.1.0/web/src/utils/tool-registry/parsers/timeseries-parser.ts +10 -0
  132. mtv_agent-0.1.0/web/src/utils/tool-registry/registry.ts +135 -0
  133. mtv_agent-0.1.0/web/src/utils/tool-registry/types.ts +77 -0
  134. mtv_agent-0.1.0/web/src/utils/tool-registry/unwrap.ts +45 -0
  135. mtv_agent-0.1.0/web/tsconfig.json +20 -0
  136. mtv_agent-0.1.0/web/vite.config.ts +25 -0
@@ -0,0 +1,29 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # VSCode files
10
+ .vscode/
11
+
12
+ # Virtual environments
13
+ .venv
14
+
15
+ # Ruff cache
16
+ .ruff_cache/
17
+
18
+ # Config (may contain API keys or tokens)
19
+ config.json
20
+
21
+ # Web UI
22
+ web/node_modules/
23
+ web/dist/
24
+ web/bun.lock
25
+
26
+ # Bundled web dist (build artifact for pip package)
27
+ mtv_agent/web_dist/
28
+
29
+ .cache/
@@ -0,0 +1 @@
1
+ 3.14
@@ -0,0 +1,69 @@
1
+ .DEFAULT_GOAL := help
2
+ .PHONY: run run-cop dev serve build-web dev-web stop format format-web lint lint-web package help
3
+
4
+ ## Run the full stack via scripts/run.sh (dev)
5
+ run:
6
+ @scripts/run.sh
7
+
8
+ ## Run with COP via scripts/run.sh (dev)
9
+ run-cop:
10
+ @scripts/run.sh --with-cop
11
+
12
+ ## Run API server with --no-web for frontend dev
13
+ dev:
14
+ @NO_WEB=1 scripts/run.sh
15
+
16
+ ## Start only the API server (pip-installed entrypoint)
17
+ serve:
18
+ CONFIG=./config.json uv run python -m mtv_agent serve
19
+
20
+ ## Build the web UI into web/dist
21
+ build-web:
22
+ cd web && npm ci && npm run build
23
+
24
+ ## Start the Vite dev server for the web UI
25
+ dev-web:
26
+ cd web && npm run dev
27
+
28
+ ## Stop all MCP containers and proxy
29
+ stop:
30
+ @echo "Stopping MCP containers..."
31
+ @docker stop mtv-agent-mcp-mtv 2>/dev/null || podman stop mtv-agent-mcp-mtv 2>/dev/null || true
32
+ @docker stop mtv-agent-mcp-metrics 2>/dev/null || podman stop mtv-agent-mcp-metrics 2>/dev/null || true
33
+ @docker stop mtv-agent-mcp-debug-queries 2>/dev/null || podman stop mtv-agent-mcp-debug-queries 2>/dev/null || true
34
+ @echo "Stopping claude-openai-proxy (if running)..."
35
+ @pkill -f 'claude_openai_proxy' 2>/dev/null || true
36
+ @echo "Done."
37
+
38
+ ## Format Python code with ruff
39
+ format:
40
+ uv run ruff format .
41
+ uv run ruff check --fix .
42
+
43
+ ## Format web code with prettier
44
+ format-web:
45
+ cd web && npm run format
46
+
47
+ ## Lint Python code with ruff
48
+ lint:
49
+ uv run ruff check .
50
+ uv run ruff format --check .
51
+
52
+ ## Lint web code with eslint and prettier
53
+ lint-web:
54
+ cd web && npm run lint && npm run format:check
55
+
56
+ ## Build pip-distributable package (includes web UI)
57
+ package: build-web
58
+ rm -rf mtv_agent/web_dist
59
+ cp -r web/dist mtv_agent/web_dist
60
+ rm -rf mtv_agent/data/skills mtv_agent/data/playbooks
61
+ cp -r skills mtv_agent/data/skills
62
+ cp -r playbooks mtv_agent/data/playbooks
63
+ uv build
64
+
65
+ ## Show this help
66
+ help:
67
+ @grep -B1 -E '^[a-zA-Z_-]+:' $(MAKEFILE_LIST) \
68
+ | grep -v '^\-\-$$' \
69
+ | awk '/^##/ {desc=substr($$0,4)} /^[a-zA-Z_-]+:/ {printf " \033[36m%-15s\033[0m %s\n", $$1, desc; desc=""}'
@@ -0,0 +1,16 @@
1
+ Metadata-Version: 2.4
2
+ Name: mtv-agent
3
+ Version: 0.1.0
4
+ Summary: AI agent for MTV/Forklift VM migrations
5
+ Requires-Python: >=3.11
6
+ Requires-Dist: claude-openai-proxy
7
+ Requires-Dist: fastapi
8
+ Requires-Dist: httpx
9
+ Requires-Dist: mcp
10
+ Requires-Dist: openai
11
+ Requires-Dist: pydantic-settings
12
+ Requires-Dist: pyyaml
13
+ Requires-Dist: sse-starlette
14
+ Requires-Dist: uvicorn
15
+ Provides-Extra: dev
16
+ Requires-Dist: ruff; extra == 'dev'
@@ -0,0 +1,232 @@
1
+ # mtv-agent
2
+
3
+ AI agent for [MTV/Forklift](https://github.com/kubev2v/forklift) VM migrations,
4
+ with a tool loop, MCP tool integration, and markdown-based skills and playbooks.
5
+
6
+ ## Quick start
7
+
8
+ ```bash
9
+ pip install mtv-agent
10
+ mtv-agent init
11
+ ```
12
+
13
+ Then set your cluster credentials and start the agent:
14
+
15
+ ```bash
16
+ export KUBE_API_URL=https://api.cluster.example.com:6443
17
+ export KUBE_TOKEN=$(oc whoami -t)
18
+
19
+ mtv-agent start # with LM Studio (default)
20
+ mtv-agent start --with-cop # with Claude
21
+ ```
22
+
23
+ Open `http://localhost:8000` in your browser.
24
+
25
+ For the full walkthrough, see:
26
+
27
+ - [docs/installation.md](docs/installation.md) -- prerequisites, install,
28
+ and workspace setup
29
+ - [docs/quickstart.md](docs/quickstart.md) -- step-by-step guide from zero
30
+ to running agent
31
+ - [docs/llm-backends.md](docs/llm-backends.md) -- LM Studio and Claude setup
32
+ - [docs/development.md](docs/development.md) -- contributor setup, dev
33
+ workflows, and project structure
34
+ - [web/README.md](web/README.md) -- web UI architecture, components, and
35
+ frontend development
36
+
37
+ ## CLI reference
38
+
39
+ ```
40
+ mtv-agent init [--dir DIR] [--force]
41
+ mtv-agent start [--with-cop] [--runtime docker|podman] [--host HOST] [--port PORT] [--config PATH] [--no-web]
42
+ mtv-agent serve [--host HOST] [--port PORT] [--config PATH] [--no-web]
43
+ mtv-agent stop
44
+ mtv-agent config
45
+ ```
46
+
47
+ | Command | Description |
48
+ |---|---|
49
+ | `init` | Create a workspace at `~/.mtv-agent/` with config, skills, and playbooks |
50
+ | `start` | Start MCP containers, optional LLM proxy, and the API server. `--no-web` disables static UI serving |
51
+ | `serve` | Start only the API server (MCP/LLM must be running separately). `--no-web` disables static UI serving |
52
+ | `stop` | Stop MCP containers and claude-openai-proxy |
53
+ | `config` | Print default config.json to stdout |
54
+
55
+ ## Configuration
56
+
57
+ All settings live in a single `config.json` file. After running `mtv-agent init`,
58
+ your config is at `~/.mtv-agent/config.json`. The agent searches for a config in this
59
+ order: `CONFIG` env var, then `./config.json`, then `~/.mtv-agent/config.json`.
60
+
61
+ To print the default config (useful for piping or inspection):
62
+
63
+ ```bash
64
+ mtv-agent config
65
+ ```
66
+
67
+ ```json
68
+ {
69
+ "llm": {
70
+ "baseUrl": "http://localhost:1234/v1",
71
+ "apiKey": "lm-studio",
72
+ "model": null
73
+ },
74
+ "server": {
75
+ "host": "0.0.0.0",
76
+ "port": 8000
77
+ },
78
+ "mcpServers": {
79
+ "kubectl-mtv": { "url": "http://localhost:8080/sse" },
80
+ "kubectl-metrics": { "url": "http://localhost:8081/sse" },
81
+ "kubectl-debug-queries": { "url": "http://localhost:8082/sse" }
82
+ },
83
+ "skills": { "dir": "./skills", "maxActive": 3 },
84
+ "playbooks": { "dir": "./playbooks" },
85
+ "memory": { "maxTurns": 20, "ttlSeconds": 3600, "toolResultLimit": 4000 },
86
+ "agent": {
87
+ "contextWindow": 30000,
88
+ "maxIterations": 20,
89
+ "maxRetries": 2,
90
+ "retryDelay": 2.0
91
+ }
92
+ }
93
+ ```
94
+
95
+ Every value can be overridden by an environment variable (no prefix needed):
96
+
97
+ | Variable | Config key | Default | Description |
98
+ |---|---|---|---|
99
+ | `LLM_BASE_URL` | `llm.baseUrl` | `http://localhost:1234/v1` | OpenAI-compatible endpoint |
100
+ | `LLM_API_KEY` | `llm.apiKey` | `lm-studio` | API key for the LLM server |
101
+ | `LLM_MODEL` | `llm.model` | auto-discovered | Model name (queries `/v1/models` if unset) |
102
+ | `SERVER_HOST` | `server.host` | `0.0.0.0` | API server bind address |
103
+ | `SERVER_PORT` | `server.port` | `8000` | API server port |
104
+ | `SKILLS_DIR` | `skills.dir` | bundled skills | Directory containing skill definitions |
105
+ | `PLAYBOOKS_DIR` | `playbooks.dir` | bundled playbooks | Directory containing playbooks |
106
+ | `MAX_ACTIVE_SKILLS` | `skills.maxActive` | `3` | Maximum skills active at once |
107
+ | `MEMORY_MAX_TURNS` | `memory.maxTurns` | `20` | Conversation turns kept per session |
108
+ | `MEMORY_TTL_SECONDS` | `memory.ttlSeconds` | `3600` | Seconds before a session is evicted |
109
+ | `CONTEXT_WINDOW` | `agent.contextWindow` | `30000` | Default context window (overridden if auto-detected) |
110
+ | `MAX_ITERATIONS` | `agent.maxIterations` | `20` | Maximum tool-loop iterations |
111
+ | `MAX_RETRIES` | `agent.maxRetries` | `2` | LLM request retries on failure |
112
+ | `RETRY_DELAY` | `agent.retryDelay` | `2.0` | Seconds between LLM retries |
113
+
114
+ ## Architecture
115
+
116
+ `mtv-agent start` manages five components:
117
+
118
+ | Component | Port | Description |
119
+ |---|---|---|
120
+ | API server | 8000 | FastAPI app serving the chat API and web UI |
121
+ | kubectl-mtv MCP | 8080 | MTV/Forklift resource queries and mutations |
122
+ | kubectl-metrics MCP | 8081 | Prometheus/Thanos metric queries |
123
+ | kubectl-debug-queries MCP | 8082 | Kubernetes resources, logs, and events |
124
+ | claude-openai-proxy | 1234 | Claude-to-OpenAI adapter (only with `--with-cop`) |
125
+
126
+ The MCP containers are managed automatically. If you run them yourself,
127
+ configure their URLs in `config.json` under `mcpServers`.
128
+
129
+ ## Skills and playbooks
130
+
131
+ `mtv-agent init` copies the default skills and playbooks into `~/.mtv-agent/` so
132
+ you can edit or extend them.
133
+
134
+ **Skills** are markdown reference guides the agent loads on demand. Each skill
135
+ lives in `~/.mtv-agent/skills/<name>/SKILL.md` with YAML frontmatter (`name`,
136
+ `description`) and instruction body.
137
+
138
+ **Playbooks** are task-oriented markdown files exposed in the web UI. They
139
+ live in `~/.mtv-agent/playbooks/`. Override the directory with `SKILLS_DIR` or
140
+ `PLAYBOOKS_DIR`.
141
+
142
+ ## API
143
+
144
+ All API endpoints are served under the `/api` prefix.
145
+
146
+ ### `POST /api/chat`
147
+
148
+ Non-streaming. Returns the complete answer as JSON.
149
+
150
+ ```bash
151
+ curl -X POST http://localhost:8000/api/chat \
152
+ -H "Content-Type: application/json" \
153
+ -d '{"message": "hello"}'
154
+ ```
155
+
156
+ Request body:
157
+
158
+ | Field | Type | Description |
159
+ |---|---|---|
160
+ | `message` | string | The user message (required) |
161
+ | `session_id` | string | Session ID for conversation history (auto-generated if omitted) |
162
+ | `skills` | string[] | Skill names to activate |
163
+ | `context` | object | Key-value context pairs (e.g. `{"namespace": "default"}`) |
164
+
165
+ ### `POST /api/chat/stream`
166
+
167
+ Streaming. Emits SSE events as the agent works. Add `?approve=true` to require
168
+ manual approval before each tool execution.
169
+
170
+ SSE event types:
171
+
172
+ | Event | Description |
173
+ |---|---|
174
+ | `session` | `{"session_id": "..."}` |
175
+ | `thinking` | Agent is waiting for the LLM |
176
+ | `usage` | Token usage: `total_tokens`, `prompt_tokens`, `completion_tokens`, `context_window` |
177
+ | `tool_call` | Tool about to run: `name`, `arguments` |
178
+ | `tool_result` | Tool finished: `name`, `result` |
179
+ | `tool_denied` | Tool denied by user: `name`, `reason` |
180
+ | `skill_selected` | Skill activated: `name` |
181
+ | `skill_cleared` | All skills deactivated |
182
+ | `context_set` | Context updated: `key`, `value` |
183
+ | `context_unset` | Context key removed: `key` |
184
+ | `content` | Final assistant response text |
185
+ | `done` | Stream complete, includes final `content` |
186
+
187
+ ### `POST /api/chat/{session_id}/approve`
188
+
189
+ Push an approval decision for a pending tool call (used with `?approve=true`).
190
+
191
+ ```json
192
+ {"approved": true}
193
+ ```
194
+
195
+ Or deny with an optional reason:
196
+
197
+ ```json
198
+ {"approved": false, "reason": "too dangerous"}
199
+ ```
200
+
201
+ ### `GET /api/status`
202
+
203
+ Returns model, MCP servers, tool count, context window, and max active skills.
204
+
205
+ ### `GET /api/models`
206
+
207
+ Lists models available on the LLM server.
208
+
209
+ ### `PUT /api/model`
210
+
211
+ Hot-swap the active model: `{"model": "model-name"}`.
212
+
213
+ ### `GET /api/skills`
214
+
215
+ Lists available skills with names and descriptions.
216
+
217
+ ### `GET /api/playbooks`
218
+
219
+ Lists available playbooks with metadata and body.
220
+
221
+ ### `GET /api/mcp`
222
+
223
+ Lists all configured MCP servers with their connection status.
224
+
225
+ ### `POST /api/mcp/{name}` / `DELETE /api/mcp/{name}`
226
+
227
+ Connect or disconnect an MCP server by name.
228
+
229
+ ## Development
230
+
231
+ See [docs/development.md](docs/development.md) for contributor setup,
232
+ dev workflows, make targets, and project structure.
@@ -0,0 +1,43 @@
1
+ {
2
+ "llm": {
3
+ "baseUrl": "http://localhost:1234/v1",
4
+ "apiKey": "lm-studio",
5
+ "model": null
6
+ },
7
+ "server": {
8
+ "host": "0.0.0.0",
9
+ "port": 8000
10
+ },
11
+ "mcpServers": {
12
+ "kubectl-mtv": {
13
+ "url": "http://localhost:8080/sse"
14
+ },
15
+ "kubectl-metrics": {
16
+ "url": "http://localhost:8081/sse"
17
+ },
18
+ "kubectl-debug-queries": {
19
+ "url": "http://localhost:8082/sse"
20
+ }
21
+ },
22
+ "skills": {
23
+ "dir": "./skills",
24
+ "maxActive": 3
25
+ },
26
+ "playbooks": {
27
+ "dir": "./playbooks"
28
+ },
29
+ "memory": {
30
+ "maxTurns": 20,
31
+ "ttlSeconds": 3600,
32
+ "toolResultLimit": 4000
33
+ },
34
+ "agent": {
35
+ "contextWindow": 30000,
36
+ "maxIterations": 20,
37
+ "maxRetries": 2,
38
+ "retryDelay": 2.0
39
+ },
40
+ "cache": {
41
+ "dir": ".cache/mtv-agent"
42
+ }
43
+ }
@@ -0,0 +1,147 @@
1
+ # Development
2
+
3
+ This guide is for contributors working from a git checkout of the
4
+ [mtv-agent](https://github.com/kubev2v/mtv-agent) repository.
5
+
6
+ ## Setup from source
7
+
8
+ ```bash
9
+ git clone https://github.com/kubev2v/mtv-agent.git
10
+ cd mtv-agent
11
+ uv sync --extra dev
12
+ ```
13
+
14
+ This creates a `.venv/`, installs all dependencies, and sets up the package
15
+ in editable mode. To activate the venv in your shell (optional -- `uv run`
16
+ handles this automatically):
17
+
18
+ ```bash
19
+ source .venv/bin/activate
20
+ ```
21
+
22
+ For the web UI you also need Node.js (v18+):
23
+
24
+ ```bash
25
+ cd web && npm ci && cd ..
26
+ ```
27
+
28
+ ## Running in dev mode
29
+
30
+ Set your cluster credentials once per shell session:
31
+
32
+ ```bash
33
+ export KUBE_API_URL=https://api.cluster.example.com:6443
34
+ export KUBE_TOKEN=$(oc whoami -t)
35
+ ```
36
+
37
+ Then use the Make targets:
38
+
39
+ ```bash
40
+ make run # MCP containers + API server (uses local LLM)
41
+ make run-cop # same, but also starts claude-openai-proxy
42
+ make build-web # build the web UI into web/dist/ (served automatically)
43
+ make stop # stop MCP containers and claude-openai-proxy
44
+ ```
45
+
46
+ The API server auto-detects `web/dist/` and serves it at
47
+ `http://localhost:8000`. If you haven't built the web UI yet, the API
48
+ still works -- you just won't see the browser interface.
49
+
50
+ ## Frontend development
51
+
52
+ For frontend work you want the Vite dev server (with hot-module reload)
53
+ alongside the API server. Run them in two terminals:
54
+
55
+ ```bash
56
+ # Terminal 1 -- API server without static file serving
57
+ make dev
58
+
59
+ # Terminal 2 -- Vite dev server on port 5173
60
+ make dev-web
61
+ ```
62
+
63
+ `make dev` sets `NO_WEB=1` so the API server does not serve static files,
64
+ avoiding conflicts with Vite. The Vite dev server proxies `/api` requests
65
+ to the API server on port 8000 automatically.
66
+
67
+ ## Make targets reference
68
+
69
+ | Target | Description |
70
+ |---|---|
71
+ | `make run` | Start MCP containers + API server via `scripts/run.sh` |
72
+ | `make run-cop` | Same as `run` but also starts claude-openai-proxy |
73
+ | `make dev` | Start MCP containers + API server with `--no-web` (for frontend dev) |
74
+ | `make serve` | Start only the API server (no containers) |
75
+ | `make build-web` | Build the web UI into `web/dist/` |
76
+ | `make dev-web` | Start the Vite dev server for the web UI |
77
+ | `make stop` | Stop MCP containers and claude-openai-proxy |
78
+ | `make format` | Auto-format Python code with ruff |
79
+ | `make format-web` | Auto-format web code with prettier |
80
+ | `make lint` | Lint Python code with ruff |
81
+ | `make lint-web` | Lint web code with eslint + prettier |
82
+ | `make package` | Build the pip-distributable wheel (includes web UI) |
83
+ | `make help` | Show all targets |
84
+
85
+ ## Linting and formatting
86
+
87
+ ```bash
88
+ make lint # ruff check + format check
89
+ make format # ruff auto-fix + format
90
+
91
+ make lint-web # eslint + prettier check
92
+ make format-web # prettier auto-fix
93
+ ```
94
+
95
+ ## Building the pip package
96
+
97
+ ```bash
98
+ make package
99
+ ```
100
+
101
+ This runs `make build-web` first, copies `web/dist/` into `mtv_agent/web_dist/`,
102
+ then runs `python -m build` to produce a distributable wheel in `dist/`.
103
+
104
+ ## Project structure
105
+
106
+ ```
107
+ mtv-agent/
108
+ ├── mtv_agent/ # Python package (pip-installable)
109
+ │ ├── __init__.py # Version
110
+ │ ├── __main__.py # python -m mtv_agent
111
+ │ ├── cli.py # CLI entry point (mtv-agent command)
112
+ │ ├── orchestrator.py # Container + process lifecycle management
113
+ │ ├── main.py # FastAPI app, /api endpoints, static serving
114
+ │ ├── agent.py # The tool loop (LLM -> tools -> results -> LLM)
115
+ │ ├── config.py # Settings (config.json + env-var overrides)
116
+ │ ├── lib/ # Internal libraries
117
+ │ │ ├── bash_tool.py # Built-in bash tool for shell commands
118
+ │ │ ├── chat_store.py # Persistent chat storage (JSON files)
119
+ │ │ ├── llm.py # OpenAI-compatible LLM client
120
+ │ │ ├── mcp_client.py # MCP SSE client
121
+ │ │ ├── mcp_manager.py # Multi-MCP server manager
122
+ │ │ ├── memory.py # In-memory conversation history
123
+ │ │ ├── playbooks.py # Playbook markdown loader
124
+ │ │ ├── skills.py # Skill markdown loader
125
+ │ │ ├── system_prompt.py # System prompt builder
126
+ │ │ ├── text_utils.py # Truncation, frontmatter parsing
127
+ │ │ ├── tool_registry.py # Unified registry (bash + MCP tools)
128
+ │ │ └── virtual_tools.py # select_skill, set_context tools
129
+ │ └── data/ # Bundled data (included in pip package)
130
+ │ ├── config.json.example
131
+ │ ├── skills/
132
+ │ └── playbooks/
133
+ ├── web/ # Web UI source (Lit + TypeScript, not packaged)
134
+ │ ├── src/
135
+ │ ├── dist/ # Built assets (served by Python server)
136
+ │ └── package.json
137
+ ├── docs/ # Documentation
138
+ │ ├── installation.md # Prerequisites, install, workspace setup
139
+ │ ├── quickstart.md # Zero-to-running walkthrough
140
+ │ ├── llm-backends.md # LM Studio and Claude setup guide
141
+ │ └── development.md # This file
142
+ ├── skills/ # Dev skills (used by make run)
143
+ ├── playbooks/ # Dev playbooks (used by make run)
144
+ ├── scripts/run.sh # Dev launcher script
145
+ ├── Makefile # Dev and build targets
146
+ └── pyproject.toml # Package metadata and dependencies
147
+ ```
@@ -0,0 +1,83 @@
1
+ # Installation
2
+
3
+ ## Prerequisites
4
+
5
+ - **Python 3.11+**
6
+ - **[uv](https://docs.astral.sh/uv/)** -- fast Python package manager
7
+ (`curl -LsSf https://astral.sh/uv/install.sh | sh`)
8
+ - **Docker or Podman** -- used to run the three MCP server containers that
9
+ give the agent access to your OpenShift cluster
10
+ - **An OpenShift cluster** with [MTV/Forklift](https://github.com/kubev2v/forklift)
11
+ installed
12
+ - **An OpenAI-compatible LLM server** -- either
13
+ [LM Studio](https://lmstudio.ai) (local) or
14
+ [Claude](https://docs.anthropic.com/en/docs/claude-code) via the bundled
15
+ proxy. See [llm-backends.md](llm-backends.md) for details.
16
+
17
+ ## Install from pip
18
+
19
+ ```bash
20
+ pip install mtv-agent
21
+ ```
22
+
23
+ This installs the `mtv-agent` command along with all Python dependencies,
24
+ including `claude-openai-proxy`.
25
+
26
+ Verify the installation:
27
+
28
+ ```bash
29
+ mtv-agent --version
30
+ ```
31
+
32
+ ## Install from source
33
+
34
+ For contributors or if you want to run from a git checkout:
35
+
36
+ ```bash
37
+ git clone https://github.com/yaacov/mtv-agent.git
38
+ cd mtv-agent
39
+ uv sync --extra dev
40
+ ```
41
+
42
+ `uv sync` creates the virtual environment automatically (in `.venv/`),
43
+ installs all dependencies, and sets up the package in editable mode.
44
+ Code changes take effect immediately.
45
+
46
+ ## Initialise a workspace
47
+
48
+ After installing, run `init` to create a local workspace with the default
49
+ configuration, skills, and playbooks:
50
+
51
+ ```bash
52
+ mtv-agent init
53
+ ```
54
+
55
+ This creates `~/.mtv-agent/` with:
56
+
57
+ ```
58
+ ~/.mtv-agent/
59
+ ├── config.json # agent settings (LLM, server, MCP, memory, etc.)
60
+ ├── skills/ # markdown reference guides the agent can load on demand
61
+ └── playbooks/ # task playbooks exposed in the web UI
62
+ ```
63
+
64
+ You can edit any of these files to customise the agent's behaviour.
65
+
66
+ ### Options
67
+
68
+ Initialise into a custom directory:
69
+
70
+ ```bash
71
+ mtv-agent init --dir ./my-workspace
72
+ ```
73
+
74
+ Reset an existing workspace back to defaults:
75
+
76
+ ```bash
77
+ mtv-agent init --force
78
+ ```
79
+
80
+ ## What's next
81
+
82
+ Follow the [Quick Start](quickstart.md) guide to set up an LLM backend and
83
+ launch the agent.