Skip to main content
Glama
blitzstermayank

Teradata MCP Server

base_tablePreview

Preview data samples and table structure from Teradata databases to verify content and schema before analysis or querying.

Instructions

This function returns data sample and inferred structure from a database table or view via SQLAlchemy, bind parameters if provided (prepared SQL), and return the fully rendered SQL (with literals) in metadata.

Arguments: table_name - table or view name database_name - Database name

Returns: ResponseType: formatted response with query results + metadata

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
table_nameYes
database_nameNo

Implementation Reference

  • The handler function that implements the core logic of the base_tablePreview tool. It executes 'SELECT TOP 5 * FROM table' to fetch a sample of data, extracts column information, builds metadata, and returns a formatted response using create_response.
    def handle_base_tablePreview(conn: TeradataConnection, table_name: str, database_name: str | None = None, *args, **kwargs):
        """
        This function returns data sample and inferred structure from a database table or view via SQLAlchemy, bind parameters if provided (prepared SQL), and return the fully rendered SQL (with literals) in metadata.
    
        Arguments:
          table_name - table or view name
          database_name - Database name
    
        Returns:
          ResponseType: formatted response with query results + metadata
        """
        logger.debug(f"Tool: handle_base_tablePreview: Args: tablename: {table_name}, databasename: {database_name}")
    
        if database_name is not None:
            table_name = f"{database_name}.{table_name}"
        with conn.cursor() as cur:
            cur.execute(f'select top 5 * from {table_name}')
            columns = cur.description
            sample = rows_to_json(cur.description, cur.fetchall())
    
            metadata = {
                "tool_name": "base_tablePreview",
                "database": database_name,
                "table_name": table_name,
                "columns": [
                    {
                        "name": c[0],
                        "type": c[1].__name__ if hasattr(c[1], '__name__') else str(c[1]),
                        "length": c[3]
                    }
                    for c in columns
                ],
                "sample_size": len(sample)
            }
            logger.debug(f"Tool: handle_base_tablePreview: metadata: {metadata}")
            return create_response(sample, metadata)
  • Dynamic registration loop that discovers all 'handle_*' functions from loaded tool modules and registers them as MCP tools. The tool 'base_tablePreview' is registered from 'handle_base_tablePreview' by stripping the 'handle_' prefix and using the function's docstring as description.
    all_functions = module_loader.get_all_functions()
    for name, func in all_functions.items():
        if not (inspect.isfunction(func) and name.startswith("handle_")):
            continue
        tool_name = name[len("handle_"):]
        if not any(re.match(p, tool_name) for p in config.get('tool', [])):
            continue
        wrapped = make_tool_wrapper(func)
        mcp.tool(name=tool_name, description=wrapped.__doc__)(wrapped)
        logger.info(f"Created tool: {tool_name}")
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions returning 'data sample and inferred structure' and 'fully rendered SQL (with literals) in metadata', which gives some behavioral insight. However, it lacks details on sample size, structure inference method, error handling, permissions required, or performance implications, leaving significant gaps for a tool that interacts with databases.

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 stated first. The 'Arguments' and 'Returns' sections add structure, though 'ResponseType' is vague. No redundant sentences are present, making it efficient.

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 annotations, 0% schema coverage, and no output schema, the description is incomplete. It hints at outputs ('data sample', 'inferred structure', 'metadata') but lacks specifics on format or content. For a database tool with two parameters and complex behavior, this leaves too much undefined for reliable agent use.

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 description coverage is 0%, so the description must compensate. It lists parameters 'table_name' and 'database_name' with brief notes ('table or view name', 'Database name'), but adds minimal semantic value beyond the schema's titles. It doesn't explain format expectations, constraints, or how null database_name is handled, failing to adequately cover the parameters.

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 tool's purpose: 'returns data sample and inferred structure from a database table or view via SQLAlchemy'. It specifies the verb ('returns'), resource ('database table or view'), and mechanism ('via SQLAlchemy'), though it doesn't explicitly differentiate from siblings like base_tableList or base_readQuery.

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. With siblings like base_tableList (likely lists tables), base_readQuery (likely executes queries), and base_tableDDL (likely shows schema), the description offers no context for choosing this tool for previewing table data and structure.

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/blitzstermayank/MCP'

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