read_kv_value
Retrieve stored values from Cloudflare Workers KV by providing a namespace ID and key. Returns the associated value.
Instructions
Read a value from Workers KV storage by key. Returns the stored value.
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 | |
| key | Yes | The key to read |
Implementation Reference
- Tool schema definition for 'read_kv_value' tool, specifying input parameters: account_id (optional), namespace_id (required), and key (required).
Tool( name="read_kv_value", description="Read a value from Workers KV storage by key. Returns the stored value.", 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", }, "key": {"type": "string", "description": "The key to read"}, }, "required": ["namespace_id", "key"], }, - src/cloudflare_mcp_server/__init__.py:422-423 (registration)Registration of the 'read_kv_value' tool in the call_tool handler, routing to _read_kv_value method.
elif name == "read_kv_value": result = await self._read_kv_value(arguments) - Handler function that executes the 'read_kv_value' tool logic: makes a GET request to the Cloudflare API endpoint for reading a KV value, returns the raw response text.
async def _read_kv_value(self, args: dict) -> str: """Read KV value.""" 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.") url = f"{CLOUDFLARE_API_BASE}/accounts/{account_id}/storage/kv/namespaces/{args['namespace_id']}/values/{args['key']}" headers = {"Authorization": f"Bearer {self.api_token}"} response = await self.client.get(url, headers=headers) response.raise_for_status() return response.text