Skip to main content
Glama
LiusCraft

Superset MCP Server

by LiusCraft

list-tables

Retrieve a list of all tables within a specified database and schema using the Superset MCP Server. Simplify database exploration by accessing structured table information for efficient querying and analysis.

Instructions

获取指定数据库的表列表

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
databaseIdYes数据库ID
schemaNoSchema名称

Implementation Reference

  • src/index.ts:343-417 (registration)
    Registration of the "list-tables" MCP tool, including input schema (databaseId: number, schema?: string) and the complete inline handler function that fetches tables from cache for the given database and optional schema, formats and returns them as text.
    server.tool(
      "list-tables",
      "获取指定数据库的表列表",
      {
        databaseId: z.number().describe("数据库ID"),
        schema: z.string().describe("Schema名称").optional(),
      },
      async ({ databaseId, schema}) => {
        try {
          // 如果缓存为空,初始化缓存
          if (databasesCache.length === 0) {
            initializeCache();
            return {
              content: [
                {
                  type: "text",
                  text: "初始化缓存中...",
                },
              ],
            };
          }
          
          const database = databasesCache.find(db => db.id === databaseId);
          if (!database) {
            return {
              content: [
                {
                  type: "text",
                  text: `找不到ID为 ${databaseId} 的数据库`,
                },
              ],
            };
          }
          
          // 获取表列表
          let tables = tablesCache.get(databaseId);
          // 如果提供了schema,则过滤表
          if (tables && schema) {
            tables = tables.filter(table => table.schema === schema);
          }
          if (!tables || tables.length === 0) {
            // 如果缓存中没有,尝试重新获取
            return {
              content: [
                {
                  type: "text",
                  text: `数据库 ${database.database_name} 中没有找到表`,
                },
              ],
            };
          }
          
          const tablesList = tables.map(table => `Schema: ${table.schema}, 表名: ${table.name}`).join("\n");
          
          return {
            content: [
              {
                type: "text",
                text: `数据库 ${database.database_name} 的表列表:\n\n${tablesList}`,
              },
            ],
          };
        } catch (error) {
          console.error("获取表列表失败:", error);
          return {
            content: [
              {
                type: "text",
                text: `获取表列表失败: ${(error as Error).message}`,
              },
            ],
          };
        }
      }
    );
  • The handler function for the list-tables tool. It initializes cache if needed, finds the database, retrieves tables from cache, filters by schema if provided, and returns a formatted text list of tables.
    async ({ databaseId, schema}) => {
      try {
        // 如果缓存为空,初始化缓存
        if (databasesCache.length === 0) {
          initializeCache();
          return {
            content: [
              {
                type: "text",
                text: "初始化缓存中...",
              },
            ],
          };
        }
        
        const database = databasesCache.find(db => db.id === databaseId);
        if (!database) {
          return {
            content: [
              {
                type: "text",
                text: `找不到ID为 ${databaseId} 的数据库`,
              },
            ],
          };
        }
        
        // 获取表列表
        let tables = tablesCache.get(databaseId);
        // 如果提供了schema,则过滤表
        if (tables && schema) {
          tables = tables.filter(table => table.schema === schema);
        }
        if (!tables || tables.length === 0) {
          // 如果缓存中没有,尝试重新获取
          return {
            content: [
              {
                type: "text",
                text: `数据库 ${database.database_name} 中没有找到表`,
              },
            ],
          };
        }
        
        const tablesList = tables.map(table => `Schema: ${table.schema}, 表名: ${table.name}`).join("\n");
        
        return {
          content: [
            {
              type: "text",
              text: `数据库 ${database.database_name} 的表列表:\n\n${tablesList}`,
            },
          ],
        };
      } catch (error) {
        console.error("获取表列表失败:", error);
        return {
          content: [
            {
              type: "text",
              text: `获取表列表失败: ${(error as Error).message}`,
            },
          ],
        };
      }
    }
  • Input schema for list-tables tool using Zod: requires databaseId (number), optional schema (string).
    {
      databaseId: z.number().describe("数据库ID"),
      schema: z.string().describe("Schema名称").optional(),
    },
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 for behavioral disclosure. It states what the tool does but doesn't describe behavioral traits like whether this is a read-only operation, potential rate limits, authentication requirements, error conditions, or return format. For a tool with zero annotation coverage, this leaves significant gaps in understanding how it behaves.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence in Chinese that directly states the tool's purpose without any wasted words. It's appropriately sized and front-loaded, with every word contributing to understanding what the tool does.

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 tool has no annotations, no output schema, and the description provides only basic purpose without behavioral context or usage guidance, the description is incomplete. For a tool that likely returns structured data (table lists), the lack of information about return format, error handling, or operational constraints leaves significant gaps for an AI agent.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already documents both parameters (databaseId and schema) with descriptions. The tool description adds no additional parameter semantics beyond what's in the schema. According to scoring rules, when schema coverage is high (>80%), the baseline is 3 even with no parameter info in the description.

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: retrieving table lists for a specified database. It uses specific verbs ('获取' - get/retrieve) and resources ('表列表' - table lists), though it doesn't explicitly differentiate from sibling tools like list-databases or list-fields. The purpose is unambiguous 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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like list-databases (for listing databases) or list-fields (for listing fields within tables), nor does it specify prerequisites or appropriate contexts. The agent must infer usage from the tool name and parameters alone.

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

Related 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/LiusCraft/superset-mcp-server'

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