Skip to main content
Glama
adetxt

SQL MCP Server

by adetxt

Get Columns

get_columns

Retrieve column names from a database table by specifying the database type, connection string, and table name.

Instructions

Get list of column in a table

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
db_typeYes
connection_stringYes
table_nameYes

Implementation Reference

  • The async handler function that implements the get_columns tool. It connects to the database using Sequelize, queries the information_schema.columns (or equivalent for SQLite) based on db_type, maps the results to column objects, and returns them as JSON text content.
    async ({db_type, connection_string, table_name}) => {
      const sequelize = new Sequelize(connection_string, {
        dialect: db_type,
      })
    
      let result: any[] = []
      let columns: {
        name: string,
        type: string,
        nullable: string,
        default: string,
        key: string,
        extra: string,
      }[] = []
    
      switch (db_type) {
        case 'postgres':
          [result] = await sequelize.query(`SELECT * FROM information_schema.columns WHERE table_name = '${table_name}'`)
          columns = result.map((column: any) => ({
            name: column.column_name,
            type: column.data_type,
            nullable: column.is_nullable,
            default: column.column_default,
            key: column.column_key,
            extra: column.extra,
          }))
          break
        case 'mysql':
          [result] = await sequelize.query(`SELECT * FROM information_schema.columns WHERE table_name = '${table_name}'`)
          columns = result.map((column: any) => ({
            name: column.column_name,
            type: column.data_type,
            nullable: column.is_nullable,
            default: column.column_default,
            key: column.column_key,
            extra: column.extra,
          }))
          break
        case 'sqlite':
          [result] = await sequelize.query(`SELECT * FROM sqlite_master WHERE type = "table" AND name = '${table_name}'`)
          columns = result.map((column: any) => ({
            name: column.name,
            type: column.type,
            nullable: column.nullable,
            default: column.default,
            key: column.key,
            extra: column.extra,
          }))
          break
      }
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(columns),
          }
        ],
      }
    },
  • Input schema for the get_columns tool using Zod for validation of db_type (enum), connection_string, and table_name.
    {
      title: 'Get Columns',
      description: 'Get list of column in a table',
      inputSchema: {
        db_type: z.enum(['postgres', 'mysql', 'sqlite']),
        connection_string: z.string(),
        table_name: z.string(),
      },  
    },
  • src/tools.ts:51-122 (registration)
    The server.registerTool call that registers the get_columns tool, specifying its name, input schema, and handler function.
    server.registerTool(
      'get_columns',
      {
        title: 'Get Columns',
        description: 'Get list of column in a table',
        inputSchema: {
          db_type: z.enum(['postgres', 'mysql', 'sqlite']),
          connection_string: z.string(),
          table_name: z.string(),
        },  
      },
      async ({db_type, connection_string, table_name}) => {
        const sequelize = new Sequelize(connection_string, {
          dialect: db_type,
        })
    
        let result: any[] = []
        let columns: {
          name: string,
          type: string,
          nullable: string,
          default: string,
          key: string,
          extra: string,
        }[] = []
    
        switch (db_type) {
          case 'postgres':
            [result] = await sequelize.query(`SELECT * FROM information_schema.columns WHERE table_name = '${table_name}'`)
            columns = result.map((column: any) => ({
              name: column.column_name,
              type: column.data_type,
              nullable: column.is_nullable,
              default: column.column_default,
              key: column.column_key,
              extra: column.extra,
            }))
            break
          case 'mysql':
            [result] = await sequelize.query(`SELECT * FROM information_schema.columns WHERE table_name = '${table_name}'`)
            columns = result.map((column: any) => ({
              name: column.column_name,
              type: column.data_type,
              nullable: column.is_nullable,
              default: column.column_default,
              key: column.column_key,
              extra: column.extra,
            }))
            break
          case 'sqlite':
            [result] = await sequelize.query(`SELECT * FROM sqlite_master WHERE type = "table" AND name = '${table_name}'`)
            columns = result.map((column: any) => ({
              name: column.name,
              type: column.type,
              nullable: column.nullable,
              default: column.default,
              key: column.key,
              extra: column.extra,
            }))
            break
        }
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(columns),
            }
          ],
        }
      },
    )
Behavior1/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. However, it only states the action without revealing any behavioral traits such as read-only vs. destructive nature, authentication needs, rate limits, or output format. This is inadequate for a tool that interacts with databases, where such details are critical.

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 a single, efficient sentence ('Get list of column in a table') that is front-loaded and avoids unnecessary words. However, it contains a grammatical error ('column' should be 'columns'), which slightly detracts from clarity but does not significantly impact conciseness.

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 database interactions, lack of annotations, no output schema, and 0% schema description coverage, the description is incomplete. It does not address critical aspects like return values, error handling, or behavioral constraints, leaving significant gaps for an AI agent to understand and use the tool effectively.

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

Parameters1/5

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

The schema description coverage is 0%, meaning parameters are undocumented in the schema. The description adds no meaning beyond the schema, as it does not explain what 'db_type', 'connection_string', or 'table_name' represent, their formats, or usage. With 3 parameters and no compensation in the description, this fails to provide necessary semantic context.

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

Purpose3/5

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

The description states the tool's purpose ('Get list of column in a table'), which is clear but vague. It specifies the verb ('Get') and resource ('column in a table'), but lacks specificity about scope or differentiation from sibling tools like 'get_tables' (which likely lists tables rather than columns). However, it avoids tautology by not merely restating the name/title.

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. It does not mention sibling tools such as 'execute_query' or 'get_tables', nor does it specify prerequisites, exclusions, or contextual cues for selection. This leaves the agent without explicit direction on tool choice.

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/adetxt/sql-mcp'

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