list_kv_keys
List all keys in a Workers KV namespace with support for prefix filtering and pagination to navigate large datasets.
Instructions
List all keys in a Workers KV namespace. Supports pagination and prefix filtering.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| account_id | No | Account ID (uses default from config if not provided) | |
| namespace_id | Yes | The KV namespace ID | |
| prefix | No | Filter keys by prefix | |
| limit | No | Maximum number of keys to return (default: 1000) | |
| cursor | No | Cursor for pagination |
Implementation Reference
- The _list_kv_keys method is the actual handler implementation. It resolves the account_id, builds query params (prefix, limit, cursor), and makes a GET request to the Cloudflare API endpoint /accounts/{account_id}/storage/kv/namespaces/{namespace_id}/keys.
async def _list_kv_keys(self, args: dict) -> Any: """List KV keys.""" account_id = args.get("account_id") or self.account_id if not account_id: raise ValueError("Account ID is required. Provide it in args or config.") params = {} if args.get("prefix"): params["prefix"] = args["prefix"] if args.get("limit"): params["limit"] = args["limit"] if args.get("cursor"): params["cursor"] = args["cursor"] return await self._make_request( f"/accounts/{account_id}/storage/kv/namespaces/{args['namespace_id']}/keys", params=params, ) - The Tool definition with inputSchema for list_kv_keys. Schema defines properties: account_id (optional), namespace_id (required), prefix (optional), limit (optional number), cursor (optional string).
Tool( name="list_kv_keys", description="List all keys in a Workers KV namespace. Supports pagination and prefix filtering.", inputSchema={ "type": "object", "properties": { "account_id": { "type": "string", "description": "Account ID (uses default from config if not provided)", }, "namespace_id": { "type": "string", "description": "The KV namespace ID", }, "prefix": { "type": "string", "description": "Filter keys by prefix", }, "limit": { "type": "number", "description": "Maximum number of keys to return (default: 1000)", }, "cursor": { "type": "string", "description": "Cursor for pagination", }, }, "required": ["namespace_id"], }, ), - src/cloudflare_mcp_server/__init__.py:428-429 (registration)The tool routing in call_tool handler: when name == 'list_kv_keys', it dispatches to self._list_kv_keys(arguments).
elif name == "list_kv_keys": result = await self._list_kv_keys(arguments) - src/cloudflare_mcp_server/__init__.py:352-352 (registration)The tool registration in list_tools() with name='list_kv_keys'.
name="list_kv_keys",