Skip to content

feat(mcp): add Redis MCP Bridge with 25 tools (#2511)#2614

Merged
mrveiss merged 5 commits intoDev_new_guifrom
feat/redis-mcp-bridge
Mar 28, 2026
Merged

feat(mcp): add Redis MCP Bridge with 25 tools (#2511)#2614
mrveiss merged 5 commits intoDev_new_guifrom
feat/redis-mcp-bridge

Conversation

@mrveiss
Copy link
Copy Markdown
Owner

@mrveiss mrveiss commented Mar 27, 2026

Summary

Implements redis_mcp as the 11th native MCP bridge in AutoBot's registry, giving AI agents direct access to Redis data structures, RediSearch vector search, and operational intelligence.

Closes #2511

25 MCP Tools across 3 categories:

Data Access (15 tools):

  • String: redis_get, redis_set, redis_delete
  • Hash: redis_hget, redis_hgetall, redis_hset
  • List: redis_lrange, redis_lpush, redis_rpush
  • Sorted Set: redis_zrange
  • Stream: redis_xrange, redis_xadd
  • Keys: redis_scan_keys, redis_type, redis_ttl

Vector Search (4 tools):

  • redis_vector_create_index, redis_vector_search, redis_hybrid_search, redis_vector_index_info

Ops Intelligence (6 tools):

  • redis_server_info, redis_dbsize, redis_memory_stats, redis_stream_health, redis_client_list, redis_slowlog

RBAC Model:

  • Users: Read all + write autobot:agent:* namespace only, read-only ops (no client_list/slowlog)
  • Admins: Full access, destructive ops (delete) require approval

Security hardening (code review findings):

  • All keys validated in namespace check (not just the first) — prevents multi-key bypass
  • filter_expression sanitized via regex allowlist — prevents RediSearch injection
  • top_k clamped to [1, 500] — prevents resource exhaustion
  • create_index restricted to SCOPED_WRITE for non-admin users
  • database parameter validated against DATABASE_MAPPING

Architecture:

Files:

  • autobot-backend/api/redis_mcp/__init__.py — Package entry
  • autobot-backend/api/redis_mcp/tools.py — 25 tool definitions (JSON schemas)
  • autobot-backend/api/redis_mcp/rbac.py — Role-based access control matrix
  • autobot-backend/api/redis_mcp/data_access.py — 15 data tool handlers
  • autobot-backend/api/redis_mcp/vector_search.py — 4 vector search handlers
  • autobot-backend/api/redis_mcp/ops_intelligence.py — 6 ops tool handlers
  • autobot-backend/api/redis_mcp/router.py — FastAPI router + dispatch

Test plan

  • Verify all 25 tools listed at GET /api/redis/mcp/tools
  • Verify RBAC: user cannot access redis_client_list or redis_slowlog
  • Verify namespace enforcement: user write to non-autobot:agent:* key is rejected
  • Verify multi-key namespace enforcement: all keys in a delete call are validated
  • Verify admin destructive ops return approval_required status
  • Verify data access tools (get/set/hash/list/stream) work against Redis
  • Verify vector search creates index and queries return results
  • Verify top_k is clamped (passing 9999 returns max 500)
  • Verify invalid filter_expression is rejected
  • Verify invalid database parameter returns 400
  • Verify ops tools return valid server stats
  • Verify bridge appears in MCP registry at GET /api/mcp/bridges
  • Pre-commit hooks pass (black, isort, flake8, bandit, function length)

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 27, 2026

⚠️ SSOT Configuration Compliance: Violations Found

Metric Count
Total Violations 2
SSOT Violations (high priority) 1
Other Violations 1

⚠️ 1 values have SSOT config equivalents!

These should be replaced with SSOT config imports:

Python:

from src.config.ssot_config import config
# Use: config.vm.main, config.port.backend, config.backend_url

TypeScript:

import config from '@/config/ssot-config'
// Use: config.vm.main, config.port.backend, config.backendUrl

📖 See SSOT_CONFIG_GUIDE.md for documentation.

mrveiss added 4 commits March 28, 2026 14:17
Implement redis_mcp as the 11th native MCP bridge providing agents
direct access to Redis data structures, RediSearch vector search,
and operational intelligence.

25 tools across 3 categories:
- Data Access (15): get/set, hash, list, sorted set, stream, scan, type, ttl, delete
- Vector Search (4): create_index, vector_search, hybrid_search, index_info
- Ops Intelligence (6): server_info, dbsize, memory_stats, stream_health, client_list, slowlog

RBAC model: users read all + write autobot:agent:* only; admins full access
with approval gates for destructive operations.
…, #2623)

and surfaces them to the agent with instructions to request user confirmation.
Redis MCP router accepts approved=true to bypass the gate after confirmation.
Also extracts _handle_unknown_tool helper to fix pre-existing function length
violation in _dispatch_tool_call.

accept query_text as an alternative to query_vector. Text is transparently
converted to embeddings using the existing NPU/Ollama pipeline from
knowledge.facts._generate_embedding_with_npu_fallback.
query_text is now an alternative to query_vector, so query_vector
should not be required. filter_expression remains required.
…ethod (#2511)

After rebase onto Dev_new_gui, _handle_unknown_tool (standalone function) was
superseded by _build_unknown_tool_error (class method from #2629). Remove dead code
and update type hints to lowercase builtins.
@mrveiss mrveiss force-pushed the feat/redis-mcp-bridge branch from 0e7fe44 to 78b240d Compare March 28, 2026 12:31
Security fixes:
- S1: Validate ALL keys in namespace check, not just the first
- S2: Sanitize filter_expression against injection via regex allowlist
- S3: Clamp top_k to [1, 500] to prevent resource exhaustion

Quality fixes:
- H1: Restrict create_index to SCOPED_WRITE for non-admin users
- H2: Validate database parameter against DATABASE_MAPPING
- H3: Extract _decode() helper to reduce xrange function length
- M3: Extract _build_index_schema() from create_index handler
- M5: Share _execute_vector_query() between search/hybrid_search
- M7: Modernize typing.List to builtin list in tools.py
@mrveiss mrveiss merged commit 1afa540 into Dev_new_gui Mar 28, 2026
4 of 5 checks passed
@mrveiss mrveiss deleted the feat/redis-mcp-bridge branch March 28, 2026 17:56
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.

1 participant