Skip to main content
Glama
nolleh
by nolleh

copy_data

Insert data into Vertica tables using the COPY command to transfer rows from external sources into database storage.

Instructions

Copy data into a Vertica table using COPY command.

Args:
    ctx: FastMCP context for progress reporting and logging
    schema: vertica schema to execute the copy against
    table: Target table name
    data: List of rows to insert

Returns:
    Status message indicating success or failure

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
schemaYes
tableYes
dataYes

Implementation Reference

  • The 'copy_data' tool handler function. It is registered via the @mcp.tool() decorator. Takes schema, table, and data (list of lists), converts data to CSV, and uses Vertica's COPY command to insert the data efficiently. Includes permission checks and proper resource management.
    @mcp.tool()
    async def copy_data(
        ctx: Context, schema: str, table: str, data: List[List[Any]],
    ) -> str:
        """Copy data into a Vertica table using COPY command.
    
        Args:
            ctx: FastMCP context for progress reporting and logging
            schema: vertica schema to execute the copy against
            table: Target table name
            data: List of rows to insert
    
        Returns:
            Status message indicating success or failure
        """
        await ctx.info(f"Copying {len(data)} rows to table: {table}")
    
        # Get or create connection manager
        manager = await get_or_create_manager(ctx)
        if not manager:
            return "Error: Failed to initialize database connection. Check configuration."
    
        # Check operation permissions
        if not manager.is_operation_allowed(schema, OperationType.INSERT):
            error_msg = f"INSERT operation not allowed for database {schema}"
            await ctx.error(error_msg)
            return error_msg
    
        conn = None
        cursor = None
        try:
            conn = manager.get_connection()
            cursor = conn.cursor()
    
            # Convert data to CSV string
            output = io.StringIO()
            writer = csv.writer(output, quoting=csv.QUOTE_MINIMAL)
            writer.writerows(data)
            output.seek(0)
    
            # Create COPY command
            copy_query = f"""COPY {table} FROM STDIN DELIMITER ',' ENCLOSED BY '\"'"""
            cursor.copy(copy_query, output.getvalue())
            conn.commit()
    
            success_msg = f"Successfully copied {len(data)} rows to {table}"
            await ctx.info(success_msg)
            return success_msg
        except Exception as e:
            error_msg = f"Error copying data: {str(e)}"
            await ctx.error(error_msg)
            return error_msg
        finally:
            if cursor:
                cursor.close()
            if conn:
                manager.release_connection(conn)
Behavior2/5

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

With no annotations provided, the description carries full burden but lacks behavioral details. It mentions 'progress reporting and logging' via ctx but doesn't disclose critical traits like whether this is a read/write operation, permission requirements, error handling, or rate limits. The return statement is vague ('Status message'), offering minimal insight into outcomes.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded with the core purpose in the first sentence. The Args and Returns sections are structured clearly, though the ctx explanation could be more concise. Overall, it avoids unnecessary verbosity.

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?

Given the complexity of a data copy operation with 3 parameters, no annotations, and no output schema, the description is insufficient. It lacks details on error conditions, performance implications, dependencies on sibling tools, or example usage, making it inadequate for safe and effective tool invocation.

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 0%, so the description must compensate. It lists parameters (ctx, schema, table, data) with brief explanations, adding some meaning beyond the bare schema. However, it doesn't detail data format, constraints, or examples, leaving gaps in understanding how to structure inputs effectively.

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 action ('Copy data') and target ('into a Vertica table using COPY command'), specifying both verb and resource. However, it doesn't differentiate from sibling tools like execute_query or stream_query, which might also handle data operations, so it doesn't reach the highest score.

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 like execute_query for similar data insertion tasks. The description only states what it does without context or exclusions, leaving the agent to infer usage scenarios.

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/nolleh/mcp-vertica'

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