Skip to main content
Glama

podbc_get_tables

Retrieve a list of tables and their details from a specified database schema using SQLAlchemy connectivity. Automatically defaults to the connection schema if none is provided.

Instructions

Retrieve and return a list containing information about tables in specified schema, if empty uses connection default

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
SchemaNo
urlNo

Implementation Reference

  • Registers the 'podbc_get_tables' tool using the @mcp.tool decorator with name and description.
    @mcp.tool( name="podbc_get_tables", description="Retrieve and return a list containing information about tables in specified schema, if empty uses connection default" )
  • The handler function that connects to the ODBC database, executes cursor.tables() to fetch tables in the specified catalog/schema, collects TABLE_CAT, TABLE_SCHEM, TABLE_NAME into a list of dicts, and returns formatted JSON.
    def podbc_get_tables(Schema: Optional[str] = None, user:Optional[str]=None, password:Optional[str]=None, dsn:Optional[str]=None) -> str: """ Retrieve and return a list containing information about tables. If `schema` is None, returns tables for all schemas. If `schema` is not None, returns tables for the specified schema. Args: schema (Optional[str]): The name of the schema to retrieve tables for. If None, retrieves tables for all schemas. user (Optional[str]=None): Optional username. password (Optional[str]=None): Optional password. dsn (Optional[str]=None): Optional dsn name. Returns: str: A list containing information about tables. """ cat = "%" if Schema is None else Schema try: with get_connection(True, user, password, dsn) as conn: cursor = conn.cursor() rs = cursor.tables(table=None, catalog=cat, schema="%", tableType="TABLE"); results = [] for row in rs: results.append({"TABLE_CAT":row[0], "TABLE_SCHEM":row[1], "TABLE_NAME":row[2]}) return json.dumps(results, indent=2) except pyodbc.Error as e: logging.error(f"Error retrieving tables: {e}") raise

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/OpenLinkSoftware/mcp-sqlalchemy-server'

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