新闻详情

新闻详情

首页 / 资讯中心 / 详情

使用 mcp-toolbox 的 looker-get-connection-tables 工具:从 Looker 连接中枚举表结构

发布时间:2026/9/14 18:31:28来源:尧图网络
使用 mcp-toolbox 的 looker-get-connection-tables 工具:从 Looker 连接中枚举表结构
使用 mcp-toolbox 的 looker-get-connection-tables 工具从 Looker 连接中枚举表结构【免费下载链接】mcp-toolboxMCP Toolbox for Databases is an open source MCP server for databases.项目地址: https://gitcode.com/GitHub_Trending/ge/mcp-toolboxlooker-get-connection-tables是 MCP Toolbox for Databases本仓库为 Looker 集成提供的一款只读 MCP 工具用于返回指定 Looker 数据库连接下某个 schema 内的全部表。本文以该工具的官方文档为核心结合仓库源码与测试完整讲解其参数语义、YAML 配置方式、底层 Looker SDK 调用链与返回结构并说明它在连接发现工具链中的实际用法帮助你在 Agent 场景中直接落地使用。工具定位Looker 连接元数据发现链的关键一环在 mcp-toolbox 的 Looker 集成中数据库元数据发现被拆分为一系列职责单一的只读工具looker-get-connection-tables处于连接 → schema → 表 → 列逐层下钻的中间位置looker-get-connections列出 Looker 中配置的全部数据库连接无参数looker-get-connection-schemas列出某连接下的 schema接受conn与可选的dblooker-get-connection-tables本文主角列出某 schema 下的全部表looker-get-connection-table-columns进一步列出表内的列信息如列名、数据类型、是否可空。相关工具的完整预置配置可在 looker-dev.yaml 中查看各工具通过type字段区分例如本工具的类型固定为looker-get-connection-tables。按照官方文档的定义该工具返回一个连接中的所有表接受必填的conn、schema参数以及可选的db参数见 looker-get-connection-tables.md。参数说明conn、schema 与可选的 db工具的运行时参数由Initialize阶段声明见 lookergetconnectiontables.go具体如下参数类型必填说明connstring是包含目标表的数据库连接名称来源于get_connections的输出schemastring是要枚举表的 schema 名称来源于get_connection_schemas的输出dbstring否可选的目标数据库名仅对支持多数据库的连接生效可用get_connections的supports_multiple_databases字段判断源码中的参数注册与文档完全一致lookergetconnectiontables.goconnParameter : parameters.NewStringParameter(conn, The connection containing the tables.) dbParameter : parameters.NewStringParameter(db, The optional database to search, parameters.WithStringRequired(false)) schemaParameter : parameters.NewStringParameter(schema, The schema containing the tables.)在Invoke阶段conn与schema会被强制断言为字符串若类型不符则返回 Agent 级错误db通过类型断言安全读取db, _ : mapParams[db].(string)为空时不会传入请求lookergetconnectiontables.go。YAML 配置示例完整字段与参数描述该工具是 MCP Toolbox 的预置/自定义工具之一通过声明式 YAML 注册。官方文档给出的最小可用配置如下kind: tool name: get_connection_tables type: looker-get-connection-tables source: looker-source description: | This tool retrieves a list of tables available within a specified database schema through a Looker connection. Parameters: - connection_name (required): The name of the database connection, obtained from get_connections. - schema (required): The name of the schema to list tables from, obtained from get_connection_schemas. - database (optional): The name of the database to filter by. Only applicable for connections that support multiple databases (check with get_connections). Output: A JSON array of strings, where each string is the name of an available table.字段说明来自官方文档的 Reference 表格与源码Config结构对应见 lookergetconnectiontables.go字段类型必填说明typestring是必须为looker-get-connection-tablessourcestring是所用 Looker 实例的 source 名称descriptionstring是传给 LLM 的工具描述直接影响模型的调用判断几点实践提示description是必填的。Initialize中若cfg.Description 会直接报错description is required for tool ...lookergetconnectiontables.go因此请在描述中写清参数来源如连接名取自get_connections与输出格式帮助 Agent 正确组织调用链。source必须指向兼容的 Looker source。ValidateSource会检查 source 是否实现了compatibleSource接口UseClientAuthorization、GetAuthTokenHeaderName、LookerApiSettings、GetLookerSDK不匹配会返回source is not a compatible type错误lookergetconnectiontables.go。字段不可随意扩展。单元测试验证了 YAML 解析的严格性若在配置中多写method字段解析会失败并提示unknown field method见 lookergetconnectiontables_test.go。该工具在预置配置中的实际写法可参考 looker-dev.yaml其description与官方文档示例一致source统一指向looker-source。底层实现从 Invoke 到 Looker SDK 的完整调用链当 Agent 调用该工具时执行路径如下核心逻辑见 lookergetconnectiontables.go类型校验从parameters.ParamValues解析出conn、schema、可选db获取 SDK调用source.GetLookerSDK(ctx, accessToken)得到 Looker v4 SDK 实例。在客户端授权end-user token模式下SDK 的 HTTP 传输层会注入Authorization与x-looker-appid: go-sdk请求头并支持透传X-Forwarded-For/X-Real-IP若未提供 access token 则报错no access token supplied with request见 looker.go构造请求组装v4.RequestConnectionTables{ConnectionName: conn, SchemaName: schema}仅在db非空时设置Database字段lookergetconnectiontables.go调用 API执行sdk.ConnectionTables(req, source.LookerApiSettings())即 Looker API v4 的GET /connections/{connection_name}/tables语义错误处理若 SDK 返回包含status401的错误统一转换为401 unauthorized其余错误经util.ProcessGeneralError归一化处理lookergetconnectiontables.go。返回结构不只是表名数组值得注意官方文档description中写给 LLM 的是A JSON array of strings简化语义但源码实际返回的是带 schema 分组的对象数组lookergetconnectiontables.go。每条记录结构为{ schema_name: demo_db, is_default: true, tables: [ { table_name: Employees, sql_escaped_name: Employees } ] }字段含义schema_name本次查询的 schema 名is_default该 schema 是否为连接的默认 schematables表对象数组每个对象含table_name表名与sql_escaped_nameSQL 转义后的表名可直接拼接进 SQL 语句。理解这一真实结构有助于你在上层编排时正确解析结果或为 LLM 编写更精确的description。测试验证单元测试与端到端集成测试仓库为该工具提供了两级测试保障配置解析单元测试lookergetconnectiontables_test.go验证最小 YAML 配置能被正确解析为Config结构包括Name、Description、Type、Source与空AuthRequired同时验证非法字段会被拒绝。端到端集成测试looker_integration_test.go一方面断言 MCP 工具清单中get_connection_tables暴露的参数与源码注册一致conn必填、db可选、schema必填且描述文本逐字匹配另一方面实际发起调用tests.RunToolInvokeParametersTest(t, get_connection_tables, []byte({conn: thelook, schema: demo_db}), wantResult) // wantResult Employees即对连接thelook、schemademo_db的调用返回了表Employees与同文件中对get_connection_schemas返回demo_db、get_connection_table_columns返回EmpID等列信息的断言构成了完整的连接发现链路验证looker_integration_test.go。在 Agent 工作流中的典型用法在实际的数据库问答或分析场景中looker-get-connection-tables通常不是孤立调用而是作为元数据发现流水线的一环get_connections → get_connection_schemas → get_connection_tables → get_connection_table_columns → 生成 SQL / LookML先用get_connections拿到连接列表通过supports_multiple_databases判断是否需要传db用get_connection_schemas枚举 schema再用本工具枚举目标 schema 下的表最后用get_connection_table_columns获取列级信息为后续查询生成提供完整元数据。小结looker-get-connection-tables是 mcp-toolbox Looker 集成中稳定、只读的元数据枚举工具配置上仅需type、source、description三个字段即可注册运行时通过connschema可选db驱动底层 Looker v4 SDK 的ConnectionTables接口返回值携带 schema 分组与sql_escaped_name便于直接衔接 SQL 生成。配合官方文档与 looker-dev.yaml 预置配置你可以在数分钟内将其接入自己的 MCP Server 配置为 Agent 补齐连接内有哪些表这一关键元数据能力。【免费下载链接】mcp-toolboxMCP Toolbox for Databases is an open source MCP server for databases.项目地址: https://gitcode.com/GitHub_Trending/ge/mcp-toolbox创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
网站建设高端定制企业官网
RELATED

相关资讯

更多精彩内容,欢迎继续阅读

较早相关资讯

最新相关资讯

生物医药创新生态:跨国药企与本土力量的协同研发 2026/9/14 19:55:35

生物医药创新生态:跨国药企与本土力量的协同研发

1. 项目背景解析:生物医药创新生态的协同进化拜耳Co.Lab共创平台的这次入驻事件,本质上是跨国药企与本土创新力量在研发模式上的深度重构。作为全球生命科学领域的百年巨头,拜耳近年来通过Co.Lab这种开放式创新平台,正在将传统的&…

阅读更多 →
批量域名查询技术:SEO与数据分析实战指南 2026/9/14 19:55:35

批量域名查询技术:SEO与数据分析实战指南

1. 批量域名查询的核心价值与应用场景 在SEO和数字营销领域,批量查询域名信息是每个从业者的基本功。我经手过的项目中,90%的SEO工作都需要从域名数据开始切入。不同于单次查询的手工作业,批量处理能带来三个维度的效率提升: 首先…

阅读更多 →
创意自行车网站模板:从zip解压到部署的完整指南 2026/9/14 19:55:34

创意自行车网站模板:从zip解压到部署的完整指南

简介:一个适用于自行车设计公司及创意机构官网展示的网站模板,采用简洁白色视觉风格,强调内容清晰与作品突出。模板内置产品展示、设计师介绍、项目案例等模块,适合具备基础HTML/CSS知识或使用WordPress、Joomla等系统进行二次编辑…

阅读更多 →
HTML5后台登录页模板:纯CSS可嵌入生产环境 2026/9/14 19:55:34

HTML5后台登录页模板:纯CSS可嵌入生产环境

简介:这是一套面向前端开发初学者与中级工程师的HTML5后台管理系统登录页面模板源码,聚焦于快速搭建美观、响应式、可直接集成的登录界面。资源包含16个文件,涵盖2个核心HTML页面(含index.html主入口)、2个结构化CSS样…

阅读更多 →
仓颉+Harness实战:从零跑通AI微服务编排 2026/9/14 19:55:34

仓颉+Harness实战:从零跑通AI微服务编排

1. 项目概述:为什么一个“Harness实战”值得专门写篇踩坑记录? 最近在用仓颉语言做模型能力编排时,真正把 deepseek harness 跑通、调通、跑稳,前后花了将近三周——不是因为代码写不出来,而是因为整个链路里埋了太多“…

阅读更多 →
综合能源系统低碳优化:P2G与碳捕集技术应用 2026/9/14 19:52:34

综合能源系统低碳优化:P2G与碳捕集技术应用

1. 项目背景与研究意义在"双碳"目标背景下,综合能源系统(Integrated Energy System, IES)的低碳化运行已成为能源领域的研究热点。热电联供(Combined Heat and Power, CHP)系统作为IES的核心组成部分,其传统运行模式往往以经济性为单一优化目标…

阅读更多 →

今日资讯

本周资讯

本月资讯

看完文章仍有疑问?

联系尧图顾问,获取一对一建站咨询

立即免费咨询 📞 400-888-8888
📞