Skip to main content
Glama
RestDB

Codehooks.io MCP Server

by RestDB

collection

List all collections in a specified project space, with options for JSON output and including system collections.

Instructions

Show collections for space. Lists all collections available in the current space.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectNoProject name
jsonNoJSON output format
sysNoShow system collections

Implementation Reference

  • Schema definition for the 'collection' tool. Defines input parameters: project (optional), json (optional boolean), sys (optional boolean to show system collections).
    const collectionSchema = z.object({
        project: z.string().optional().describe("Project name"),
        json: z.boolean().optional().describe("JSON output format"),
        sys: z.boolean().optional().describe("Show system collections")
    });
  • src/index.ts:498-510 (registration)
    Tool registration entry for 'collection' in the tools array. Defines name='collection', description='Show collections for space', and maps to the collectionSchema for input validation.
    {
        name: "collection",
        description: "Show collections for space. Lists all collections available in the current space.",
        schema: collectionSchema,
        inputSchema: {
            type: "object",
            properties: {
                project: { type: "string", description: "Project name" },
                json: { type: "boolean", description: "JSON output format" },
                sys: { type: "boolean", description: "Show system collections" }
            }
        }
    }
  • Handler implementation for the 'collection' tool. Builds CLI arguments to call 'coho collection' with project, space, json, and sys flags, then executes via executeCohoCommand and returns the result.
    case "collection": {
        const { project, json, sys } = args as CollectionArgs;
        const collectionArgs = [
            'collection',
            '--project', project || config.projectId,
            '--space', config.space
        ];
    
        if (json) collectionArgs.push('--json');
        if (sys) collectionArgs.push('--sys');
    
        const result = await executeCohoCommand(collectionArgs);
        return {
            content: [
                {
                    type: "text",
                    text: result
                }
            ],
            isError: false
        };
    }
  • TypeScript type inference for CollectionArgs using z.infer<typeof collectionSchema>.
    type CollectionArgs = z.infer<typeof collectionSchema>;
  • Helper function executeCohoCommand used by the 'collection' tool handler to execute CLI commands with admin token sanitization.
    // Helper function to execute coho CLI commands
    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}`);
        }
    }
Behavior3/5

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

The description implies a read-only operation ('Show', 'Lists') but does not explicitly state no modifications occur. With no annotations, the agent must infer safety. A direct statement would improve transparency.

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 with no unnecessary words. The purpose is front-loaded and every sentence adds value. No fluff or repetition.

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 is adequate for a simple listing tool but lacks details on return format (e.g., list of names or full objects) and does not mention pagination or limits, which could affect agent expectations.

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?

Input schema covers 100% of parameters with brief descriptions. The tool description adds no additional meaning beyond what is already in the schema, so baseline score of 3 applies.

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

Purpose4/5

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

The description clearly states the tool lists collections in the current space (verb+resource). However, it does not differentiate from sibling tools like query_collection, which might also list collections with filtering.

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 is provided on when to use this tool versus alternatives such as query_collection or other listing tools. The context 'current space' is implied but no exclusions are given.

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