Skip to main content
Glama
RestDB

Codehooks.io MCP Server

by RestDB

kv_set

Set a key-value pair in a space with optional time-to-live and keyspace for organized, time-limited data storage.

Instructions

Set key-value pair in a space with optional TTL and keyspace.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYesKey to set
valYesValue to set
keyspaceNoKeyspace to use
ttlNoTime to live in millis for value
jsonNoOutput info as JSON (not table)

Implementation Reference

  • The handler for the 'kv_set' tool. It extracts key, val, keyspace, ttl, and json arguments, builds the CLI 'set' command with appropriate flags, executes it via 'executeCohoCommand', and returns the result as text content.
    case "kv_set": {
        const { key, val, keyspace, ttl, json } = args as KvSetArgs;
        const setArgs = [
            'set',
            '--project', config.projectId,
            '--space', config.space,
            key,
            val
        ];
    
        if (keyspace) setArgs.push('--keyspace', keyspace);
        if (ttl) setArgs.push('--ttl', ttl.toString());
        if (json) setArgs.push('--json');
    
        const result = await executeCohoCommand(setArgs);
        return {
            content: [
                {
                    type: "text",
                    text: result
                }
            ],
            isError: false
        };
    }
  • The Zod schema (kvSetSchema) defining input validation for 'kv_set': key (required string), val (required string), keyspace (optional string), ttl (optional number), json (optional boolean).
    const kvSetSchema = z.object({
        key: z.string().describe("Key to set"),
        val: z.string().describe("Value to set"),
        keyspace: z.string().optional().describe("Keyspace to use"),
        ttl: z.number().optional().describe("Time to live in millis for value"),
        json: z.boolean().optional().describe("Output info as JSON (not table)"),
    });
  • src/index.ts:446-461 (registration)
    Registration of the 'kv_set' tool in the tools array with name, description, schema reference, and inputSchema for JSON Schema exposure.
    {
        name: "kv_set",
        description: "Set key-value pair in a space with optional TTL and keyspace.",
        schema: kvSetSchema,
        inputSchema: {
            type: "object",
            properties: {
                key: { type: "string", description: "Key to set" },
                val: { type: "string", description: "Value to set" },
                keyspace: { type: "string", description: "Keyspace to use" },
                ttl: { type: "number", description: "Time to live in millis for value" },
                json: { type: "boolean", description: "Output info as JSON (not table)" }
            },
            required: ["key", "val"]
        }
    },
  • Helper function 'executeCohoCommand' used by kv_set handler to run the 'coho' CLI with sanitized arguments and admin token.
    async function executeCohoCommand(args: string[]): Promise<string> {
        const safeArgs = ['coho', ...args, '--admintoken', '***'];
        console.error(`Executing command: ${safeArgs.join(' ')}`);
        try {
            const { stdout, stderr } = await execFile('coho', [...args, '--admintoken', config.adminToken], {
                timeout: 120000 // 2 minutes timeout for CLI operations
            });
            if (stderr) {
                // Sanitize stderr before logging to avoid token exposure
                const safeSterr = stderr.replace(new RegExp(config.adminToken, 'g'), '***');
                console.error(`Command output to stderr:`, safeSterr);
            }
            console.error(`Command successful`);
            const result = stdout || stderr;
            // Sanitize result to ensure admin token is not exposed
            return result ? result.replace(new RegExp(config.adminToken, 'g'), '***') : result;
        } catch (error: any) {
            // Comprehensive sanitization of all error properties to avoid admin token exposure
            const sanitizeText = (text: string): string => text ? text.replace(new RegExp(config.adminToken, 'g'), '***') : text;
    
            const sanitizedMessage = sanitizeText(error?.message || 'Unknown error');
            const sanitizedCmd = sanitizeText(error?.cmd || '');
            const sanitizedStdout = sanitizeText(error?.stdout || '');
            const sanitizedStderr = sanitizeText(error?.stderr || '');
    
            // Log sanitized error details
            console.error(`Command failed: ${sanitizedMessage}`);
            if (sanitizedCmd) console.error(`Command: ${sanitizedCmd}`);
            if (sanitizedStdout) console.error(`Stdout: ${sanitizedStdout}`);
            if (sanitizedStderr) console.error(`Stderr: ${sanitizedStderr}`);
    
            // Return sanitized error message
            const errorDetails = [sanitizedMessage, sanitizedStderr].filter(Boolean).join(' - ');
            throw new McpError(ErrorCode.InvalidRequest, `Command failed: ${errorDetails}`);
        }
    }
Behavior2/5

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

No annotations provided; description fails to disclose side effects (e.g., overwriting existing keys), atomicity, or error handling. Only states basic operation.

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?

Single sentence with no extraneous words. Clear and efficient.

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

Completeness2/5

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

Despite 5 parameters and no output schema, description adds minimal context. No info on return values, ordering, or behavior beyond the schema.

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%, so baseline is 3. Description does not add additional semantic meaning beyond what schema already specifies for parameters.

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?

Description clearly states action (Set), resource (key-value pair), and optional features (TTL, keyspace). Distinguishes from siblings like kv_del and kv_get.

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

Usage Guidelines2/5

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

No guidance on when to use vs alternatives (e.g., kv_get for reading, kv_del for deletion). Context of use is implied but not explicit.

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/RestDB/codehooks-mcp-server'

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