You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: PLAN.md
+131-3Lines changed: 131 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,33 @@
4
4
5
5
Prepare StreamNative MCP Server for Claude connector submission and review.
6
6
7
+
## Current review follow-up: operation spec registry
8
+
9
+
Reviewer feedback is valid: current branch split read/write tool names, but duplicated `toolMode` helpers and per-builder write-operation maps still create scatter-shot maintenance. Adding one operation can require enum updates, write map updates, handler switch updates, docs, and compliance-test classification. `validateModeOperation` also classifies any operation missing from the write map as read, so an unclassified future write can pass read-mode validation until the handler switch rejects or mishandles it.
10
+
11
+
Recommended next design: make each tool family declare operation metadata once, then derive mode-specific tool schemas, annotations, validation, and tests from that registry.
12
+
13
+
```go
14
+
typeOperationModestring
15
+
16
+
const (
17
+
OperationModeReadOperationMode = "read"
18
+
OperationModeWriteOperationMode = "write"
19
+
)
20
+
21
+
typeOperationSpecstruct {
22
+
Namestring
23
+
ModeOperationMode
24
+
Destructivebool
25
+
Idempotentbool
26
+
Resources []string
27
+
Params []ParamSpec
28
+
HandlerOperationHandler
29
+
}
30
+
```
31
+
32
+
Scope is incremental but complete: add shared spec helpers, migrate `kafka/topics.go` and `pulsar/namespace.go` as reference implementations, then migrate every remaining split builder in batches. Keep current read/write tool names unchanged. Use docs generated operation-table blocks first; do not rewrite full Markdown documents.
33
+
7
34
Hard requirements from Claude docs:
8
35
9
36
- every MCP tool has non-empty `annotations.title`
@@ -403,12 +430,16 @@ Plan:
403
430
404
431
### Phase 1: shared annotation + mode helpers
405
432
433
+
Status: implemented on current branch.
434
+
406
435
- Add `pkg/mcp/toolannotations` helper.
407
436
- Add local read/write mode helpers in builders with mixed operations.
408
437
- Add reusable operation validation helpers where a builder already has operation maps.
409
438
410
439
### Phase 2: split Kafka tools completely
411
440
441
+
Status: implemented on current branch; follow-up refactor still needed to remove duplicated operation classification.
442
+
412
443
- Update all Kafka builders to build mode-specific tools.
413
444
- Ensure read/write tools have mode-specific descriptions, examples, operation enums, and parameter schemas.
414
445
- Read-only config returns only read tools.
@@ -418,6 +449,8 @@ Plan:
418
449
419
450
### Phase 3: split Pulsar tools completely
420
451
452
+
Status: implemented on current branch; follow-up refactor still needed to remove duplicated operation classification.
453
+
421
454
- Update all Pulsar builders to build mode-specific tools.
422
455
- Ensure read/write tools have mode-specific descriptions, examples, operation enums, and parameter schemas.
423
456
- Preserve existing read-only behavior by not registering write tools in read-only config.
- add `go generate` or test helper to refresh/check blocks
561
+
11. Cleanup after migration:
562
+
- delete or shrink duplicated Kafka/Pulsar `tool_mode.go`
563
+
- move shared `pruneToolInputSchema`/required filtering helper if still duplicated
564
+
- remove obsolete per-builder write maps
565
+
- remove obsolete compliance-test write maps
566
+
450
567
## Tests / compliance guard
451
568
452
569
Add focused tests:
@@ -465,25 +582,36 @@ Add focused tests:
465
582
- StreamNative Cloud/context/log/resource tools have valid annotations.
466
583
- PFTools dynamic tool creation has valid annotation.
467
584
- Operation validation rejects read operations on write tools and write operations on read tools.
585
+
- Operation validation rejects unknown operations instead of treating them as read.
586
+
- Operation enum values are derived from or checked against `OperationSpec`.
587
+
- Compliance tests derive read/write classification from `OperationSpec`, not hand-maintained write maps.
588
+
- Docs generated operation table blocks match `OperationSpec`.
468
589
469
590
Static guard:
470
591
471
592
- Build all feature sets and assert no `operation` enum contains both read and write verbs in one tool.
472
593
- For split tool families, assert mode-specific schema/description purity with family-specific allow/deny lists.
594
+
- Assert every handler switch operation has a matching `OperationSpec` entry.
473
595
474
596
## Risks
475
597
476
598
- Tool split is runtime-visible and likely breaking for clients/prompts that call old names.
477
-
- Docs under `docs/tools/` can drift if not updated with split names.
599
+
- Operation spec refactor can accidentally change schema ordering, descriptions, or enum content even when tool names stay unchanged.
600
+
- Docs under `docs/tools/` can drift if generated operation blocks are not checked in tests or `go generate`.
478
601
- Some operations are ambiguous (`consume`, `trigger`, cursor operations, context reset). Conservative destructive annotation may add confirmations but avoids unsafe auto-run.
479
602
- Some current tools may have read-only-mode logic embedded in handlers; after split, registration and handler validation must both enforce mode to prevent write leakage.
603
+
-`OperationSpec.Handler` can over-couple schema metadata and dispatch if introduced too early. Prefer enum/validation/test/doc generation first, then dispatch consolidation.
480
604
-`mcp-go` default annotations are unsafe for compliance because title empty and destructive default true.
481
605
482
606
## Confirmed decisions
483
607
484
608
- Fix all current mixed read/write surfaces, not only `kafka/topics.go` and `pulsar/namespace.go`.
609
+
- Implement operation-spec follow-up across all affected split builders, not only the two reference files.
610
+
- Start with shared spec + two reference migrations: `kafka/topics.go` and `pulsar/namespace.go`.
611
+
- Keep current read/write tool names unchanged.
485
612
- Do not preserve old mixed tool names or old mixed builder/schema patterns.
486
613
- Runtime-visible docs must be updated with read/write split and must avoid mixed read/write wording.
614
+
- For docs generation, start with generated operation table blocks only; do not generate whole Markdown documents.
487
615
- Conservative safety annotations are acceptable for ambiguous side-effect tools unless implementation proves true read-only behavior.
**Claude connector safety:** Actual MCP tools are split into `kafka_admin_connect_read` and `kafka_admin_connect_write`. The read tool is read-only and only exposes read operations/parameters. The write tool is destructive and is not registered in read-only mode.
**Claude connector safety:** Actual MCP tools are split into `kafka_admin_groups_read` and `kafka_admin_groups_write`. The read tool is read-only and only exposes read operations/parameters. The write tool is destructive and is not registered in read-only mode.
**Claude connector safety:** Actual MCP tools are split into `kafka_admin_sr_read` and `kafka_admin_sr_write`. The read tool is read-only and only exposes read operations/parameters. The write tool is destructive and is not registered in read-only mode.
**Claude connector safety:** Actual MCP tools are split into `kafka_admin_topics_read` and `kafka_admin_topics_write`. The read tool is read-only and only exposes read operations/parameters. The write tool is destructive and is not registered in read-only mode.
**Claude connector safety:** Actual MCP tools are split into `pulsar_admin_brokers_read` and `pulsar_admin_brokers_write`. The read tool is read-only and only exposes read operations/parameters. The write tool is destructive and is not registered in read-only mode.
**Claude connector safety:** Actual MCP tools are split into `pulsar_admin_cluster_read` and `pulsar_admin_cluster_write`. The read tool is read-only and only exposes read operations/parameters. The write tool is destructive and is not registered in read-only mode.
**Claude connector safety:** Actual MCP tools are split into `pulsar_admin_functions_read` and `pulsar_admin_functions_write`. The read tool is read-only and only exposes read operations/parameters. The write tool is destructive and is not registered in read-only mode.
4
12
5
13
Pulsar Functions are lightweight compute processes that consume messages from Pulsar topics, apply user-defined logic, and optionally produce results to another topic.
**Claude connector safety:** Actual MCP tools are split into `pulsar_admin_namespace_read` and `pulsar_admin_namespace_write`. The read tool is read-only and only exposes read operations/parameters. The write tool is destructive and is not registered in read-only mode.
**Claude connector safety:** Actual MCP tools are split into `pulsar_admin_nsisolationpolicy_read` and `pulsar_admin_nsisolationpolicy_write`. The read tool is read-only and only exposes read operations/parameters. The write tool is destructive and is not registered in read-only mode.
4
12
5
13
Namespace isolation policies control which brokers specific namespaces can use.
0 commit comments