Skip to content

Commit 8f0460f

Browse files
committed
docs: Update repo-level README to only focus on which package to use.
1 parent 5ca7630 commit 8f0460f

File tree

1 file changed

+55
-254
lines changed

1 file changed

+55
-254
lines changed

README.md

Lines changed: 55 additions & 254 deletions
Original file line numberDiff line numberDiff line change
@@ -19,291 +19,92 @@ Databases or APIs) managed by Toolbox into your GenAI applications.
1919

2020
<!-- TOC -->
2121

22-
- [MCP Toolbox SDKs for Python](#mcp-toolbox-sdks-for-python)
23-
- [Overview](#overview)
24-
- [Available Packages](#available-packages)
25-
- [Quickstart](#quickstart)
26-
- [Core Concepts](#core-concepts)
27-
- [Connecting to Toolbox](#connecting-to-toolbox)
28-
- [Loading Tools](#loading-tools)
29-
- [Invoking Tools](#invoking-tools)
30-
- [Synchronous vs. Asynchronous Usage](#synchronous-vs-asynchronous-usage)
31-
- [Authenticating Tools](#authenticating-tools)
32-
- [When is Authentication Needed?](#when-is-authentication-needed)
33-
- [Supported Authentication Mechanisms](#supported-authentication-mechanisms)
34-
- [SDK Configuration](#sdk-configuration)
35-
- [Binding Parameter Values](#binding-parameter-values)
36-
- [Why Bind Parameters?](#why-bind-parameters)
37-
- [SDK Configuration](#sdk-configuration)
38-
- [Usage Comparison](#usage-comparison)
39-
- [Contributing](#contributing)
40-
- [License](#license)
41-
- [Support](#support)
22+
- [Overview](#overview)
23+
- [Which Package Should I Use?](#which-package-should-i-use)
24+
- [Available Packages](#available-packages)
25+
- [Getting Started](#getting-started)
26+
- [Contributing](#contributing)
27+
- [License](#license)
28+
- [Support](#support)
4229

4330
<!-- /TOC -->
4431

4532
## Overview
4633

47-
The Toolbox service provides a centralized way to manage and expose tools for
48-
use by LLMs. These SDKs act as clients for that service, abstracting away the
49-
API calls needed to fetch tool definitions and invoke them.
34+
The MCP Toolbox service provides a centralized way to manage and expose tools
35+
(like API connectors, database query tools, etc.) for use by GenAI applications.
36+
37+
These Python SDKs act as clients for that service. They handle the communication needed to:
38+
39+
* Fetch tool definitions from your running Toolbox instance.
40+
* Provide convenient Python objects or functions representing those tools.
41+
* Invoke the tools (calling the underlying APIs/services configured in Toolbox).
42+
* Handle authentication and parameter binding as needed.
43+
44+
By using these SDKs, you can easily leverage your Toolbox-managed tools directly
45+
within your Python applications or AI orchestration frameworks.
46+
47+
## Which Package Should I Use?
48+
49+
Choosing the right package depends on how you are building your application:
50+
51+
* [`toolbox-langchain`](https://github.com/googleapis/mcp-toolbox-sdk-python/tree/main/packages/toolbox-langchain):
52+
Use this package if you are building your application using the LangChain or
53+
LangGraph frameworks. It provides tools that are directly compatible with the
54+
LangChain ecosystem (`BaseTool` interface), simplifying integration.
55+
* [`toolbox-core`](https://github.com/googleapis/mcp-toolbox-sdk-python/tree/main/packages/toolbox-core):
56+
Use this package if you are not using LangChain/LangGraph or any other
57+
orchestration framework, or if you need a framework-agnostic way to interact
58+
with Toolbox tools (e.g., for custom orchestration logic or direct use in
59+
Python scripts).
5060

5161
## Available Packages
5262

53-
This repository hosts the following Python packages:
63+
This repository hosts the following Python packages. See the package-specific
64+
README for detailed installation and usage instructions:
5465

55-
| Package | Key Purpose | Integration | Path | Details (README) | PyPI Status |
66+
| Package | Target Use Case | Integration | Path | Details (README) | PyPI Status |
5667
| :------ | :---------- | :---------- | :---------------------- | :---------- | :---------
57-
| `toolbox-core` | Provides core, framework-agnostic tool handling | Use directly / Custom | `packages/toolbox-core/` | 📄 [View README](https://github.com/googleapis/mcp-toolbox-sdk-python/blob/main/packages/toolbox-core/README.md) | [![PyPI version](https://badge.fury.io/py/toolbox-core.svg)](https://badge.fury.io/py/toolbox-core) |
58-
| `toolbox-langchain` | Integrates Toolbox tools with the LangChain ecoystem | LangChain / LangGraph | `packages/toolbox-langchain/` | 📄 [View README](https://github.com/googleapis/mcp-toolbox-sdk-python/blob/main/packages/toolbox-langchain/README.md) | [![PyPI version](https://badge.fury.io/py/toolbox-langchain.svg)](https://badge.fury.io/py/toolbox-langchain) |
68+
| `toolbox-core` | Framework-agnostic / Custom applications | Use directly / Custom | `packages/toolbox-core/` | 📄 [View README](https://github.com/googleapis/mcp-toolbox-sdk-python/blob/main/packages/toolbox-core/README.md) | [![PyPI version](https://badge.fury.io/py/toolbox-core.svg)](https://badge.fury.io/py/toolbox-core) |
69+
| `toolbox-langchain` | LangChain / LangGraph applications | LangChain / LangGraph | `packages/toolbox-langchain/` | 📄 [View README](https://github.com/googleapis/mcp-toolbox-sdk-python/blob/main/packages/toolbox-langchain/README.md) | [![PyPI version](https://badge.fury.io/py/toolbox-langchain.svg)](https://badge.fury.io/py/toolbox-langchain) |
5970

60-
## Quickstart
71+
## Getting Started
6172

6273
To get started using Toolbox tools with an application, follow these general steps:
6374

64-
1. **Configure and Run the Toolbox Service:**
75+
1. **Set up and Run the Toolbox Service:**
6576

66-
For detailed instructions on setting up and running the Toolbox service
67-
itself, see: [**Toolbox Getting Started
77+
Before using the SDKs, you need the main MCP Toolbox service running. Follow
78+
the instructions here: [**Toolbox Getting Started
6879
Guide**](https://github.com/googleapis/genai-toolbox?tab=readme-ov-file#getting-started)
6980

70-
2. **Install the Toolbox SDK:**
71-
72-
Install the appropriate Python SDK package:
81+
2. **Install the Appropriate SDK:**
82+
83+
Choose the package based on your needs (see "[Which Package Should I Use?](#which-package-should-i-use)" above) and install it:
7384

7485
```bash
7586
# For the core, framework-agnostic SDK
7687
pip install toolbox-core
7788

7889
# OR
79-
90+
8091
# For LangChain/LangGraph integration
81-
# pip install toolbox-langchain
92+
pip install toolbox-langchain
8293
```
8394

84-
3. **Load Tools Using the SDK Client:**
95+
3. **Use the SDK:**
8596

86-
Once the service is running and the SDK is installed, use the
87-
`ToolboxClient` in your Python code to connect to the service and load the
88-
tools.
89-
90-
```py
91-
from toolbox_core import ToolboxClient
92-
# from toolbox_langchain import ToolboxClient
93-
94-
client = ToolboxClient("http://127.0.0.1:5000")
95-
96-
tools = await client.load_toolset("toolset_name")
97-
# tools = await client.aload_toolset("toolset_name")
98-
```
97+
Consult the README for your chosen package (linked in the "[Available
98+
Packages](#available-packages)" section above) for detailed instructions on
99+
how to connect the client, load tool definitions, invoke tools, configure
100+
authentication/binding, and integrate them into your application or
101+
framework.
99102

100103
> [!TIP]
101-
> For a complete, step-by-step walkthrough, please refer to the full tutorial:
102-
> [**Toolbox Quickstart
104+
> For a complete, end-to-end example including setting up the service and using
105+
> an SDK, see the full tutorial: [**Toolbox Quickstart
103106
> Tutorial**](https://googleapis.github.io/genai-toolbox/getting-started/local_quickstart)
104107

105-
## Core Concepts
106-
107-
The following concepts apply generally across the different SDK packages,
108-
although specific method names or object types might vary slightly. Refer to the
109-
individual package READMEs for precise details.
110-
111-
### Connecting to Toolbox
112-
113-
Initialize a client, pointing it to the URL where your Toolbox service is
114-
running.
115-
116-
```py
117-
from toolbox_core import ToolboxClient
118-
119-
# replace with your Toolbox service's URL
120-
client = ToolboxClient("http://127.0.0.1:5000")
121-
```
122-
123-
### Loading Tools
124-
125-
Fetch tool definitions from the Toolbox service. You can load individual tools
126-
by name or load all tools within a specific toolset (or all available toolsets).
127-
128-
```py
129-
# Load a single tool
130-
tool = await client.load_tool("my-tool")
131-
132-
# Load all tools in a specific toolset
133-
tools = await client.load_toolset("my-toolset")
134-
135-
# Load all tools from all toolsets
136-
all_tools = await client.load_toolset()
137-
```
138-
139-
> [!NOTE]
140-
> **Upcoming Feature (`v0.2.0`+):** Support for calling `client.load_toolset()`
141-
> without arguments will be introduced in `v0.2.0`.
142-
143-
### Invoking Tools
144-
145-
Loaded tools behave like callable Python objects or functions.
146-
147-
* **`toolbox-core`**: Async tools are `awaitable`, sync tools are called
148-
directly.
149-
```py
150-
result = await tool(param1="value1", param2="value2")
151-
```
152-
153-
* **`toolbox-langchain`**: Tools conform to LangChain's `BaseTool` interface
154-
and are typically invoked via `.invoke()` or `.ainvoke()`, often managed by
155-
a LangGraph agent.
156-
```py
157-
result = await tool.ainvoke({"param1": "value1", "param2": "value2"})
158-
```
159-
160-
### Synchronous vs. Asynchronous Usage
161-
162-
| Package | Loading Tools | Invoking Tools | Docs |
163-
| :---------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------- |
164-
| **`toolbox-core`** | **Async:**<br/>* **Class:** `ToolboxClient`<br/>* **Methods:** `await client.load_*`<br/><br/>**Sync:**<br/>* **Class:** `ToolboxSyncClient`<br/>* **Methods:** `client.load_*` | **Async:**<br/>* **Class:** `ToolboxTool`<br/>* **Invocation:** `await tool(...)`<br/><br/>**Sync:**<br/>* **Class:** `ToolboxSyncTool`<br/>* **Invocation:** `tool(...)` | [`toolbox-core` README](https://github.com/googleapis/mcp-toolbox-sdk-python/blob/main/packages/toolbox-core/README.md#synchronous-usage) |
165-
| **`toolbox-langchain`** | **Unified Class:** `ToolboxClient`<br/><br/>* **Async Methods:** `await client.aload_*`<br/><br/>* **Sync Methods:** `client.load_*` | **Unified Class:** `ToolboxTool`<br/><br/>* &nbsp;**Async Method:** `await tool.ainvoke()`<br/><br/>* &nbsp;**Sync Method:** `tool.invoke()` | [`toolbox-langchain` README](https://github.com/googleapis/mcp-toolbox-sdk-python/blob/main/packages/toolbox-langchain/README.md#asynchronous-usage) |
166-
167-
The `ToolboxSyncClient` handles communication with the Toolbox service *synchronously* and produces `ToolboxSyncTool` instances when you load tools. You do not use the `await` keyword when interacting with these synchronous versions.
168-
169-
```py
170-
from toolbox_core import ToolboxSyncClient
171-
172-
# replace with your Toolbox service's URL
173-
sync_client = ToolboxSyncClient("http://127.0.0.1:5000")
174-
175-
# Load a single tool
176-
tool = sync_client.load_tool("my-tool")
177-
178-
# Load all tools in a specific toolset
179-
tools = sync_client.load_toolset("my-toolset")
180-
181-
# Load all tools from all toolsets
182-
all_tools = sync_client.load_toolset()
183-
```
184-
185-
> [!NOTE]
186-
> **Upcoming Feature (`v0.2.0`+):** Support for calling `sync_client.load_toolset()`
187-
> without arguments will be introduced in `v0.2.0`.
188-
189-
190-
### Authenticating Tools
191-
192-
Tools configured in the Toolbox service to require authentication need
193-
credentials provided by the SDK during invocation.
194-
195-
#### When is Authentication Needed?
196-
197-
Authentication is configured *per-tool* within the Toolbox service. If a tool
198-
definition specifies it requires authentication (e.g., an "authenticated
199-
parameter"), the SDK must be configured to provide the necessary token.
200-
201-
#### Supported Authentication Mechanisms
202-
203-
Currently, the primary mechanism involves passing **OIDC ID Tokens** (typically
204-
obtained via Google OAuth 2.0) for specific parameters marked as authenticated
205-
in the tool's definition within the Toolbox service. Refer to the [Toolbox
206-
Service Documentation - Authenticated
207-
Parameters](https://googleapis.github.io/genai-toolbox/resources/tools/#authenticated-parameters)
208-
for details on configuring this in the service.
209-
210-
#### SDK Configuration
211-
212-
> [!WARNING]
213-
> Always use HTTPS to connect your application with the Toolbox service,
214-
> especially in production environments or whenever the communication involves
215-
> sensitive data (including scenarios where tools require authentication
216-
> tokens). Using plain HTTP lacks encryption and exposes your application and
217-
> data to significant security risks.
218-
219-
You need to provide the SDK with a function (sync or async) that can retrieve
220-
the required ID token when the tool is called. This function is registered with
221-
the SDK, associating it with the specific authentication requirement defined in
222-
the Toolbox service (matched by name).
223-
224-
```python
225-
from toolbox_core import ToolboxClient
226-
# from toolbox_langchain import ToolboxClient
227-
228-
async def get_auth_token():
229-
# ... Logic to retrieve ID token (e.g., from local storage, OAuth flow)
230-
# This example just returns a placeholder. Replace with your actual token retrieval.
231-
return "YOUR_ID_TOKEN" # Placeholder
232-
233-
toolbox = ToolboxClient("http://127.0.0.1:5000")
234-
tool = await toolbox.load_tool("my-tool")
235-
# tool = await toolbox.aload_tool("my-tool")
236-
237-
auth_tool = tool.add_auth_token_getters({"my_auth": get_auth_token})
238-
# auth_tool = tool.add_auth_tokens({"my_auth": get_auth_token})
239-
240-
# OR
241-
242-
auth_tool = await toolbox.load_tool("my-tool", auth_token_getters={"my_auth": get_auth_token})
243-
# auth_tool = await toolbox.aload_tool("my-tool", auth_tokens={"my_auth": get_auth_token})
244-
245-
result = await auth_tool(input="some input")
246-
# result = await auth_tool.ainvoke({"input": "some input"})
247-
```
248-
249-
> [!TIP]
250-
> Your token retriever function is invoked every time an authenticated parameter
251-
> requires a token for a tool call. Consider implementing caching logic within
252-
> this function to avoid redundant token fetching or generation, especially for
253-
> tokens with longer validity periods or if the retrieval process is
254-
> resource-intensive.
255-
256-
### Binding Parameter Values
257-
258-
Pre-set specific parameter values for a tool *before* it's invoked or passed to
259-
an LLM. Bound parameter values are fixed and won't be requested from the LLM.
260-
261-
#### Why Bind Parameters?
262-
263-
* **Protecting sensitive information:** API keys, secrets, etc.
264-
* **Enforcing consistency:** Ensuring specific values for certain parameters.
265-
* **Pre-filling known data:** Pre-fill common or known values.
266-
267-
#### SDK Configuration
268-
269-
> [!IMPORTANT]
270-
> The parameter names used for binding must exactly match the parameter names
271-
> defined in the tool's configuration within the Toolbox service.
272-
273-
> [!NOTE]
274-
> You do not need to modify the tool's configuration in the Toolbox service to
275-
> bind parameter values using the SDK.
276-
277-
Similar to authentication, you can bind parameters after loading a tool or
278-
during the loading process.
279-
280-
```py
281-
from toolbox_core import ToolboxClient
282-
# from toolbox_langchain import ToolboxClient
283-
284-
toolbox = ToolboxClient("http://127.0.0.1:5000")
285-
tool = await toolbox.load_tool("my-tool")
286-
# tool = await toolbox.aload_tool("my-tool")
287-
288-
bound_tool = tool.bind_parameters({"param": "value"})
289-
# bound_tool = tool.bind_params({"param": "value"})
290-
291-
# OR
292-
293-
bound_tool = await toolbox.load_tool("my-tool", bound_params={"param": "value"})
294-
# bound_tool = await toolbox.aload_tool("my-tool", bound_params={"param": "value"})
295-
```
296-
297-
## Usage Comparison
298-
299-
While the core concepts are similar, the way you integrate and use the tools
300-
varies depending on the chosen SDK package and framework.
301-
302-
| Package | Target Scenario | Client Class(es) | Loaded Tool Type | Tool Invocation | LangGraph Integration | Detailed Examples |
303-
| :---------------- | :--------------------------------------------------------------- | :---------------------------------------------------------------------------------- | :--------------------------------------------------------------------- | :-------------------------------------- | :----------------------------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------- |
304-
| `toolbox-core` | Framework-agnostic applications or custom orchestration logic. | `ToolboxClient` (async)<br>`ToolboxSyncClient` (sync) | `ToolboxTool` (async) /<br>`ToolboxSyncTool` (sync) | Directly callable / awaitable. | **Requires wrapping:** Tools may need manual wrapping (e.g., `StructuredTool.from_function`) for full LLM use. | [Core README Section](https://github.com/googleapis/mcp-toolbox-sdk-python/tree/main/packages/toolbox-core#use-with-langgraph) |
305-
| `toolbox-langchain` | Applications within the LangChain / LangGraph ecosystem. | `ToolboxClient` (provides both sync `load_*` and async `aload_*` methods) | `ToolboxTool` instances (compatible with LangChain `BaseTool`) | Standard LangChain tool usage patterns. | **Seamless:** Designed for direct use with `model.bind_tools(tools)` and `ToolNode(tools)`. | [LangChain README Section](https://github.com/googleapis/mcp-toolbox-sdk-python/blob/main/packages/toolbox-langchain#use-with-langgraph) |
306-
307108
## Contributing
308109

309110
Contributions are welcome! Please refer to the

0 commit comments

Comments
 (0)