read_query
Execute SQL queries to retrieve data from Bitable tables, enabling structured data access and analysis through the MCP server.
Instructions
read_query by sql
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes |
Implementation Reference
- src/bitable_mcp/server.py:57-65 (handler)The handler function that executes the 'read_query' tool. It runs the SQL query on the Bitable database via a connection pool, retrieves records and column names, and returns them as JSON.def read_query(sql: str) -> list[str]: with conn_pool.connect() as connection: cursor = connection.cursor() records = cursor.execute(sql).fetchall() columns = [t[0] for t in cursor.description or []] return json.dumps({ "columns": columns, "records": records, })
- src/bitable_mcp/server.py:53-56 (registration)Registers the 'read_query' tool with the MCP server using the @mcp.tool decorator, including name and description.@mcp.tool( name="read_query", description="read_query by sql", )