Skip to content

Support reading from the $all stream#4

Merged
Lougarou merged 3 commits intokurrent-io:masterfrom
Ophelos:support-reading-all-stream
Mar 31, 2026
Merged

Support reading from the $all stream#4
Lougarou merged 3 commits intokurrent-io:masterfrom
Ophelos:support-reading-all-stream

Conversation

@TastyPi
Copy link
Copy Markdown
Contributor

@TastyPi TastyPi commented Mar 27, 2026

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.

Works very well with Claude Code.

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>
Copy link
Copy Markdown
Collaborator

@Lougarou Lougarou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@TastyPi TastyPi requested a review from Lougarou March 30, 2026 11:32
@TastyPi
Copy link
Copy Markdown
Contributor Author

TastyPi commented Mar 30, 2026

@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.

@Lougarou Lougarou merged commit de26174 into kurrent-io:master Mar 31, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants