Skip to main content
Glama
ry-ops

Cloudflare MCP Server

by ry-ops

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

TableJSON Schema
NameRequiredDescriptionDefault
account_idNoAccount ID (uses default from config if not provided)
namespace_idYesThe KV namespace ID
prefixNoFilter keys by prefix
limitNoMaximum number of keys to return (default: 1000)
cursorNoCursor 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"],
        },
    ),
  • 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)
  • The tool registration in list_tools() with name='list_kv_keys'.
    name="list_kv_keys",
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description provides behavioral traits: supports pagination and prefix filtering. It honestly represents a read operation. However, it does not disclose rate limits, authorization requirements, or behavior for empty results, but the core behavior is transparent.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, front-loaded with the main action, and no unnecessary words. Every sentence earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description omits return value details (e.g., format, pagination metadata). Given no output schema, this is a gap. Parameters are well-documented in schema, so overall adequate but not fully complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with descriptions for all 5 parameters. The description adds context by mentioning 'pagination and prefix filtering', which ties to the prefix, limit, and cursor parameters. This adds marginal value beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'List', the resource 'keys in a Workers KV namespace', and key features (pagination, prefix filtering). This distinguishes it from siblings like read_kv_value (single key) and list_kv_namespaces (list namespaces).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for listing keys with optional filtering and pagination but does not explicitly state when to use this tool over alternatives (e.g., when you need to enumerate keys vs reading a known key). No exclusion criteria or prerequisite conditions are mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ry-ops/cloudflare-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server