mcpTools property

  1. @override
List<McpTool> get mcpTools

Implementation

@override
List<McpTool> get mcpTools => [
  McpTool(
    name: 'redis_inspect',
    description:
        'Redis: what one key holds (type, TTL, encoding, size, memory, '
        'first items), or with `match` the keys of a pattern by type and '
        'the cache keys that never expire. Values are hidden in '
        'production.',
    properties: const {
      'key': {'type': 'string', 'description': 'A full key.'},
      'match': {
        'type': 'string',
        'description': 'A SCAN pattern, e.g. myapp-database-*',
      },
      'connection': {'type': 'string', 'description': 'default or cache'},
      'limit': {'type': 'integer', 'description': 'Items to show (20).'},
    },
    run: (arguments) async {
      final client = Redis.connection(
        arguments['connection'] as String? ?? 'default',
      );
      final limit = (arguments['limit'] as num?)?.toInt() ?? 20;
      if (arguments['key'] case final String key) {
        return inspectRedisKey(
          client,
          key,
          values: !_production,
          limit: limit,
        );
      }
      final config = App.make<ConfigRepository>();
      final redis = config.section<RedisConfig>();
      final audit = await auditRedisKeys(
        client,
        match: arguments['match'] as String? ?? '${redis.prefix}*',
        cachePrefix: '${redis.prefix}${config.section<CacheConfig>().prefix}',
        limit: limit,
      );
      return {
        'keys': audit.keys,
        'types': audit.types,
        'without_ttl': audit.withoutTtl,
        'cache_keys_without_ttl': audit.cacheWithoutTtl,
      };
    },
  ),
];