Skip to main content
Glama
Teradata

Teradata MCP Server

Official
by Teradata

base_tablePreview

Preview sample data and structure from Teradata database tables or views to understand content before 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 core handler function for the 'base_tablePreview' tool. It executes a 'SELECT TOP 5 * FROM table' query to preview table data, extracts column metadata, converts rows to JSON, and returns a formatted response with sample data and metadata.
    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 of all 'handle_*' functions as MCP tools. Converts 'handle_base_tablePreview' to tool name 'base_tablePreview' and registers it with FastMCP using a wrapper that handles DB connection injection and QueryBand setting.
    # Register code tools via module loader
    module_loader = td.initialize_module_loader(config)
    if module_loader:
        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
            # Skip template tools (used for developer reference only)
            if tool_name.startswith("tmpl_"):
                logger.debug(f"Skipping template tool: {tool_name}")
                continue
            # Skip BAR tools if BAR functionality is disabled
            if tool_name.startswith("bar_") and not enableBAR:
                logger.info(f"Skipping BAR tool: {tool_name} (BAR functionality disabled)")
                continue
            # Skip chat completion tools if chat completion functionality is disabled
            if tool_name.startswith("chat_") and not enableChat:
                logger.info(f"Skipping chat completion tool: {tool_name} (chat completion functionality disabled)")
                continue
            wrapped = make_tool_wrapper(func)
            mcp.tool(name=tool_name, description=wrapped.__doc__)(wrapped)
            logger.info(f"Created tool: {tool_name}")
            logger.debug(f"Tool Docstring: {wrapped.__doc__}")
    else:
Behavior2/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. It mentions that the tool returns 'data sample and inferred structure' and includes 'fully rendered SQL (with literals) in metadata', which adds some behavioral context. However, it lacks details on permissions, rate limits, error handling, or what constitutes a 'sample' (e.g., row count). For a tool with no annotations, this is insufficient to fully inform the agent about its behavior.

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, starting with the core functionality. It uses three sentences without unnecessary fluff, though the second sentence about 'bind parameters' could be integrated more smoothly. Overall, it is efficient and structured, earning a high score for 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 no annotations, 0% schema coverage, and no output schema, the description is incomplete. It explains the basic purpose and mentions metadata, but lacks details on return format, error cases, or dependencies. For a tool with two parameters and complex behavior (SQL rendering, data sampling), this leaves significant gaps for the agent to operate effectively.

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 'table_name' and 'database_name' as arguments with brief explanations, but these merely restate the parameter names without adding meaningful semantics (e.g., format examples, constraints, or how 'database_name' interacts with 'table_name'). This does not adequately supplement the bare schema, leaving parameters poorly understood.

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 'returns data sample and inferred structure from a database table or view via SQLAlchemy', which provides a clear verb ('returns') and resource ('database table or view'). However, it does not distinguish this from sibling tools like base_readQuery or base_tableList, which might also retrieve data or list tables. The purpose is understandable but lacks sibling differentiation.

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 explicit guidance is provided on when to use this tool versus alternatives. The description mentions 'bind parameters if provided (prepared SQL)', but this is a technical detail rather than usage context. It does not indicate scenarios where this tool is preferred over siblings like base_readQuery or base_tableDDL, leaving the agent without clear selection criteria.

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/Teradata/teradata-mcp-server'

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