Skip to main content
Glama
RestDB

Codehooks.io MCP Server

by RestDB

export

Export data from a collection to CSV or JSONL format; returns content directly or saves to a file when filepath is specified.

Instructions

Export data from collection. If no filepath specified, returns the exported content directly. If filepath specified, saves to file inside Docker container.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collectionYesCollection to export
filepathNoFile to save export data (optional, will return content if not specified)
csvNoExport to CSV format
jsonlNoExport to JSONL format

Implementation Reference

  • Zod schema defining the input parameters for the 'export' tool: collection (required), filepath (optional file to save to), csv (optional boolean), jsonl (optional boolean).
    const exportSchema = z.object({
        collection: z.string().describe("Collection to export"),
        filepath: z.string().optional().describe("File to save export data (optional, will return content if not specified)"),
        csv: z.boolean().optional().describe("Export to CSV format"),
        jsonl: z.boolean().optional().describe("Export to JSONL format")
    });
  • src/index.ts:418-432 (registration)
    Tool registration entry for 'export' in the tools array, including its description and inputSchema (JSON Schema format) defining the same parameters.
    {
        name: "export",
        description: "Export data from collection. If no filepath specified, returns the exported content directly. If filepath specified, saves to file inside Docker container.",
        schema: exportSchema,
        inputSchema: {
            type: "object",
            properties: {
                collection: { type: "string", description: "Collection to export" },
                filepath: { type: "string", description: "File to save export data (optional, will return content if not specified)" },
                csv: { type: "boolean", description: "Export to CSV format" },
                jsonl: { type: "boolean", description: "Export to JSONL format" }
            },
            required: ["collection"]
        }
    },
  • Handler case for the 'export' tool. It constructs coho CLI arguments for the 'export' command with project, space, collection, and optional flags (filepath, csv, jsonl), then executes the command via executeCohoCommand and returns the result as text content.
    case "export": {
        const { collection, filepath, csv, jsonl } = args as ExportArgs;
        const exportArgs = [
            'export',
            '--project', config.projectId,
            '--space', config.space,
            '--collection', collection
        ];
    
        if (filepath) exportArgs.push('--file', filepath);
        if (csv) exportArgs.push('--csv');
        if (jsonl) exportArgs.push('--jsonl');
    
        const result = await executeCohoCommand(exportArgs);
        return {
            content: [
                {
                    type: "text",
                    text: result
                }
            ],
            isError: false
        };
    }
  • Helper function executeCohoCommand used by the export handler (and all other tools) to execute coho CLI commands with the 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}`);
        }
    }
Behavior3/5

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

Discloses two behavioral paths based on filepath (return vs save), which is useful. However, it omits details like whether saving overwrites, what is returned when filepath is specified, and any side effects. Without annotations, the description carries full burden and falls short.

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, no wasted words, front-loaded with the main action. Highly efficient.

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 explains the core behavior but lacks details on output format (when returned), error handling, and behavior when multiple format flags are set. Given no output schema and no annotations, more completeness would be beneficial.

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

Parameters4/5

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

Schema coverage is 100%, so parameters have descriptions. The description adds value by explaining the conditional behavior of filepath (return vs save), which is beyond what the schema provides. However, it does not elaborate on csv and jsonl beyond their schema descriptions.

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?

Clearly states 'Export data from collection' with a specific verb and resource, and distinguishes two modes of operation (return vs save to file). This sets it apart from sibling tools like 'import' or 'query_collection'.

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 like 'query_collection', or any prerequisites or exclusions. The description only states what it does, not when to choose it.

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