
Written by: Twisha Bansal, Software Engineer @ Google (Linkedin)
Generative AI applications are revolutionizing how we interact with technology. However, the true power of agents, which are powered by underlying Large Language Models (LLMs), often lies in their ability to interact with the external world — whether fetching real-time data, connecting to databases, or executing complex operations. This is where the concept of “tooling” comes into play, enabling agents to perform actions and access information outside the model’s training data.
MCP Toolbox helps you build Gen AI tools that let your agents access data in your database. Toolbox supports 15+ databases and provides simplified development, better performance, enhanced security and end-to-end observability.
We are thrilled to announce the release of the Toolbox JS SDK, a new TypeScript (and JavaScript-compatible) SDK designed to simplify this integration. The Toolbox JS SDK provides an MCP-like experience allowing you to load and call tools, while providing extra functionality around auth, security, and performance.
- Compatible with popular JS frameworks: Designed to work with various orchestration frameworks like LangChain, LlamaIndex, and Genkit.
- Idiomatic Typescript experience: The SDK converts your YAML-defined tools into native JavaScript objects, eliminating boilerplate code for HTTP requests and API interactions.
- Clear separation of concerns: This design decouples your agent development from tool implementation.
This post will guide you through getting started and highlight the SDK’s core capabilities.
To utilize the SDK, you’ll first need a running instance of the Toolbox server, which acts as the central hub for your tools. Let’s look at the foundational steps for setting up your tools and then connecting with the SDK.
Note: For a step-by-step tutorial on how to download and install Toolbox, see the Quickstart.
1. Configure Toolbox
The Toolbox server uses a tools.yaml
file to define the tools your agents can access. This YAML file outlines the tool’s database query, parameters, and clear descriptions that guide the agent’s usage.
Here is a simplified example of an tools.yaml
to define hotel management tools for a hotel assistant agent:
sources:
// Add Database metadata such as URLtools:
search-hotels-by-location:
kind: postgres-sql
source: my-pg-source
description: Search for hotels based on location.
parameters:
- name: location
type: string
description: The location of the hotel.
statement: SELECT * FROM hotels WHERE location ILIKE '%' || $1 || '%';
book-hotel:
...
For full tools.yaml
examples, see tutorials for BigQuery and Postgres.
This configuration describes the toolset, containing tools like search-hotels-by-name, book-hotel, and cancel-hotel. Each tool is defined with a clear description and explicit parameters, including their type and description. Behind the scenes, your Toolbox server implements the logic for these tools, connecting to databases or APIs as needed.
With your tools.yaml
and database configuration in place, run the Toolbox server using the command below:
./toolbox --tools-file=tools.yaml
Once the server is running, it exposes an endpoint (e.g. http://127.0.0.1:5000
) that the Toolbox JS SDK will connect to.
2. Install the SDK
Now, let’s get to the JavaScript/TypeScript side. First, install the SDK in your project:
npm install @toolbox-sdk/core
# or
yarn add @toolbox-sdk/core
Next, we connect to the Toolbox Server from our application. The ToolboxClient
serves as your primary interface for interacting with the running Toolbox server. Initialize it with your server’s endpoint:
import
apiKey: process.env.GEMINI_API_KEY from "@toolbox-sdk/core";// Ensure your Toolbox server is running at this address
const client = new ToolboxClient("http://127.0.0.1:5000");
Once connected, you can fetch your defined tools. The SDK allows you to load an entire toolset or specific individual tools. Given our tools.yaml
setup:
// Load all tools
const toolboxTools = await client.loadToolset();
These toolboxTools
are objects representing your external functionalities, now ready for use by your agent.
3. Integrate with an orchestration framework
The Toolbox JS SDK is designed for seamless integration with popular orchestration frameworks like LangChainJS and Genkit. The ToolboxClient simplifies the process of converting your defined Toolbox tools into Tool objects compatible with various orchestration frameworks.
Create a LangChainJS agent:
import process.env.GOOGLE_API_KEY
from "@langchain/langgraph/prebuilt";
import process.env.GOOGLE_API_KEY
from "@langchain/google-vertexai";
import
apiKey: process.env.GEMINI_API_KEY from "@langchain/core/tools";// 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()
});
// Prepare the Langchain-compatible tools
const tools = toolboxTools.map(getTool);
// Each agent needs to be bound with an LLM model and some tools
const agent = createReactAgent({
llm: new ChatVertexAI({model: "gemini-2.0-flash-exp"}),
tools: tools,
});
const result = await agent.invoke(
{
messages: [{
role: "user",
content: "Find all hotels in Basel."
}]
}
);
Create a Genkit agent:
import { ToolboxClient } from "@toolbox-sdk/core"
import { genkit } from 'genkit';
import { googleAI } from '@genkit-ai/googleai';// 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'),
});
// Define the basics of the tool: name, description, schema and core logic
const getGenkitTool = (toolboxTool) => ai.defineTool({
name: toolboxTool.getName(),
description: toolboxTool.getDescription(),
schema: toolboxTool.getParamSchema()
}, toolboxTool)
// Prepare the Genkit-compatible tools
const tools = toolboxTools.map(getGenkitTool);
// Get response
const response = await ai.generate({
prompt: 'Find all hotels in Basel.',
tools: tools,
system: systemPrompt,
});
console.log(response.text);
For information on usage with other orchestration frameworks, see additional documentation.
Without Toolbox, you’d have to write significant boilerplate code directly in your agent’s application — one set of functions for database connections and queries, and another for REST API calls with all their complex authentication and error-handling. Your application quickly becomes cluttered with credentials and integration logic that is difficult to secure and maintain.
MCP Toolbox eliminates this complexity.
Instead of writing all that code, you simply define your tools in a single tools.yaml
file — one for the database query, another for the API call. Toolbox securely handles all the backend execution for you.
The new Toolbox JS SDK is the bridge that makes this possible. It fetches these powerful, YAML-defined tools and delivers them to your agent as simple, native JavaScript functions.
The Toolbox JS SDK aims to be an indispensable asset for developers building sophisticated Generative AI applications. By simplifying tool integration, it enables you to focus on the core logic of your agents, letting them interact with your data with unprecedented ease. We encourage you to try it out, experiment with its capabilities, and join our community in shaping the future of agent-powered applications!
This blog post provides a foundational understanding of how to get started with the Toolbox JS SDK, from defining your tools in tools.yaml
to connecting them with your LangChain agent. To truly unlock its potential, explore the JS SDK Documentation.
- Deep dive into tool definition: Explore how you can build custom tools using
tools.yaml
config. - Implement authentication & authorization: Learn how to secure your Toolbox server and tools, ensuring only authorized agents can access sensitive functionalities.
- Explore advanced features: Discover capabilities like bound parameters. This allows you to pre-set values for specific tool parameters before the tool is invoked or even passed to an LLM.
Contribute to the Community! We welcome your feedback and contributions. Join our Discord channel and check out the repositories for the:
Source Credit: https://medium.com/google-cloud/seamless-tool-integration-for-agents-a-deep-dive-into-the-new-toolbox-js-sdk-0a2d0f0927ff?source=rss—-e52cf94d98af—4