Skip to main content
Glama
get_tables.py1.5 kB
"""Get tables tool.""" from typing import Optional from fastmcp import Context from .base import MCPTool class GetTablesService(MCPTool): """Service to retrieve list of tables in a database.""" @property def name(self) -> str: return "get_tables" @property def description(self) -> str: return "Get list of all tables in a specific database" async def execute( self, ctx: Context, database: Optional[str] = None, server_name: Optional[str] = None, user: Optional[str] = None, password: Optional[str] = None, driver: Optional[str] = None, port: Optional[int] = None ) -> list[str]: """Get list of tables. Args: ctx: FastMCP context database: Database name server_name: Server hostname/address user: Database username password: Database password driver: ODBC driver name port: Server port Returns: list[str]: List of table names or error messages """ creds = self.creds_manager.get_from_context( ctx, user, password, server_name, database, driver, port ) if not creds.database: return ["Error: Database name is required"] if not creds.is_valid(): return ["Error: Missing credentials"] return self.inspector.get_tables(creds)

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

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