MCP Toolbox Core SDK

1.0.0 · active · verified Thu Apr 16

Python Base SDK for interacting with the Toolbox service, designed to seamlessly integrate the functionalities of the MCP Toolbox into your Gen AI applications by allowing you to load and use tools defined in the service as standard Python functions. It is actively maintained by Google and released version 1.0.0 on March 25, 2026, with related SDKs and the core Toolbox service undergoing rapid development and frequent updates.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the `ToolboxClient`, connect to a running MCP Toolbox service (requires a locally or remotely deployed server), and load and invoke a predefined tool, such as 'get_weather'. Make sure the `TOOLBOX_SERVICE_URL` environment variable is set or the default URL is correct.

import asyncio
import os
from toolbox_core import ToolboxClient

async def main():
    # Replace with the actual URL where your Toolbox service is running.
    # It's recommended to use an environment variable for the host in production.
    toolbox_host = os.environ.get("TOOLBOX_SERVICE_URL", "http://127.0.0.1:5000")
    print(f"Connecting to Toolbox service at: {toolbox_host}")

    try:
        async with ToolboxClient(toolbox_host) as toolbox:
            # Assuming 'get_weather' is a tool defined and exposed by your Toolbox service.
            # The tool name must match a tool configured on the running Toolbox server.
            weather_tool = await toolbox.load_tool("get_weather")
            print("Tool 'get_weather' loaded successfully.")

            # Invoke the loaded tool with its expected parameters.
            result = await weather_tool(location="London")
            print(f"Weather in London: {result}")
    except Exception as e:
        print(f"An error occurred: {e}")
        print("Ensure the MCP Toolbox server is running and accessible at the specified URL.")
        print("Refer to the MCP Toolbox Server Getting Started Guide for setup instructions (e.g., https://github.com/googleapis/mcp-toolbox).")

if __name__ == "__main__":
    asyncio.run(main())

view raw JSON →