-
Notifications
You must be signed in to change notification settings - Fork 0
feat(mcp): add database tools for direct Redis connections #572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add 23 new MCP tools for direct Redis database interaction, enabling AI agents to query, inspect, and diagnose Redis databases. New tools: - Server info: ping, info, dbsize, module_list, client_list, config_get - Key operations: scan, type, ttl, exists, memory_usage, get, execute - Data structures: hgetall, hlen, lrange, llen, smembers, scard, zrange, zcard, slowlog, slowlog_len Features: - Uses Database profile type for connection credentials - Read-only mode blocks write commands (SET, DEL, FLUSHDB, etc.) - Generic execute tool for arbitrary Redis commands - Lazy connection initialization - Full TLS support via tokio-rustls Implementation: - New database_tools.rs with DatabaseTools struct and ConnectionManager - Parameter structs and tool implementations in server.rs - Updated mcp tools list command (now 78 total tools) - Integration test for local Redis validation
…TimeSeries, RedisBloom)
…lete, alias, and synonym tools New tools added: - FT.CREATE: Create indexes with full schema definition (TEXT, TAG, NUMERIC, GEO, VECTOR fields) - FT.DROPINDEX: Delete indexes with optional document deletion - FT.ALTER: Add fields to existing indexes - FT.EXPLAIN: Get query execution plans for debugging - FT.TAGVALS: Get unique values for TAG fields - FT.SPELLCHECK: Get spelling suggestions for queries - FT.ALIASADD/DEL/UPDATE: Manage index aliases for zero-downtime rebuilds - FT.SUGADD/GET/DEL/LEN: Autocomplete dictionary management - FT.SYNDUMP/SYNUPDATE: Synonym group management All tools include comprehensive documentation for jpx discovery indexing.
Add 10 new RedisJSON MCP tools: - JSON.MGET: Get JSON values from multiple keys - JSON.OBJKEYS: Get all keys from a JSON object - JSON.OBJLEN: Get the number of keys in a JSON object - JSON.ARRINDEX: Find the index of an element in a JSON array - JSON.ARRPOP: Pop an element from a JSON array - JSON.ARRTRIM: Trim a JSON array to a specified range - JSON.ARRINSERT: Insert elements into a JSON array - JSON.CLEAR: Clear container values or set numbers to 0 - JSON.TOGGLE: Toggle a boolean value - JSON.FORGET: Alias for JSON.DEL (documented separately) Also adds JSON.CLEAR and JSON.TOGGLE to WRITE_COMMANDS list for read-only mode protection. These tools enable comprehensive JSON document manipulation and support testing RediSearch on both HASH and JSON data types.
- Add database_pipeline tool for executing multiple Redis commands in a single round-trip - Support atomic mode (MULTI/EXEC) for transactional execution - Benchmarked: 380x speedup vs individual calls (100 commands: 5ms vs 2065ms) - Update session notes with competitive analysis and scoped work chunks Streams and Pub/Sub support scoped for next implementation phase.
The rustls-pemfile crate is marked unmaintained but is a transitive dependency of the redis crate. We cannot directly update it until upstream redis-rs updates their dependencies.
Streams tools (18 new tools): - database_xadd: Add entries to streams - database_xread: Read from streams (supports blocking) - database_xrange/xrevrange: Range queries - database_xlen: Get stream length - database_xinfo_stream/groups/consumers: Stream introspection - database_xgroup_create/destroy/delconsumer/setid: Consumer group management - database_xreadgroup: Consumer group reads - database_xack: Acknowledge messages - database_xdel: Delete entries - database_xtrim: Trim stream length - database_xpending: Get pending entries - database_xclaim/xautoclaim: Claim pending messages Pub/Sub tools (4 new tools): - database_publish: Publish messages to channels - database_pubsub_channels: List active channels - database_pubsub_numsub: Get subscriber counts - database_pubsub_numpat: Get pattern subscription count Also: - Fix clippy doc comment formatting - Add cargo-audit config to ignore RUSTSEC-2025-0134
Added 22 new tool definitions: - 18 Streams tools (XADD, XREAD, XRANGE, XREVRANGE, XLEN, XINFO, XGROUP, XREADGROUP, XACK, XDEL, XTRIM, XPENDING, XCLAIM, XAUTOCLAIM) - 4 Pub/Sub tools (PUBLISH, PUBSUB CHANNELS, PUBSUB NUMSUB, PUBSUB NUMPAT) Added two new subcategories: - streams: Redis Streams for event sourcing and message queues - pubsub: Pub/Sub messaging operations Total tools in discovery: 100
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Add 23 new MCP tools for direct Redis database interaction, enabling AI agents to query, inspect, and diagnose Redis databases through natural conversation.
Closes #564
New Tools (23 total)
Server Info (6)
database_ping- Ping the Redis serverdatabase_info- Get server information (INFO)database_dbsize- Get number of keys in databasedatabase_module_list- List loaded modulesdatabase_client_list- Get connected clientsdatabase_config_get- Get configuration valuesKey Operations (7)
database_scan- Scan keys matching a pattern (safe alternative to KEYS)database_type- Get key typedatabase_ttl- Get key TTL in secondsdatabase_exists- Check if key existsdatabase_memory_usage- Get memory usage of a keydatabase_get- Get string key valuedatabase_execute- Execute arbitrary Redis commandData Structures (10)
database_hgetall- Get all hash fieldsdatabase_hlen- Get hash lengthdatabase_lrange- Get list rangedatabase_llen- Get list lengthdatabase_smembers- Get set membersdatabase_scard- Get set cardinalitydatabase_zrange- Get sorted set rangedatabase_zcard- Get sorted set cardinalitydatabase_slowlog- Get slow log entriesdatabase_slowlog_len- Get slow log lengthFeatures
--allow-writesto enabledatabase_executeallows arbitrary Redis commands for flexibilityImplementation
database_tools.rsmodule withDatabaseToolsstruct andConnectionManagerserver.rsmcp toolscommand output (now shows 78 total tools)Testing
Tool Count