Support reading from the $all stream#4
Conversation
The read_stream tool now handles `$all` by using `read_all()` instead of `get_stream()`, filtering out system events (prefixed with `$`). Also includes the stream name in the output so events from different streams are distinguishable. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Lougarou
left a comment
There was a problem hiding this comment.
Thanks for this contribution @TastyPi — reading from $all is a really useful addition, and the approach of annotating events with their stream name is spot on.
Two suggestions:
1. Drop the custom filter_exclude — the library default already handles this
The kurrentdbclient read_all() method defaults to filter_exclude=DEFAULT_EXCLUDE_FILTER, which is:
DEFAULT_EXCLUDE_FILTER = (
r"\$.+", # system events ($@, $metadata, etc.)
r"PersistentConfig\d+", # persistent subscription config events
r"Result", # projection result events
)The current PR overrides this with filter_exclude=[r"^\$"], which actually lets system events slip through (e.g. $@ link events from $category-* streams). This is because the library wraps patterns via construct_filter_exclude_regex() into ^(?!(pattern$|...)), so the ^\$ pattern only excludes the literal single-character event type $, not $@, $metadata, etc.
I verified this with an MCP test client — removing the filter_exclude parameter entirely (relying on the library default) fixes the issue:
events = kdb_client.read_all(
resolve_links=True,
backwards=backwards,
limit=limit,
)2. Update the docstring to mention $all support
MCP clients (Claude Desktop, Claude Code, Cursor, etc.) read the tool's description to decide when and how to invoke it. The current docstring says "one single word stream name" — without mentioning $all, the LLM client may never discover this capability. Something like:
stream: The stream name to read from. Use "$all" to read from all streams (system events are filtered out automatically).
|
@Lougarou Updated based on your suggestions. For the $all stream, I found Claude at least always used it correctly without the extra documentation, but I agree it's more helpful to include. |
The read_stream tool now handles
$allby usingread_all()instead ofget_stream(), filtering out system events (prefixed with$). Also includes the stream name in the output so events from different streams are distinguishable.Works very well with Claude Code.