Skip to main content
Glama
RestDB

Codehooks.io MCP Server

by RestDB

kv_get

Retrieve key-value pairs from a keyspace, with pattern matching using wildcards.

Instructions

Retrieve key-value pair(s) from a space. Supports pattern matching with wildcards.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyNoKey to match, or key* to fetch list*
keyspaceNoKeyspace to scan
textNoOutput info as text line

Implementation Reference

  • Zod schema definition for kv_get tool, defining input parameters: key (optional, default '*'), keyspace (optional), and text (optional boolean).
    const kvGetSchema = z.object({
        key: z.string().optional().default("*").describe("Key to match, or key* to fetch list"),
        keyspace: z.string().optional().describe("Keyspace to scan"),
        text: z.boolean().optional().describe("Output info as text line"),
    });
  • src/index.ts:433-445 (registration)
    Tool registration entry for 'kv_get' in the tools array, with name, description (pattern matching with wildcards), and inputSchema mapping to the kvGetSchema.
    {
        name: "kv_get",
        description: "Retrieve key-value pair(s) from a space. Supports pattern matching with wildcards.",
        schema: kvGetSchema,
        inputSchema: {
            type: "object",
            properties: {
                key: { type: "string", description: "Key to match, or key* to fetch list", default: "*" },
                keyspace: { type: "string", description: "Keyspace to scan" },
                text: { type: "boolean", description: "Output info as text line" }
            }
        }
    },
  • Handler implementation for kv_get: extracts args (key, keyspace, text), builds coho CLI 'get' command with project/space flags, executes via executeCohoCommand, and returns the result as text content.
    case "kv_get": {
        const { key = "*", keyspace, text } = args as KvGetArgs;
        const getArgs = [
            'get',
            '--project', config.projectId,
            '--space', config.space,
            key
        ];
    
        if (keyspace) getArgs.push('--keyspace', keyspace);
        if (text) getArgs.push('--text');
    
        const result = await executeCohoCommand(getArgs);
        return {
            content: [
                {
                    type: "text",
                    text: result
                }
            ],
            isError: false
        };
    }
  • Helper function executeCohoCommand that runs the coho CLI tool with given arguments and admin token, sanitizing output to avoid token exposure.
    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}`);
        }
    }
  • src/index.ts:199-204 (registration)
    Type inference for KvGetArgs derived from the Zod schema, used in the handler to type the parsed arguments.
    type KvGetArgs = z.infer<typeof kvGetSchema>;
    type KvSetArgs = z.infer<typeof kvSetSchema>;
    type KvDelArgs = z.infer<typeof kvDelSchema>;
    type LogArgs = z.infer<typeof logSchema>;
    type DocsArgs = z.infer<typeof docsSchema>;
    type CollectionArgs = z.infer<typeof collectionSchema>;
Behavior2/5

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

With no annotations, the description should disclose read-only nature, effects, and limitations. It only states retrieval and pattern matching, omitting behavior for missing keys, result format, or resource consumption.

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 that is concise and front-loaded, with no unnecessary words.

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?

Simple tool, but lacking details on pagination, multiple matches, or error handling. Without output schema, description should clarify return format.

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 description coverage is 100%, so the description adds no new meaning beyond what the schema already provides. Baseline score of 3 applies.

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 tool retrieves key-value pairs and supports wildcard pattern matching, distinguishing it from sibling tools like kv_set and kv_del.

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 this tool versus alternatives (e.g., kv_del for deletion). Does not mention prerequisites or when not to use.

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