kafka-mcp 0.1.1 → 0.1.2
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 +71 -2
- package/dist/cli.js +22 -1
- package/dist/lib/skill-installer.d.ts +11 -0
- package/dist/lib/skill-installer.js +97 -0
- package/package.json +1 -1
- package/skills/kafka-cli/SKILL.md +6 -6
package/README.md
CHANGED
|
@@ -9,10 +9,11 @@
|
|
|
9
9
|
- 获取指定 Topic 的消息并支持搜索
|
|
10
10
|
- 获取消费者组列表
|
|
11
11
|
- 查看指定消费者组在某个 Topic 上的消费进度
|
|
12
|
+
- 安装面向 Cursor、Claude、Codex 的技能模板
|
|
12
13
|
|
|
13
14
|
## 功能与命令
|
|
14
15
|
|
|
15
|
-
当前 CLI 提供以下
|
|
16
|
+
当前 CLI 提供以下 6 个命令:
|
|
16
17
|
|
|
17
18
|
### 1. `topics`
|
|
18
19
|
|
|
@@ -96,6 +97,34 @@ node dist/cli.js groups --search billing
|
|
|
96
97
|
node dist/cli.js group-progress --group billing-consumers --topic orders
|
|
97
98
|
```
|
|
98
99
|
|
|
100
|
+
### 6. `skill-install`
|
|
101
|
+
|
|
102
|
+
安装可复用的技能模板,支持:
|
|
103
|
+
|
|
104
|
+
- `cursor`
|
|
105
|
+
- `claude`
|
|
106
|
+
- `codex`
|
|
107
|
+
|
|
108
|
+
默认安装位置:
|
|
109
|
+
|
|
110
|
+
- `cursor`:当前目录下的 `.cursor/rules/kafka-mcp.mdc`
|
|
111
|
+
- `claude`:当前目录下的 `.claude/commands/kafka-mcp.md`
|
|
112
|
+
- `codex`:`$CODEX_HOME/skills/kafka-cli-inspector/SKILL.md`
|
|
113
|
+
|
|
114
|
+
常用参数:
|
|
115
|
+
|
|
116
|
+
- `--dir`:指定安装根目录
|
|
117
|
+
- `--force`:覆盖已有文件
|
|
118
|
+
|
|
119
|
+
示例:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
node dist/cli.js skill-install cursor
|
|
123
|
+
node dist/cli.js skill-install claude
|
|
124
|
+
node dist/cli.js skill-install codex
|
|
125
|
+
node dist/cli.js skill-install cursor --dir /path/to/project --force
|
|
126
|
+
```
|
|
127
|
+
|
|
99
128
|
## 配置方式
|
|
100
129
|
|
|
101
130
|
CLI 会按以下顺序读取配置,找到第一个存在的配置源后使用:
|
|
@@ -139,17 +168,43 @@ CLI 会按以下顺序读取配置,找到第一个存在的配置源后使用
|
|
|
139
168
|
|
|
140
169
|
## 安装
|
|
141
170
|
|
|
171
|
+
本地开发:
|
|
172
|
+
|
|
142
173
|
```bash
|
|
143
174
|
npm install
|
|
144
175
|
npm run build
|
|
145
176
|
```
|
|
146
177
|
|
|
147
|
-
|
|
178
|
+
如果要直接使用已经发布到 npm 的版本,可以有两种方式。
|
|
179
|
+
|
|
180
|
+
方式一:全局安装
|
|
148
181
|
|
|
149
182
|
```bash
|
|
150
183
|
npm install -g kafka-mcp
|
|
151
184
|
```
|
|
152
185
|
|
|
186
|
+
安装完成后可以直接执行:
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
kafka-mcp --help
|
|
190
|
+
kafka-mcp topics
|
|
191
|
+
kafka-mcp messages --topic orders --search paid
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
方式二:使用 `npx` 直接运行,无需全局安装
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
npx kafka-mcp --help
|
|
198
|
+
npx kafka-mcp topics
|
|
199
|
+
npx kafka-mcp messages --topic orders --search paid
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
如果你想固定版本,也可以这样使用:
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
npx kafka-mcp@0.1.1 --help
|
|
206
|
+
```
|
|
207
|
+
|
|
153
208
|
## 使用示例
|
|
154
209
|
|
|
155
210
|
```bash
|
|
@@ -158,6 +213,7 @@ npx tsx src/cli.ts topic --topic orders
|
|
|
158
213
|
npx tsx src/cli.ts messages --topic orders --search paid --limit 20
|
|
159
214
|
npx tsx src/cli.ts groups --search billing
|
|
160
215
|
npx tsx src/cli.ts group-progress --group billing-consumers --topic orders
|
|
216
|
+
npx tsx src/cli.ts skill-install cursor
|
|
161
217
|
```
|
|
162
218
|
|
|
163
219
|
如果已经执行过构建,也可以直接运行:
|
|
@@ -167,6 +223,19 @@ node dist/cli.js topics
|
|
|
167
223
|
node dist/cli.js messages --topic orders --search paid
|
|
168
224
|
```
|
|
169
225
|
|
|
226
|
+
如果使用已发布的 npm 包,对应命令可以写成:
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
kafka-mcp topics --search order
|
|
230
|
+
kafka-mcp topic --topic orders
|
|
231
|
+
kafka-mcp messages --topic orders --search paid --limit 20
|
|
232
|
+
kafka-mcp groups --search billing
|
|
233
|
+
kafka-mcp group-progress --group billing-consumers --topic orders
|
|
234
|
+
kafka-mcp skill-install cursor
|
|
235
|
+
kafka-mcp skill-install claude
|
|
236
|
+
kafka-mcp skill-install codex
|
|
237
|
+
```
|
|
238
|
+
|
|
170
239
|
## Skill
|
|
171
240
|
|
|
172
241
|
可复用的 Skill 定义位于 `skills/kafka-cli/SKILL.md`,后续可以基于这个 CLI 继续扩展成面向 Codex、Claude 或其他 Agent 的 Kafka 操作能力。
|
package/dist/cli.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { Command } from "commander";
|
|
3
3
|
import { formatRows } from "./lib/format.js";
|
|
4
4
|
import { KafkaCliService } from "./lib/kafka.js";
|
|
5
|
+
import { installSkill } from "./lib/skill-installer.js";
|
|
5
6
|
const program = new Command();
|
|
6
7
|
let service;
|
|
7
8
|
function getService() {
|
|
@@ -11,7 +12,7 @@ function getService() {
|
|
|
11
12
|
program
|
|
12
13
|
.name("kafka-mcp")
|
|
13
14
|
.description("Kafka CLI for topics, messages, and consumer group inspection")
|
|
14
|
-
.version("0.1.
|
|
15
|
+
.version("0.1.2");
|
|
15
16
|
program
|
|
16
17
|
.command("topics")
|
|
17
18
|
.description("List topics")
|
|
@@ -89,6 +90,26 @@ program
|
|
|
89
90
|
lag: partition.lag ?? ""
|
|
90
91
|
}))));
|
|
91
92
|
});
|
|
93
|
+
program
|
|
94
|
+
.command("skill-install")
|
|
95
|
+
.description("Install a reusable skill template for Cursor, Claude, or Codex")
|
|
96
|
+
.argument("<target>", "Target platform: cursor | claude | codex")
|
|
97
|
+
.option("-d, --dir <path>", "Custom base directory for installation")
|
|
98
|
+
.option("-f, --force", "Overwrite an existing installed file")
|
|
99
|
+
.action(async (target, options) => {
|
|
100
|
+
if (!isSkillTarget(target)) {
|
|
101
|
+
throw new Error(`Unsupported target: ${target}. Expected one of: cursor, claude, codex.`);
|
|
102
|
+
}
|
|
103
|
+
const result = await installSkill({
|
|
104
|
+
target,
|
|
105
|
+
baseDir: options.dir,
|
|
106
|
+
force: options.force
|
|
107
|
+
});
|
|
108
|
+
console.log(`Installed ${result.target} skill to: ${result.outputPath}`);
|
|
109
|
+
});
|
|
110
|
+
function isSkillTarget(value) {
|
|
111
|
+
return value === "cursor" || value === "claude" || value === "codex";
|
|
112
|
+
}
|
|
92
113
|
program.parseAsync(process.argv).catch((error) => {
|
|
93
114
|
const message = error instanceof Error ? error.message : String(error);
|
|
94
115
|
console.error(`Error: ${message}`);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type SkillTarget = "cursor" | "claude" | "codex";
|
|
2
|
+
export interface InstallSkillOptions {
|
|
3
|
+
target: SkillTarget;
|
|
4
|
+
baseDir?: string;
|
|
5
|
+
force?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface InstallSkillResult {
|
|
8
|
+
target: SkillTarget;
|
|
9
|
+
outputPath: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function installSkill(options: InstallSkillOptions): Promise<InstallSkillResult>;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { dirname, resolve } from "node:path";
|
|
5
|
+
export async function installSkill(options) {
|
|
6
|
+
const outputPath = resolveInstallPath(options.target, options.baseDir);
|
|
7
|
+
const content = renderSkillContent(options.target);
|
|
8
|
+
await mkdir(dirname(outputPath), { recursive: true });
|
|
9
|
+
if (!options.force && existsSync(outputPath)) {
|
|
10
|
+
throw new Error(`Target file already exists: ${outputPath}. Re-run with --force to overwrite.`);
|
|
11
|
+
}
|
|
12
|
+
await writeFile(outputPath, content, "utf8");
|
|
13
|
+
return {
|
|
14
|
+
target: options.target,
|
|
15
|
+
outputPath
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function resolveInstallPath(target, baseDir) {
|
|
19
|
+
if (target === "cursor") {
|
|
20
|
+
return resolve(baseDir ?? process.cwd(), ".cursor", "rules", "kafka-mcp.mdc");
|
|
21
|
+
}
|
|
22
|
+
if (target === "claude") {
|
|
23
|
+
return resolve(baseDir ?? process.cwd(), ".claude", "commands", "kafka-mcp.md");
|
|
24
|
+
}
|
|
25
|
+
const codexHome = process.env.CODEX_HOME ?? resolve(homedir(), ".codex");
|
|
26
|
+
return resolve(baseDir ?? codexHome, "skills", "kafka-cli-inspector", "SKILL.md");
|
|
27
|
+
}
|
|
28
|
+
function renderSkillContent(target) {
|
|
29
|
+
if (target === "cursor") {
|
|
30
|
+
return `---
|
|
31
|
+
description: Kafka inspection workflow through the published kafka-mcp CLI
|
|
32
|
+
globs:
|
|
33
|
+
alwaysApply: false
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
- Use \`npx kafka-mcp\` for read-only Kafka inspection tasks.
|
|
37
|
+
- Start with \`npx kafka-mcp topics --search <keyword>\` when the exact topic is unknown.
|
|
38
|
+
- Use \`npx kafka-mcp messages --topic <topic> --search <keyword> --limit <n>\` to preview messages.
|
|
39
|
+
- Use \`npx kafka-mcp groups --search <keyword>\` to find consumer groups.
|
|
40
|
+
- Use \`npx kafka-mcp group-progress --group <groupId> --topic <topic>\` to inspect committed offsets, latest offsets, and lag.
|
|
41
|
+
- Keep limits small unless the user explicitly asks for broader inspection.
|
|
42
|
+
- Summarize only the relevant topics, messages, or lagging partitions.
|
|
43
|
+
`;
|
|
44
|
+
}
|
|
45
|
+
if (target === "claude") {
|
|
46
|
+
return `---
|
|
47
|
+
description: Inspect Kafka topics, messages, and consumer lag with kafka-mcp
|
|
48
|
+
argument-hint: [goal or topic/group details]
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
Use the published \`kafka-mcp\` CLI through \`npx kafka-mcp\` to investigate Kafka in read-only mode.
|
|
52
|
+
|
|
53
|
+
Preferred workflow:
|
|
54
|
+
|
|
55
|
+
1. If the exact topic is unknown, run \`npx kafka-mcp topics --search $ARGUMENTS\`.
|
|
56
|
+
2. If the exact consumer group is unknown, run \`npx kafka-mcp groups --search $ARGUMENTS\`.
|
|
57
|
+
3. For message lookup, run \`npx kafka-mcp messages --topic <topic> --search <keyword> --limit 20\`.
|
|
58
|
+
4. For consumer lag, run \`npx kafka-mcp group-progress --group <groupId> --topic <topic>\`.
|
|
59
|
+
|
|
60
|
+
When responding:
|
|
61
|
+
|
|
62
|
+
- Summarize only the relevant topics, messages, or lagging partitions.
|
|
63
|
+
- Mention topic, partition, committed offset, latest offset, and lag when reporting progress issues.
|
|
64
|
+
- Call out clearly when there are no matches.
|
|
65
|
+
`;
|
|
66
|
+
}
|
|
67
|
+
return `---
|
|
68
|
+
name: kafka-cli-inspector
|
|
69
|
+
description: Use this skill when you need to inspect Kafka topics, preview messages, search Kafka data, or analyze a consumer group's progress for a topic through the published kafka-mcp npm CLI.
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
# Kafka CLI Inspector
|
|
73
|
+
|
|
74
|
+
Use this skill when a user wants Kafka read-only inspection through the published \`kafka-mcp\` npm CLI.
|
|
75
|
+
|
|
76
|
+
## Commands
|
|
77
|
+
|
|
78
|
+
- \`npx kafka-mcp topics --search <keyword>\` lists topics and supports fuzzy substring search.
|
|
79
|
+
- \`npx kafka-mcp topic --topic <topic>\` shows partition metadata for a topic.
|
|
80
|
+
- \`npx kafka-mcp messages --topic <topic> --search <keyword> --limit <n>\` previews messages from a topic and filters by topic, key, value, or headers.
|
|
81
|
+
- \`npx kafka-mcp groups --search <keyword>\` lists consumer groups and supports search.
|
|
82
|
+
- \`npx kafka-mcp group-progress --group <groupId> --topic <topic>\` shows committed offsets, latest offsets, lag, and the current member assignment per partition.
|
|
83
|
+
|
|
84
|
+
## Workflow
|
|
85
|
+
|
|
86
|
+
1. Check that Kafka brokers are configured through \`.kafka-mcp.json\`, \`~/.config/kafka-mcp/config.json\`, or \`KAFKA_BROKERS\`.
|
|
87
|
+
2. Use \`topics\` or \`groups\` first if the exact topic or consumer group is unknown.
|
|
88
|
+
3. Use \`messages\` for lightweight investigation. Prefer small limits and a search term.
|
|
89
|
+
4. Use \`group-progress\` when the task is about backlog, lag, stuck partitions, or which consumer currently owns a partition.
|
|
90
|
+
|
|
91
|
+
## Output guidance
|
|
92
|
+
|
|
93
|
+
- Summarize only the relevant topics, messages, or lagging partitions.
|
|
94
|
+
- Call out when a search returns no results rather than dumping empty tables.
|
|
95
|
+
- When reporting lag, mention the topic, partition, committed offset, latest offset, and lag value.
|
|
96
|
+
`;
|
|
97
|
+
}
|
package/package.json
CHANGED
|
@@ -5,15 +5,15 @@ description: Use this skill when you need to inspect Kafka topics, preview messa
|
|
|
5
5
|
|
|
6
6
|
# Kafka CLI Inspector
|
|
7
7
|
|
|
8
|
-
Use this skill when a user wants Kafka read-only inspection
|
|
8
|
+
Use this skill when a user wants Kafka read-only inspection through the published `kafka-mcp` npm CLI.
|
|
9
9
|
|
|
10
10
|
## Commands
|
|
11
11
|
|
|
12
|
-
- `npx
|
|
13
|
-
- `npx
|
|
14
|
-
- `npx
|
|
15
|
-
- `npx
|
|
16
|
-
- `npx
|
|
12
|
+
- `npx kafka-mcp topics --search <keyword>` lists topics and supports fuzzy substring search.
|
|
13
|
+
- `npx kafka-mcp topic --topic <topic>` shows partition metadata for a topic.
|
|
14
|
+
- `npx kafka-mcp messages --topic <topic> --search <keyword> --limit <n>` previews messages from a topic and filters by topic, key, value, or headers.
|
|
15
|
+
- `npx kafka-mcp groups --search <keyword>` lists consumer groups and supports search.
|
|
16
|
+
- `npx kafka-mcp group-progress --group <groupId> --topic <topic>` shows committed offsets, latest offsets, lag, and the current member assignment per partition.
|
|
17
17
|
|
|
18
18
|
## Workflow
|
|
19
19
|
|