@vaultgradient/pipequery-cli 0.3.2 → 0.4.0
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.
- package/README.md +88 -2
- package/dist/index.js +1009 -24
- package/package.json +10 -2
- package/src/commands/mcp.ts +87 -0
- package/src/commands/source.ts +63 -1
- package/src/config/schema.ts +108 -1
- package/src/docker/templates.ts +1 -1
- package/src/index.ts +37 -6
- package/src/mcp/http.ts +191 -0
- package/src/mcp/provider.ts +223 -0
- package/src/mcp/server.ts +138 -0
- package/src/mcp/stdio.ts +26 -0
- package/src/server/sources/kafka.ts +166 -0
- package/src/server/sources/manager.ts +12 -0
- package/src/server/sources/mysql.ts +128 -0
- package/src/server/sources/postgres.ts +139 -0
- package/src/server/sources/sqlite.ts +114 -0
package/README.md
CHANGED
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
A command-line tool for building data pipelines, REST APIs, and terminal dashboards using PipeQuery expressions.
|
|
4
4
|
|
|
5
|
-
Connect to any data source (REST APIs, WebSockets, files), run pipe-based queries to transform and aggregate data, then expose results as API endpoints or visualize them as rich terminal charts.
|
|
5
|
+
Connect to any data source (REST APIs, WebSockets, files, Postgres, MySQL, SQLite, Kafka), run pipe-based queries to transform and aggregate data, then expose results as API endpoints or visualize them as rich terminal charts.
|
|
6
6
|
|
|
7
7
|
**Create API endpoints on the fly** — run `pq endpoint add /api/prices -q "crypto | sort(price desc)"` and instantly get a live JSON endpoint, no config file needed.
|
|
8
8
|
|
|
9
|
+
**Give your AI agent live data** — `pq mcp serve` exposes every configured source to any Model Context Protocol client (Claude Desktop, Claude Code, Cursor, Copilot). Your AI can now query your REST APIs, files, Postgres / MySQL / SQLite databases, Kafka streams, and WebSocket feeds directly.
|
|
10
|
+
|
|
9
11
|
## Installation
|
|
10
12
|
|
|
11
13
|
```bash
|
|
12
|
-
npm install -g @
|
|
14
|
+
npm install -g @vaultgradient/pipequery-cli
|
|
13
15
|
```
|
|
14
16
|
|
|
15
17
|
Or install from source:
|
|
@@ -80,6 +82,29 @@ pq source add coins -t rest -u "https://api.example.com/coins" -i 30s
|
|
|
80
82
|
# Add a file source with live watching
|
|
81
83
|
pq source add orders -t file -p ./data/orders.csv -w
|
|
82
84
|
|
|
85
|
+
# Add a Postgres source (credentials interpolated from env at runtime)
|
|
86
|
+
pq source add users -t postgres \
|
|
87
|
+
-u "postgres://\${DB_USER}:\${DB_PASS}@db.internal:5432/app" \
|
|
88
|
+
-q "SELECT id, email, created_at FROM users WHERE created_at > NOW() - INTERVAL '7 days'" \
|
|
89
|
+
-i 60s
|
|
90
|
+
|
|
91
|
+
# Add a MySQL source
|
|
92
|
+
pq source add orders -t mysql \
|
|
93
|
+
-u "mysql://\${DB_USER}:\${DB_PASS}@db.internal:3306/shop" \
|
|
94
|
+
-q "SELECT id, total, status FROM orders WHERE created_at > NOW() - INTERVAL 1 DAY" \
|
|
95
|
+
-i 60s
|
|
96
|
+
|
|
97
|
+
# Add a SQLite source (path is relative to pipequery.yaml; opens read-only by default)
|
|
98
|
+
pq source add events -t sqlite -p ./events.db \
|
|
99
|
+
-q "SELECT * FROM events WHERE ts > strftime('%s', 'now', '-1 hour')" \
|
|
100
|
+
-i 30s
|
|
101
|
+
|
|
102
|
+
# Add a Kafka / Redpanda source (streaming — last 1000 messages kept in a ring buffer)
|
|
103
|
+
pq source add live_orders -t kafka \
|
|
104
|
+
--brokers "broker1:9092,broker2:9092" \
|
|
105
|
+
--topic order-events \
|
|
106
|
+
--value-format json
|
|
107
|
+
|
|
83
108
|
# Test a source (fetch sample data)
|
|
84
109
|
pq source test coins
|
|
85
110
|
|
|
@@ -92,6 +117,10 @@ Source types:
|
|
|
92
117
|
- **websocket** — Streams data from a WebSocket connection
|
|
93
118
|
- **file** — Reads JSON or CSV files, optionally watches for changes
|
|
94
119
|
- **static** — Inline JSON data defined in config
|
|
120
|
+
- **postgres** — Polls a Postgres query. Supports `${ENV_VAR}` interpolation in the connection URL so credentials stay out of `pipequery.yaml`. Options: `-u` URL, `-q` query, `-i` interval, `--ssl <require\|no-verify\|false>`, `--max-rows <n>` (default 10000).
|
|
121
|
+
- **mysql** — Polls a MySQL (or MariaDB) query. Same env-var interpolation and `--ssl` / `--max-rows` options as `postgres`.
|
|
122
|
+
- **sqlite** — Polls a query against a local SQLite file (or `:memory:`). Opens read-only by default (pass `--no-readonly` to open read-write). Options: `-p` path, `-q` query, `-i` interval, `--max-rows <n>`, `--no-readonly`.
|
|
123
|
+
- **kafka** — Streams messages from a Kafka (or Kafka-compatible, e.g. Redpanda) topic into a bounded ring buffer. Each message is decoded per `valueFormat` and spread into a row alongside `_kafka_topic`/`_kafka_partition`/`_kafka_offset`/`_kafka_timestamp`/`_kafka_key` metadata. Auto-generates a per-process consumer group so each pipequery instance sees the full firehose; set `groupId` explicitly to load-balance across replicas. Options: `--brokers` (comma list, supports `${ENV_VAR}`), `--topic`, `--group-id`, `--from-beginning`, `--value-format <json\|string\|raw>`, `--max-buffer <n>` (default 1000), `--ssl true`. SASL is config-only (not CLI-exposed yet).
|
|
95
124
|
|
|
96
125
|
### `pq endpoint`
|
|
97
126
|
|
|
@@ -181,6 +210,63 @@ pq remote connect https://my-server.example.com
|
|
|
181
210
|
pq remote status
|
|
182
211
|
```
|
|
183
212
|
|
|
213
|
+
## Use with AI (MCP)
|
|
214
|
+
|
|
215
|
+
PipeQuery ships a [Model Context Protocol](https://modelcontextprotocol.io) server so any MCP-aware AI client — Claude Desktop, Claude Code, Cursor, Copilot, custom agents — can query your configured sources directly.
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
# stdio mode — what Claude Desktop / Cursor want
|
|
219
|
+
pq mcp serve
|
|
220
|
+
|
|
221
|
+
# HTTP/SSE mode — for remote clients or future hosted deployments
|
|
222
|
+
pq mcp serve --http --port 3001
|
|
223
|
+
|
|
224
|
+
# HTTP with bearer-token auth (recommended for anything non-localhost)
|
|
225
|
+
PIPEQUERY_MCP_TOKEN=$(openssl rand -hex 32) pq mcp serve --http --port 3001
|
|
226
|
+
# or inline:
|
|
227
|
+
pq mcp serve --http --port 3001 --auth-token "my-secret"
|
|
228
|
+
|
|
229
|
+
# Attach to a running `pq serve` instance instead of loading pipequery.yaml locally
|
|
230
|
+
pq mcp serve --attach http://localhost:3000
|
|
231
|
+
|
|
232
|
+
# Inspect the tool schemas (useful for directory submission / debugging)
|
|
233
|
+
pq mcp inspect
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
**HTTP authentication** — when a token is set (`PIPEQUERY_MCP_TOKEN` env var or `--auth-token` flag), clients must send `Authorization: Bearer <token>` on every request; unauthenticated requests are rejected with `401`. If no token is set, the endpoint is open and the server prints a loud startup warning — fine for localhost, never OK for a publicly reachable deployment.
|
|
237
|
+
|
|
238
|
+
**Tools exposed** to the AI:
|
|
239
|
+
|
|
240
|
+
| Tool | What it does |
|
|
241
|
+
|------|-------------|
|
|
242
|
+
| `query` | Run any PipeQuery expression against live sources |
|
|
243
|
+
| `list_sources` | List configured sources and their health |
|
|
244
|
+
| `describe_source` | Return a sample + inferred field names for one source |
|
|
245
|
+
| `list_endpoints` | List pre-configured endpoints and their stored queries |
|
|
246
|
+
| `call_endpoint` | Execute a pre-configured endpoint by path |
|
|
247
|
+
|
|
248
|
+
### Claude Desktop setup
|
|
249
|
+
|
|
250
|
+
Add to `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
|
|
251
|
+
|
|
252
|
+
```json
|
|
253
|
+
{
|
|
254
|
+
"mcpServers": {
|
|
255
|
+
"pipequery": {
|
|
256
|
+
"command": "pq",
|
|
257
|
+
"args": ["mcp", "serve"],
|
|
258
|
+
"cwd": "/path/to/your/project-with-pipequery.yaml"
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
Restart Claude Desktop; ask "what pipequery sources are configured?" to verify.
|
|
265
|
+
|
|
266
|
+
### Claude Code / Cursor setup
|
|
267
|
+
|
|
268
|
+
Same idea — consult each tool's MCP config section. The stdio command is `pq mcp serve` with `cwd` pointing at a directory containing `pipequery.yaml`.
|
|
269
|
+
|
|
184
270
|
## Docker & Remote Deployment
|
|
185
271
|
|
|
186
272
|
The `pq` server and CLI are fully decoupled. You can run the server in Docker (locally or on a remote machine) and control it from your local terminal.
|