list_kv_keys
Retrieve all keys from a Cloudflare Workers KV namespace with pagination and prefix filtering support to manage stored data efficiently.
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 |
Input Schema (JSON Schema)
{
"properties": {
"account_id": {
"description": "Account ID (uses default from config if not provided)",
"type": "string"
},
"cursor": {
"description": "Cursor for pagination",
"type": "string"
},
"limit": {
"description": "Maximum number of keys to return (default: 1000)",
"type": "number"
},
"namespace_id": {
"description": "The KV namespace ID",
"type": "string"
},
"prefix": {
"description": "Filter keys by prefix",
"type": "string"
}
},
"required": [
"namespace_id"
],
"type": "object"
}
Implementation Reference
- The handler function implementing the list_kv_keys tool. It constructs API parameters from input args and calls _make_request to fetch keys from Cloudflare Workers KV namespace.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, )
- Input schema for list_kv_keys tool defining parameters: account_id (optional), namespace_id (required), prefix, limit, cursor.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:351-380 (registration)Tool registration in list_tools(): defines name, description, and inputSchema for list_kv_keys.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)Dispatch in call_tool() that invokes the _list_kv_keys handler when tool name is list_kv_keys.elif name == "list_kv_keys": result = await self._list_kv_keys(arguments)