Skip to main content
Glama
AnuragRai017

Database Updater MCP Server

update_database

Update database tables from CSV or Excel files by specifying file path, database type, connection string, and target table name.

Instructions

Update the database from a CSV or Excel file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesPath to the CSV or Excel file
databaseTypeYesType of database (e.g., PostgreSQL, MySQL, MongoDB, SQLite)
connectionStringYesConnection string for the database
tableNameYesName of the table to update

Implementation Reference

  • Handler for executing the 'update_database' tool: validates arguments, parses CSV/Excel file, parses connection string, logs update (placeholder for actual DB update), returns success message.
    case "update_database": {
        const filePath = String(request.params.arguments?.filePath);
        const databaseType = String(request.params.arguments?.databaseType);
        const connectionString = String(request.params.arguments?.connectionString);
        const tableName = String(request.params.arguments?.tableName);
    
        if (!filePath || !databaseType || !connectionString || !tableName) {
            throw new McpError(ErrorCode.InvalidParams, "File path, database type, connection string, and table name are required");
        }
    
        try {
            const fileExtension = filePath.split('.').pop()?.toLowerCase();
            let results: any[] = [];
    
            if (fileExtension === 'csv') {
                results = await parseCsvFile(filePath);
            } else if (fileExtension === 'xlsx' || fileExtension === 'xls') {
                results = await parseExcelFile(filePath);
            } else {
                throw new McpError(ErrorCode.InvalidParams, "Unsupported file type. Only CSV and Excel files are supported.");
            }
    
            // Placeholder for database interaction logic
            const connectionDetails = parseConnectionString(connectionString);
            console.log(`Updating database of type ${databaseType} with connection details ${JSON.stringify(connectionDetails)} and table name ${tableName} with data:`, results);
    
            // Add database update logic here based on databaseType and connectionDetails
            // For example, you might use a library like 'pg' for PostgreSQL, 'mysql' for MySQL, or 'mongodb' for MongoDB
            // This is a placeholder, so for now, we'll just log the data
    
            return {
                content: [{
                    type: "text",
                    text: `Successfully updated database from ${filePath}`
                }]
            };
    
        } catch (error: any) {
            console.error("Error updating database:", error);
            throw new McpError(ErrorCode.InternalError, `Error updating database: ${error.message}`);
        }
    }
  • src/index.ts:125-150 (registration)
    Registration of the 'update_database' tool in ListToolsRequestSchema handler, including name, description, and input schema.
    {
      name: "update_database",
      description: "Update the database from a CSV or Excel file",
      inputSchema: {
        type: "object",
        properties: {
          filePath: {
            type: "string",
            description: "Path to the CSV or Excel file"
          },
           databaseType: {
            type: "string",
            description: "Type of database (e.g., PostgreSQL, MySQL, MongoDB, SQLite)"
          },
          connectionString: {
            type: "string",
            description: "Connection string for the database"
          },
          tableName: {
            type: "string",
            description: "Name of the table to update"
          }
        },
        required: ["filePath", "databaseType", "connectionString", "tableName"]
      }
    }
  • Helper function to parse CSV files into array of objects, used by update_database handler.
    async function parseCsvFile(filePath: string): Promise<any[]> {
        return new Promise((resolve, reject) => {
            const results: any[] = [];
            fs.createReadStream(filePath)
                .pipe(csvParser())
                .on('data', (data: any) => results.push(data))
                .on('end', () => resolve(results))
                .on('error', (error: any) => reject(error));
        });
    }
  • Helper function to parse Excel files into array of objects, used by update_database handler.
    async function parseExcelFile(filePath: string): Promise<any[]> {
        const workbook = XLSX.readFile(filePath);
        const sheetName = workbook.SheetNames[0];
        const worksheet = workbook.Sheets[sheetName];
        return XLSX.utils.sheet_to_json(worksheet);
    }
  • Helper function to parse database connection string into details object, used by update_database handler.
    function parseConnectionString(connectionString: string): any {
        // This is a basic example, you might need a more robust parser
        try {
            const url = new URL(connectionString);
            if (url.protocol === 'mongodb:') {
                return {
                    type: 'mongodb',
                    url: connectionString
                };
            } else {
                const parts = connectionString.split(';');
                const connectionDetails: any = {};
                parts.forEach(part => {
                    const [key, value] = part.split('=');
                    if (key && value) {
                        connectionDetails[key.trim()] = value.trim();
                    }
                });
                return connectionDetails;
            }
        } catch (e) {
            // If it's not a URL, assume it's a semicolon-separated string
            const parts = connectionString.split(';');
            const connectionDetails: any = {};
            parts.forEach(part => {
                const [key, value] = part.split('=');
                if (key && value) {
                    connectionDetails[key.trim()] = value.trim();
                }
            });
            return connectionDetails;
        }
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool updates a database, implying a mutation operation, but fails to describe critical behaviors such as required permissions, whether the update is destructive or additive, error handling, or any rate limits. This is a significant gap for a tool that performs database writes.

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?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It is front-loaded with the core action and resource, making it easy to parse. Every part of the sentence contributes essential information, earning its place.

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 database update tool with no annotations and no output schema, the description is incomplete. It lacks details on the update behavior (e.g., whether it overwrites or merges data), expected outcomes, error conditions, or security considerations. This leaves the agent with insufficient context for safe and effective use.

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?

The schema description coverage is 100%, so the input schema already documents all four parameters thoroughly. The description adds no additional meaning beyond what the schema provides, such as explaining how parameters interact or providing examples. This meets the baseline for high schema coverage but doesn't enhance parameter understanding.

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 ('Update') and resource ('the database'), specifying the source format ('from a CSV or Excel file'). It distinguishes from the sibling tool 'create_note' by focusing on database operations rather than note creation. However, it doesn't specify what 'update' entails (e.g., insert, upsert, replace), keeping it from a perfect 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?

The description provides no guidance on when to use this tool versus alternatives, prerequisites, or exclusions. It mentions the source file types but doesn't explain when this tool is appropriate compared to other database operations or data import methods. This lack of context leaves the agent with minimal usage direction.

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/AnuragRai017/database-updater-MCP-Server'

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