Skip to main content
Glama
nolleh
by nolleh

copy_data

Insert rows into a Vertica table using the COPY command. Provide schema, table, and row data to bulk load records efficiently.

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 async function `copy_data` that implements the tool logic. It accepts schema, table, and data (list of rows), converts data to CSV, then uses Vertica's COPY FROM STDIN command to bulk-insert rows into the specified table, with permission checking and connection 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)
  • The `@mcp.tool()` decorator registers `copy_data` as an MCP tool on the FastMCP instance.
    @mcp.tool()
    async def copy_data(
  • The function signature serves as the schema: parameters are `ctx: Context`, `schema: str`, `table: str`, `data: List[List[Any]]` (the rows to insert), and returns `str`.
    async def copy_data(
        ctx: Context, schema: str, table: str, data: List[List[Any]],
    ) -> str:
  • The `finally` block ensures proper cleanup of the cursor and connection back to the pool.
    if cursor:
        cursor.close()
    if conn:
        manager.release_connection(conn)
Behavior3/5

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

With no annotations, the description carries full burden. It mentions using COPY command but lacks details on permissions, error handling, or side effects. Returns a status message but no specifics.

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?

Description is concise with Args and Returns sections, front-loading the purpose. No unnecessary sentences.

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 no output schema, no annotations, and 3 required params, the description is incomplete. It doesn't mention table existence requirements, data format constraints, or behavior on conflict.

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

Parameters2/5

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

Schema coverage is 0%, but description adds minimal meaning: 'vertica schema', 'Target table name', 'List of rows to insert'. The 'data' parameter lacks structure details beyond list of rows, leaving ambiguity.

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 it copies data into a Vertica table using COPY command, which is a specific verb and resource. It is easily distinguishable from siblings like execute_query or list_indexes.

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 vs alternatives like execute_query for single inserts. No prerequisites or exclusions are mentioned.

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