Files
wehub-resource-sync e3eb629236
Sync Labels / build (push) Has been cancelled
tests / unit tests (macos-latest) (push) Has been cancelled
tests / unit tests (ubuntu-latest) (push) Has been cancelled
tests / unit tests (windows-latest) (push) Has been cancelled
docs: make Chinese README the default
2026-07-13 11:09:23 +00:00

1113 lines
32 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!-- WEHUB_ZH_README -->
> [!NOTE]
> 本文档由 WeHub 基于上游 README 翻译整理,属于社区翻译,非官方中文文档。
> [English](./README.en.md) · [原始项目](https://github.com/googleapis/mcp-toolbox) · [上游 README](https://github.com/googleapis/mcp-toolbox/blob/HEAD/README.md)
> 原作者、版权与许可证归属以原始项目及本仓库 LICENSE 文件为准。
<div align="center">
![logo](./logo.png)
# MCP Toolbox for Databases
<a href="https://trendshift.io/repositories/25495" target="_blank"><img src="https://trendshift.io/api/badge/repositories/25495" alt="googleapis%2Fmcp-toolbox | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
[![Go Report Card](https://goreportcard.com/badge/github.com/googleapis/mcp-toolbox)](https://goreportcard.com/report/github.com/googleapis/mcp-toolbox)
[![License: Apache
2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Docs](https://img.shields.io/badge/Docs-MCP_Toolbox-blue)](https://mcp-toolbox.dev/)
[![Discord](https://img.shields.io/badge/Discord-%235865F2.svg?style=flat&logo=discord&logoColor=white)](https://discord.gg/Dmm69peqjh)
[![Medium](https://img.shields.io/badge/Medium-12100E?style=flat&logo=medium&logoColor=white)](https://medium.com/@mcp_toolbox)
[![Python SDK](https://img.shields.io/pypi/v/toolbox-core?logo=python&logoColor=white&label=Python%20SDK)](https://pypi.org/project/toolbox-core/)
[![JS/TS SDK](https://img.shields.io/npm/v/@toolbox-sdk/core?logo=javascript&logoColor=white&label=JS%20SDK)](https://www.npmjs.com/package/@toolbox-sdk/core)
[![Go SDK](https://img.shields.io/github/v/release/googleapis/mcp-toolbox-sdk-go?logo=go&logoColor=white&label=Go%20SDK)](https://pkg.go.dev/github.com/googleapis/mcp-toolbox-sdk-go)
[![Java SDK](https://img.shields.io/maven-central/v/com.google.cloud.mcp/mcp-toolbox-sdk-java?logo=apache-maven&logoColor=white&label=Java%20SDK)](https://mvnrepository.com/artifact/com.google.cloud.mcp/mcp-toolbox-sdk-java)
</div>
MCP Toolbox for Databases 是一款开源的 Model Context ProtocolMCP)服务器,可将你的 AI 智能体、IDE 和应用程序直接连接至企业数据库。
<p align="center">
<img src="docs/en/documentation/introduction/architecture.png" alt="architecture" width="50%"/>
</p>
它具有**双重用途**
1. **开箱即用的 MCP 服务器(构建时,Build-Time):** 使用我们*预构建的通用工具*,即可让 Gemini CLI、Google Antigravity、Claude Code、Codex 或其他 MCP 客户端即时连接你的数据库。无需编写样板代码,即可与数据对话、探索 schema 并生成代码。
2. **自定义工具框架(运行时,Run-Time):** 一套稳健的框架,用于为生产环境中的智能体构建专用、高安全性的 AI 工具。可安全、便捷地定义结构化查询、语义搜索和 NL2SQL 能力。
本 README 提供简要概览。如需全面了解,请参阅[完整文档](https://mcp-toolbox.dev/).
> [!IMPORTANT]
> **仓库名称更新:** `genai-toolbox` 仓库已正式更名为 `mcp-toolbox`。为确保本地环境反映新名称,你可以更新远程地址:
> `git remote set-url origin https://github.com/googleapis/mcp-toolbox.git`
> [!NOTE]
> 该解决方案最初名为「Gen AI Toolbox for Databases」(github.com/googleapis/genai-toolbox),因其最初开发早于 MCP,后已更名以与 MCP 兼容对齐。
<!-- TOC ignore:true -->
## 目录
- [为何选择 MCP Toolbox](#why-mcp-toolbox)
- [快速入门:预构建工具](#quick-start-prebuilt-tools)
- [快速入门:自定义工具](#quick-start-custom-tools)
- [安装并运行 Toolbox 服务器](#install--run-the-toolbox-server)
- [连接到 Toolbox](#connect-to-toolbox)
- [MCP 客户端](#mcp-client)
- [Toolbox SDK:与你的应用程序集成](#toolbox-sdks-integrate-with-your-application)
- [其他功能](#additional-features)
- [版本管理](#versioning)
- [贡献](#contributing)
- [社区](#community)
---
## 为何选择 MCP Toolbox
- **开箱即用的数据库访问:** 预构建的通用工具,可让你直接从 IDE 或 CLI 即时探索数据(例如 `list_tables``execute_sql`)。
- **自定义工具框架:** 使用你预定义的逻辑构建可用于生产环境的工具,并通过受限访问(Restricted Access)、结构化查询(Structured Queries)和语义搜索(Semantic Search)确保安全。
- **简化开发:** 用不到 10 行代码即可将工具集成到 Agent Development KitADK)、LangChain、LlamaIndex 或自定义智能体中。
- **更佳性能:** 开箱即用支持连接池、集成身份验证(IAM)和端到端可观测性(OpenTelemetry)。
- **增强安全性**:集成身份验证,更安全地访问你的数据。
- **端到端可观测性**:开箱即用的指标与追踪,内置 OpenTelemetry 支持。
---
## 快速入门:预构建工具
告别频繁切换上下文,让你的 AI 助手成为真正的协作开发者。通过 MCP Toolbox 将 IDE 连接到数据库,你可以用自然语言查询数据、自动化 schema 发现与管理,并生成具备数据库感知能力的代码。
你可以在任何兼容 MCP 的 IDE 或客户端(例如 Gemini CLI、Google Antigravity、Claude Code、Codex 等)中,通过配置 MCP 服务器来使用 Toolbox。
**预构建工具也可通过 [Google Antigravity MCP Store](https://antigravity.google/docs/mcp) 一键安装,使用更便捷。**
1. 将以下内容添加到你的客户端 MCP 配置文件(通常为 `mcp.json``claude_desktop_config.json`):
```json
{
"mcpServers": {
"toolbox-postgres": {
"command": "npx",
"args": [
"-y",
"@toolbox-sdk/server",
"--prebuilt=postgres",
"--stdio"
]
}
}
}
```
2. 设置相应的环境变量以完成连接,请参阅[预构建工具参考](https://mcp-toolbox.dev/documentation/configuration/prebuilt-configs/).
当你使用 `--prebuilt=<database>` 标志运行 Toolbox 时,即可即时获得与该数据库交互的标准工具。你也可以使用 `--prebuilt=<database>/<toolset>` 语法指定特定工具集(例如 `--prebuilt=postgres/data` 仅加载 SQL 工具)。
当前支持的数据库包括:
- **Google Cloud** AlloyDB、BigQuery、Cloud SQLPostgreSQL、MySQL、SQL Server)、Spanner、Firestore、Knowledge Catalog(原 Dataplex)。
- **其他数据库:** PostgreSQL、MySQL、[MariaDB](https://mcp-toolbox.dev/integrations/mariadb/source/), SQL Server、Oracle、MongoDB、Redis、Elasticsearch、CockroachDB、ClickHouse、Couchbase、Neo4j、Snowflake、Trino 等。
有关所有受支持数据库的可用工具及其能力的完整列表,请参阅[预构建工具参考](https://mcp-toolbox.dev/documentation/configuration/prebuilt-configs/).
*有关 Docker 或二进制文件等不同运行方式,请参见[安装并运行 Toolbox 服务器](#install--run-the-toolbox-server)一节。*
> [!TIP]
> 如需托管方案,[Google Cloud MCP Servers](https://cloud.google.com/blog/products/databases/managed-mcp-servers-for-google-cloud-databases)
> 提供带有预构建工具的托管 MCP 体验;你可以[在此了解两者差异](https://mcp-toolbox.dev/dev/reference/faq/).
---
## 快速入门:自定义工具
Toolbox 也可用作定制化工具的框架。
配置 Toolbox 的主要方式是通过 `tools.yaml` 文件。如果你有多个文件,可以使用 `--config
tools.yaml` 标志指定 Toolbox 加载哪一个。
你可以在
[Resources](https://mcp-toolbox.dev/documentation/configuration/).
中找到所有资源类型的更详细参考文档。
### Sources
`tools.yaml` 中的 `sources` 部分定义了 Toolbox 应能访问哪些数据源。大多数工具至少需要一个可执行的数据源。
```yaml
kind: source
name: my-pg-source
type: postgres
host: 127.0.0.1
port: 5432
database: toolbox_db
user: toolbox_user
password: my-password
```
有关配置不同类型数据源的更多详情,请参阅
[Sources](https://mcp-toolbox.dev/documentation/configuration/sources/).
### Tools
`tools.yaml` 中的 `tools` 部分定义了智能体可执行的操作:工具类型、影响的数据源、使用的参数等。
```yaml
kind: tool
name: search-hotels-by-name
type: postgres-sql
source: my-pg-source
description: Search for hotels based on name.
parameters:
- name: name
type: string
description: The name of the hotel.
statement: SELECT * FROM hotels WHERE name ILIKE '%' || $1 || '%';
```
有关如何配置不同类型工具的更多详情,请参阅
[Tools](https://mcp-toolbox.dev/documentation/configuration/tools/).
### Toolsets
你的 `tools.yaml` 中的 `toolsets` 部分允许你定义希望一起加载的工具组。
这对于按智能体(agent)或应用定义不同分组会很有用。
```yaml
kind: toolset
name: my_first_toolset
tools:
- my_first_tool
- my_second_tool
---
kind: toolset
name: my_second_toolset
tools:
- my_second_tool
- my_third_tool
```
### Prompts
`tools.yaml` 中的 `prompts` 部分定义了可用于
与 LLM 交互的提示词(prompts)。
```yaml
kind: prompt
name: code_review
description: "Asks the LLM to analyze code quality and suggest improvements."
messages:
- content: >
Please review the following code for quality, correctness,
and potential improvements: \n\n{{.code}}
arguments:
- name: "code"
description: "The code to review"
```
有关如何配置提示词的更多详情,请参阅
[Prompts](https://mcp-toolbox.dev/documentation/configuration/prompts/).
---
## 安装并运行 Toolbox 服务器
你可以使用[配置文件](#quick-start-custom-tools)直接运行 Toolbox
```sh
npx @toolbox-sdk/server --config tools.yaml
```
这会使用你的配置文件运行最新版本的 Toolbox 服务器。
> [!NOTE]
> 此方法优先考虑便利性,而非性能。
> 如需更标准、更可靠的安装方式,请使用二进制文件
> 或容器镜像,详见[安装并运行 Toolbox 服务器](#install--run-the-toolbox-server)。
### 安装 Toolbox
要获取最新版本,请查看 [releases 页面][releases],并按照
适用于你的操作系统和 CPU 架构的以下说明操作。
[releases]: https://github.com/googleapis/mcp-toolbox/releases
<details open>
<summary>Binary</summary>
将 Toolbox 安装为二进制文件:
<!-- {x-release-please-start-version} -->
> <details>
> <summary>Linux (AMD64)</summary>
>
> 在 Linux (AMD64) 上将 Toolbox 安装为二进制文件:
>
> ```sh
> # see releases page for other versions
> export VERSION=1.6.0
> curl -L -o toolbox https://storage.googleapis.com/mcp-toolbox-for-databases/v$VERSION/linux/amd64/toolbox
> chmod +x toolbox
> ```
>
> </details>
> <details>
> <summary>macOS (Apple Silicon)</summary>
>
> 在 macOS (Apple Silicon) 上将 Toolbox 安装为二进制文件:
>
> ```sh
> # see releases page for other versions
> export VERSION=1.6.0
> curl -L -o toolbox https://storage.googleapis.com/mcp-toolbox-for-databases/v$VERSION/darwin/arm64/toolbox
> chmod +x toolbox
> ```
>
> </details>
> <details>
> <summary>macOS (Intel)</summary>
>
> 在 macOS (Intel) 上将 Toolbox 安装为二进制文件:
>
> ```sh
> # see releases page for other versions
> export VERSION=1.6.0
> curl -L -o toolbox https://storage.googleapis.com/mcp-toolbox-for-databases/v$VERSION/darwin/amd64/toolbox
> chmod +x toolbox
> ```
>
> </details>
> <details>
> <summary>Windows (Command Prompt)</summary>
>
> 在 Windows (Command Prompt) 上将 Toolbox 安装为二进制文件:
>
> ```cmd
> :: see releases page for other versions
> set VERSION=1.6.0
> curl -o toolbox.exe "https://storage.googleapis.com/mcp-toolbox-for-databases/v%VERSION%/windows/amd64/toolbox.exe"
> ```
>
> </details>
> <details>
> <summary>Windows (PowerShell)</summary>
>
> 在 Windows (PowerShell) 上将 Toolbox 安装为二进制文件:
>
> ```powershell
> # see releases page for other versions
> $VERSION = "1.6.0"
> curl.exe -o toolbox.exe "https://storage.googleapis.com/mcp-toolbox-for-databases/v$VERSION/windows/amd64/toolbox.exe"
> ```
>
> </details>
> <details>
> <summary>Windows ARM64 (Command Prompt)</summary>
>
> 在 Windows ARM64 (Command Prompt) 上将 Toolbox 安装为二进制文件:
>
> ```cmd
> :: see releases page for other versions
> set VERSION=1.6.0
> curl -o toolbox.exe "https://storage.googleapis.com/mcp-toolbox-for-databases/v%VERSION%/windows/arm64/toolbox.exe"
> ```
>
> </details>
> <details>
> <summary>Windows ARM64 (PowerShell)</summary>
>
> 在 Windows ARM64 (PowerShell) 上将 Toolbox 安装为二进制文件:
>
> ```powershell
> # see releases page for other versions
> $VERSION = "1.6.0"
> curl.exe -o toolbox.exe "https://storage.googleapis.com/mcp-toolbox-for-databases/v$VERSION/windows/arm64/toolbox.exe"
> ```
>
> </details>
</details>
<details>
<summary>Container image</summary>
你也可以将 Toolbox 安装为容器:
```sh
# see releases page for other versions
export VERSION=1.6.0
docker pull us-central1-docker.pkg.dev/database-toolbox/toolbox/toolbox:$VERSION
```
</details>
<details>
<summary>Homebrew</summary>
在 macOS 或 Linux 上使用 Homebrew 安装 Toolbox
```sh
brew install mcp-toolbox
```
</details>
<details>
<summary>Compile from source</summary>
要从源码安装,请确保已安装最新版本的
[Go](https://go.dev/doc/install),,然后运行以下命令:
```sh
go install github.com/googleapis/mcp-toolbox@v1.6.0
```
<!-- {x-release-please-end} -->
</details>
<details>
<summary>Gemini CLI</summary>
查看 [Gemini CLI extensions](https://geminicli.com/extensions/),可将针对 AlloyDB、BigQuery 和 Cloud SQL 等特定数据库的预构建工具直接安装到 Gemini CLI 中。
```sh
# Install Gemini CLI
npm install -g @google/gemini-cli
# Install the extension
gemini extensions install https://github.com/gemini-cli-extensions/cloud-sql-postgres
# Run Gemini CLI
gemini
```
通过 Gemini CLI 使用自然语言与你的自定义工具交互。
```sh
# Install the extension
gemini extensions install https://github.com/gemini-cli-extensions/mcp-toolbox
```
</details>
### 运行 Toolbox
[配置](#quick-start-custom-tools)一个 `tools.yaml` 来定义你的工具,然后
执行 `toolbox` 以启动服务器:
<details open>
<summary>Binary</summary>
从二进制文件运行 Toolbox
```sh
./toolbox --config "tools.yaml"
```
> ⓘ Note
> Toolbox 默认启用动态重载。要禁用此功能,请使用
> `--disable-reload` 标志。
</details>
<details>
<summary>Container image</summary>
拉取[容器镜像](#install-toolbox)后运行服务器:
```sh
export VERSION=0.24.0 # Use the version you pulled
docker run -p 5000:5000 \
-v $(pwd)/tools.yaml:/app/tools.yaml \
us-central1-docker.pkg.dev/database-toolbox/toolbox/toolbox:$VERSION \
--config "/app/tools.yaml"
```
> ⓘ Note
> `-v` 标志会将你本地的 `tools.yaml` 挂载到容器中,`-p` 会将
> 容器的端口 `5000` 映射到主机的端口 `5000`。
</details>
<details>
<summary>Source</summary>
要直接从源码运行服务器,请进入项目根目录
并运行:
```sh
go run .
```
> ⓘ Note
> 此命令从源码运行项目,更适合开发与
> 测试。它**不会**将二进制文件编译到你的 `$GOPATH` 中。如果你希望
> 改为编译二进制文件,请参阅[开发者
> 文档](./DEVELOPER.md#building-the-binary)。
</details>
<details>
<summary>Homebrew</summary>
如果你使用 [Homebrew](https://brew.sh/), 安装了 Toolbox`toolbox`
二进制文件已在系统路径中可用。你可以使用相同的
命令启动服务器:
```sh
toolbox --config "tools.yaml"
```
</details>
<details>
<summary>NPM</summary>
无需手动下载二进制文件即可直接运行 Toolbox(需要 Node.js):
```sh
npx @toolbox-sdk/server --config tools.yaml
```
</details>
<details>
<summary>Gemini CLI</summary>
安装 [Gemini CLI extensions](https://geminicli.com/extensions/), 后,预构建工具将在使用时可用。
```sh
# Run Gemini CLI
gemini
# List extensions
/extensions list
# List MCP servers
/mcp list
```
</details>
你可以使用 `toolbox help` 查看完整的标志列表!要停止服务器,请发送
终止信号(在大多数平台上为 `ctrl+c`)。
如需了解在不同环境中部署的更多详细文档,请查阅 [Deploy Toolbox
章节](https://mcp-toolbox.dev/documentation/deploy-to/) 中的资源。
---
## 连接到 Toolbox
Toolbox 服务器启动并运行后,你可以将工具加载到兼容 MCPModel Context Protocol)的客户端或应用中。
### MCP 客户端
将以下配置添加到你的 MCP 客户端配置中:
```json
{
"mcpServers": {
"toolbox": {
"type": "http",
"url": "http://127.0.0.1:5000/mcp",
}
}
}
```
如需连接到特定 toolset,请将 url 替换为 "http://127.0.0.1:5000/mcp/{toolset_name}"。
### Toolbox SDK:与应用集成
Toolbox 客户端 SDK 提供了易于使用的构建模块和高级功能,用于将自定义应用连接到 MCP Toolbox 服务器。以下是适用于各种框架的客户端 SDK 列表:
<details open>
<summary>Python (<a href="https://github.com/googleapis/mcp-toolbox-sdk-python">Github</a>)</summary>
<br>
<blockquote>
<details open>
<summary>Core</summary>
1. 安装 [Toolbox Core SDK][toolbox-core]
```bash
pip install toolbox-core
```
1. 加载工具:
```python
from toolbox_core import ToolboxClient
# update the url to point to your server
async with ToolboxClient("http://127.0.0.1:5000") as client:
# these tools can be passed to your application!
tools = await client.load_toolset("toolset_name")
```
有关 Toolbox Core SDK 的更多详细使用说明,请参阅
[项目 README][toolbox-core-readme]。
[toolbox-core]: https://pypi.org/project/toolbox-core/
[toolbox-core-readme]: https://github.com/googleapis/mcp-toolbox-sdk-python/tree/main/packages/toolbox-core/README.md
</details>
<details>
<summary>LangChain / LangGraph</summary>
1. 安装 [Toolbox LangChain SDK][toolbox-langchain]
```bash
pip install toolbox-langchain
```
1. 加载工具:
```python
from toolbox_langchain import ToolboxClient
# update the url to point to your server
async with ToolboxClient("http://127.0.0.1:5000") as client:
# these tools can be passed to your application!
tools = client.load_toolset()
```
有关 Toolbox LangChain SDK 的更多详细使用说明,请参阅
[项目 README][toolbox-langchain-readme]。
[toolbox-langchain]: https://pypi.org/project/toolbox-langchain/
[toolbox-langchain-readme]: https://github.com/googleapis/mcp-toolbox-sdk-python/blob/main/packages/toolbox-langchain/README.md
</details>
<details>
<summary>LlamaIndex</summary>
1. 安装 [Toolbox Llamaindex SDK][toolbox-llamaindex]
```bash
pip install toolbox-llamaindex
```
1. 加载工具:
```python
from toolbox_llamaindex import ToolboxClient
# update the url to point to your server
async with ToolboxClient("http://127.0.0.1:5000") as client:
# these tools can be passed to your application!
tools = client.load_toolset()
```
有关 Toolbox Llamaindex SDK 的更多详细使用说明,请参阅
[项目 README][toolbox-llamaindex-readme]。
[toolbox-llamaindex]: https://pypi.org/project/toolbox-llamaindex/
[toolbox-llamaindex-readme]: https://github.com/googleapis/genai-toolbox-llamaindex-python/blob/main/README.md
</details>
</details>
</blockquote>
<details>
<summary>Javascript/Typescript (<a href="https://github.com/googleapis/mcp-toolbox-sdk-js">Github</a>)</summary>
<br>
<blockquote>
<details open>
<summary>Core</summary>
1. 安装 [Toolbox Core SDK][toolbox-core-js]
```bash
npm install @toolbox-sdk/core
```
1. 加载工具:
```javascript
import { ToolboxClient } from '@toolbox-sdk/core';
// update the url to point to your server
const URL = 'http://127.0.0.1:5000';
let client = new ToolboxClient(URL);
// these tools can be passed to your application!
const tools = await client.loadToolset('toolsetName');
```
有关 Toolbox Core SDK 的更多详细使用说明,请参阅
[项目 README][toolbox-core-js-readme]。
[toolbox-core-js]: https://www.npmjs.com/package/@toolbox-sdk/core
[toolbox-core-js-readme]: https://github.com/googleapis/mcp-toolbox-sdk-js/blob/main/packages/toolbox-core/README.md
</details>
<details>
<summary>LangChain / LangGraph</summary>
1. 安装 [Toolbox Core SDK][toolbox-core-js]
```bash
npm install @toolbox-sdk/core
```
2. 加载工具:
```javascript
import { ToolboxClient } from '@toolbox-sdk/core';
// update the url to point to your server
const URL = 'http://127.0.0.1:5000';
let client = new ToolboxClient(URL);
// these tools can be passed to your application!
const toolboxTools = await client.loadToolset('toolsetName');
// Define the basics of the tool: name, description, schema and core logic
const getTool = (toolboxTool) => tool(currTool, {
name: toolboxTool.getName(),
description: toolboxTool.getDescription(),
schema: toolboxTool.getParamSchema()
});
// Use these tools in your Langchain/Langraph applications
const tools = toolboxTools.map(getTool);
```
</details>
<details>
<summary>Genkit</summary>
1. 安装 [Toolbox Core SDK][toolbox-core-js]
```bash
npm install @toolbox-sdk/core
```
2. 加载工具:
```javascript
import { ToolboxClient } from '@toolbox-sdk/core';
import { genkit } from 'genkit';
// Initialise genkit
const ai = genkit({
plugins: [
googleAI({
apiKey: process.env.GEMINI_API_KEY || process.env.GOOGLE_API_KEY
})
],
model: googleAI.model('gemini-2.0-flash'),
});
// update the url to point to your server
const URL = 'http://127.0.0.1:5000';
let client = new ToolboxClient(URL);
// these tools can be passed to your application!
const toolboxTools = await client.loadToolset('toolsetName');
// Define the basics of the tool: name, description, schema and core logic
const getTool = (toolboxTool) => ai.defineTool({
name: toolboxTool.getName(),
description: toolboxTool.getDescription(),
schema: toolboxTool.getParamSchema()
}, toolboxTool)
// Use these tools in your Genkit applications
const tools = toolboxTools.map(getTool);
```
</details>
<details>
<summary>ADK</summary>
1. 安装 [Toolbox ADK SDK][toolbox-adk-js]
```bash
npm install @toolbox-sdk/adk
```
2. 加载工具:
```javascript
import { ToolboxClient } from '@toolbox-sdk/adk';
// update the url to point to your server
const URL = 'http://127.0.0.1:5000';
let client = new ToolboxClient(URL);
// these tools can be passed to your application!
const tools = await client.loadToolset('toolsetName');
```
有关 Toolbox ADK SDK 的更多详细使用说明,请参阅
[项目 README][toolbox-adk-js-readme]。
[toolbox-adk-js]: https://www.npmjs.com/package/@toolbox-sdk/adk
[toolbox-adk-js-readme]:
https://github.com/googleapis/mcp-toolbox-sdk-js/blob/main/packages/toolbox-adk/README.md
</details>
</details>
</blockquote>
<details>
<summary>Go (<a href="https://github.com/googleapis/mcp-toolbox-sdk-go">Github</a>)</summary>
<br>
<blockquote>
<details>
<summary>Core</summary>
1. 安装 [Toolbox Go SDK][toolbox-go]
```bash
go get github.com/googleapis/mcp-toolbox-sdk-go
```
2. 加载工具:
```go
package main
import (
"github.com/googleapis/mcp-toolbox-sdk-go/core"
"context"
)
func main() {
// Make sure to add the error checks
// update the url to point to your server
URL := "http://127.0.0.1:5000";
ctx := context.Background()
client, err := core.NewToolboxClient(URL)
// Framework agnostic tools
tools, err := client.LoadToolset("toolsetName", ctx)
}
```
有关 Toolbox Go SDK 更详细的使用说明,请参阅
[项目的 README][toolbox-core-go-readme]。
[toolbox-go]: https://pkg.go.dev/github.com/googleapis/mcp-toolbox-sdk-go/core
[toolbox-core-go-readme]: https://github.com/googleapis/mcp-toolbox-sdk-go/blob/main/core/README.md
</details>
<details>
<summary>LangChain Go</summary>
1. 安装 [Toolbox Go SDK][toolbox-go]
```bash
go get github.com/googleapis/mcp-toolbox-sdk-go
```
2. 加载工具:
```go
package main
import (
"context"
"encoding/json"
"github.com/googleapis/mcp-toolbox-sdk-go/core"
"github.com/tmc/langchaingo/llms"
)
func main() {
// Make sure to add the error checks
// update the url to point to your server
URL := "http://127.0.0.1:5000"
ctx := context.Background()
client, err := core.NewToolboxClient(URL)
// Framework agnostic tool
tool, err := client.LoadTool("toolName", ctx)
// Fetch the tool's input schema
inputschema, err := tool.InputSchema()
var paramsSchema map[string]any
_ = json.Unmarshal(inputschema, &paramsSchema)
// Use this tool with LangChainGo
langChainTool := llms.Tool{
Type: "function",
Function: &llms.FunctionDefinition{
Name: tool.Name(),
Description: tool.Description(),
Parameters: paramsSchema,
},
}
}
```
</details>
<details>
<summary>Genkit</summary>
1. 安装 [Toolbox Go SDK][toolbox-go]
```bash
go get github.com/googleapis/mcp-toolbox-sdk-go
```
2. 加载工具:
```go
package main
import (
"context"
"log"
"github.com/firebase/genkit/go/genkit"
"github.com/googleapis/mcp-toolbox-sdk-go/core"
"github.com/googleapis/mcp-toolbox-sdk-go/tbgenkit"
)
func main() {
// Make sure to add the error checks
// Update the url to point to your server
URL := "http://127.0.0.1:5000"
ctx := context.Background()
g := genkit.Init(ctx)
client, err := core.NewToolboxClient(URL)
// Framework agnostic tool
tool, err := client.LoadTool("toolName", ctx)
// Convert the tool using the tbgenkit package
// Use this tool with Genkit Go
genkitTool, err := tbgenkit.ToGenkitTool(tool, g)
if err != nil {
log.Fatalf("Failed to convert tool: %v\n", err)
}
log.Printf("Successfully converted tool: %s", genkitTool.Name())
}
```
</details>
<details>
<summary>Go GenAI</summary>
1. 安装 [Toolbox Go SDK][toolbox-go]
```bash
go get github.com/googleapis/mcp-toolbox-sdk-go
```
2. 加载工具:
```go
package main
import (
"context"
"encoding/json"
"github.com/googleapis/mcp-toolbox-sdk-go/core"
"google.golang.org/genai"
)
func main() {
// Make sure to add the error checks
// Update the url to point to your server
URL := "http://127.0.0.1:5000"
ctx := context.Background()
client, err := core.NewToolboxClient(URL)
// Framework agnostic tool
tool, err := client.LoadTool("toolName", ctx)
// Fetch the tool's input schema
inputschema, err := tool.InputSchema()
var schema *genai.Schema
_ = json.Unmarshal(inputschema, &schema)
funcDeclaration := &genai.FunctionDeclaration{
Name: tool.Name(),
Description: tool.Description(),
Parameters: schema,
}
// Use this tool with Go GenAI
genAITool := &genai.Tool{
FunctionDeclarations: []*genai.FunctionDeclaration{funcDeclaration},
}
}
```
</details>
<details>
<summary>OpenAI Go</summary>
1. 安装 [Toolbox Go SDK][toolbox-go]
```bash
go get github.com/googleapis/mcp-toolbox-sdk-go
```
2. 加载工具:
```go
package main
import (
"context"
"encoding/json"
"github.com/googleapis/mcp-toolbox-sdk-go/core"
openai "github.com/openai/openai-go"
)
func main() {
// Make sure to add the error checks
// Update the url to point to your server
URL := "http://127.0.0.1:5000"
ctx := context.Background()
client, err := core.NewToolboxClient(URL)
// Framework agnostic tool
tool, err := client.LoadTool("toolName", ctx)
// Fetch the tool's input schema
inputschema, err := tool.InputSchema()
var paramsSchema openai.FunctionParameters
_ = json.Unmarshal(inputschema, &paramsSchema)
// Use this tool with OpenAI Go
openAITool := openai.ChatCompletionToolParam{
Function: openai.FunctionDefinitionParam{
Name: tool.Name(),
Description: openai.String(tool.Description()),
Parameters: paramsSchema,
},
}
}
```
</details>
<details open>
<summary>ADK Go</summary>
1. 安装 [Toolbox Go SDK][toolbox-go]
```bash
go get github.com/googleapis/mcp-toolbox-sdk-go
```
1. 加载工具:
```go
package main
import (
"github.com/googleapis/mcp-toolbox-sdk-go/tbadk"
"context"
)
func main() {
// Make sure to add the error checks
// Update the url to point to your server
URL := "http://127.0.0.1:5000"
ctx := context.Background()
client, err := tbadk.NewToolboxClient(URL)
if err != nil {
return fmt.Sprintln("Could not start Toolbox Client", err)
}
// Use this tool with ADK Go
tool, err := client.LoadTool("toolName", ctx)
if err != nil {
return fmt.Sprintln("Could not load Toolbox Tool", err)
}
}
```
有关 Toolbox Go SDK 更详细的使用说明,请参阅
[项目的 README][toolbox-core-go-readme]。
</details>
</details>
</blockquote>
</details>
---
## 其他功能
### 使用 Toolbox UI 测试工具
要启动 Toolbox 的交互式 UI,请使用 `--ui` 标志。这使你能够测试
工具与 toolset,并支持授权参数等功能。要了解更多信息,
请访问 [Toolbox UI](https://mcp-toolbox.dev/documentation/configuration/toolbox-ui/).
```sh
./toolbox --ui
```
### 遥测(Telemetry
Toolbox 通过 OpenTelemetry 发出追踪(trace)和指标(metric)。使用 `--telemetry-otlp=<endpoint>`
可导出到任何兼容 OTLP 的后端,例如 Google Cloud Monitoring、Agnost AI 或
其他服务。详情请参阅[遥测文档](https://mcp-toolbox.dev/documentation/monitoring/export_telemetry/)。
### 生成 Agent Skill
`skills-generate` 命令允许你将 **toolset** 转换为符合 [Agent Skill 规范](https://agentskills.io/specification). 的 **Agent Skill**。这对于将工具以可移植的 skill 包形式分发非常有用。
```bash
toolbox --config tools.yaml skills-generate \
--name "my-skill" \
--toolset "my_toolset" \
--description "A skill containing multiple tools"
```
生成后,你可以将该 skill 安装到 Gemini CLI
```bash
gemini skills install ./skills/my-skill
```
更多详情,请参阅[生成 Agent Skill 指南](https://mcp-toolbox.dev/documentation/configuration/skills/).。
---
## 版本控制
MCP Toolbox for Databases 遵循[语义化版本(Semantic Versioning](https://semver.org/).。
公共 API 包括 Toolbox ServerCLI、配置清单和预构建 toolset)以及 Client SDK。
- **主版本(Major versions)**:当出现破坏性变更时递增,例如不兼容的 CLI 或清单变更。
- **次版本(Minor versions)**:在新增功能时递增,包括对预构建 toolset 或 beta 功能的修改。
- **补丁版本(Patch versions)**:在向后兼容的错误修复时递增。
更多详情,请参阅我们的[完整版本控制政策](https://mcp-toolbox.dev/reference/versioning/).。
---
## 贡献
欢迎贡献。请参阅 [CONTRIBUTING](CONTRIBUTING.md) 指南以开始参与。
有关搭建 Toolbox 本身开发环境的技术细节,请参阅 [DEVELOPER](DEVELOPER.md) 指南。
请注意,本项目发布时附带贡献者行为准则(Contributor Code of Conduct)。参与本项目即表示您同意遵守其条款。更多信息请参阅 [贡献者行为准则](CODE_OF_CONDUCT.md)。
---
## Community
加入我们的 [Discord 社区](https://discord.gg/GQrFB3Ec3W),与我们的开发者建立联系!