Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions packages/toolbox-adk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ involving Large Language Models (LLMs).
- [Installation](#installation)
- [Quickstart](#quickstart)
- [Usage](#usage)
- [Transport Protocols](#transport-protocols)
- [Available Protocols](#available-protocols)
- [Specifying a Protocol](#specifying-a-protocol)
- [Loading Tools](#loading-tools)
- [Load a toolset](#load-a-toolset)
- [Load a single tool](#load-a-single-tool)
Expand Down Expand Up @@ -123,6 +126,34 @@ All interactions for loading and invoking tools happen through this client.
> For advanced use cases, you can provide an external `AxiosInstance`
> during initialization (e.g., `ToolboxClient(url, my_session)`).


## Transport Protocols

The SDK supports multiple transport protocols to communicate with the Toolbox server. You can specify the protocol version during client initialization.

### Available Protocols

- `Protocol.MCP`: The default protocol (currently aliases to `MCP_v20250618`).
- `Protocol.MCP_v20241105`: Use this for compatibility with older MCP servers (November 2024 version).
- `Protocol.MCP_v20250326`: March 2025 version.
- `Protocol.MCP_v20250618`: June 2025 version.
- `Protocol.TOOLBOX`: Legacy Toolbox protocol.

### Specifying a Protocol

You can explicitly set the protocol by passing the `protocol` argument to the `ToolboxClient` constructor.

```javascript
import { ToolboxClient, Protocol } from '@toolbox-sdk/adk';

const URL = 'http://127.0.0.1:5000';

// Initialize with a specific protocol version
const client = new ToolboxClient(URL, null, null, Protocol.MCP_v20241105);

const tools = await client.loadToolset();
```

## Loading Tools

You can load tools individually or in groups (toolsets) as defined in your
Expand Down
9 changes: 8 additions & 1 deletion packages/toolbox-adk/src/toolbox_adk/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
AuthTokenGetters,
BoundParams,
ClientHeadersConfig,
Protocol,
} from '@toolbox-sdk/core';
import {ToolboxTool, CoreTool} from './tool.js';
import type {AxiosInstance} from 'axios';
Expand Down Expand Up @@ -44,8 +45,14 @@ export class ToolboxClient {
url: string,
session?: AxiosInstance | null,
clientHeaders?: ClientHeadersConfig | null,
protocol: Protocol = Protocol.MCP,
) {
this.coreClient = new CoreToolboxClient(url, session, clientHeaders);
this.coreClient = new CoreToolboxClient(
url,
session,
clientHeaders,
protocol,
);
}

/**
Expand Down
1 change: 1 addition & 0 deletions packages/toolbox-adk/src/toolbox_adk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
// Export the main factory function and the core tool type
export {ToolboxClient} from './client.js';
export {ToolboxTool} from './tool.js';
export {Protocol} from '@toolbox-sdk/core';
14 changes: 11 additions & 3 deletions packages/toolbox-adk/test/e2e/test.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import {ToolboxClient} from '../../src/toolbox_adk/client.js';
import {ToolboxTool} from '../../src/toolbox_adk/tool.js';
import {
ToolboxClient,
ToolboxTool,
Protocol,
} from '../../src/toolbox_adk/index.js';

import {AxiosError} from 'axios';
import {CustomGlobal} from './types.js';
Expand All @@ -30,7 +33,12 @@ describe('ToolboxClient E2E Tests', () => {
const mockToolContext = {} as ToolContext;

beforeAll(async () => {
commonToolboxClient = new ToolboxClient(testBaseUrl);
commonToolboxClient = new ToolboxClient(
testBaseUrl,
undefined,
undefined,
Protocol.TOOLBOX,
);
});

beforeEach(async () => {
Expand Down
6 changes: 6 additions & 0 deletions packages/toolbox-adk/test/test.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type MockCoreClientConstructor = (
url: string,
session?: AxiosInstance | null,
clientHeaders?: ClientHeadersConfig | null,
protocol?: string | null,
) => MockCoreClient;

const mockLoadTool =
Expand Down Expand Up @@ -66,6 +67,10 @@ const MockToolboxTool = jest.fn();

jest.unstable_mockModule('@toolbox-sdk/core', () => ({
ToolboxClient: MockCoreToolboxClient,
Protocol: {
MCP: 'mcp-default',
TOOLBOX: 'toolbox',
},
}));

jest.unstable_mockModule('../src/toolbox_adk/tool.js', () => ({
Expand Down Expand Up @@ -94,6 +99,7 @@ describe('ToolboxClient', () => {
'http://test.url',
mockSession,
mockHeaders,
'mcp-default',
);
});

Expand Down
31 changes: 31 additions & 0 deletions packages/toolbox-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ involving Large Language Models (LLMs).
- [Installation](#installation)
- [Quickstart](#quickstart)
- [Usage](#usage)
- [Transport Protocols](#transport-protocols)
- [Available Protocols](#available-protocols)
- [Specifying a Protocol](#specifying-a-protocol)
- [Loading Tools](#loading-tools)
- [Load a toolset](#load-a-toolset)
- [Load a single tool](#load-a-single-tool)
Expand Down Expand Up @@ -121,6 +124,34 @@ All interactions for loading and invoking tools happen through this client.
> For advanced use cases, you can provide an external `AxiosInstance`
> during initialization (e.g., `ToolboxClient(url, my_session)`).


## Transport Protocols

The SDK supports multiple transport protocols to communicate with the Toolbox server. You can specify the protocol version during client initialization.

### Available Protocols

- `Protocol.MCP`: The default protocol (currently aliases to `MCP_v20250618`).
- `Protocol.MCP_v20241105`: Use this for compatibility with older MCP servers (November 2024 version).
- `Protocol.MCP_v20250326`: March 2025 version.
- `Protocol.MCP_v20250618`: June 2025 version.
- `Protocol.TOOLBOX`: Legacy Toolbox protocol.

### Specifying a Protocol

You can explicitly set the protocol by passing the `protocol` argument to the `ToolboxClient` constructor.

```javascript
import { ToolboxClient, Protocol } from '@toolbox-sdk/core';

const URL = 'http://127.0.0.1:5000';

// Initialize with a specific protocol version
const client = new ToolboxClient(URL, null, null, Protocol.MCP_v20241105);

const tools = await client.loadToolset();
```

## Loading Tools

You can load tools individually or in groups (toolsets) as defined in your
Expand Down
3 changes: 2 additions & 1 deletion packages/toolbox-core/jest.config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"testMatch": [
"<rootDir>/test/*.ts"
"<rootDir>/test/*.ts",
"<rootDir>/test/mcp/*.ts"
],
"preset": "ts-jest",
"transform": {
Expand Down
9 changes: 5 additions & 4 deletions packages/toolbox-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
],
"exports": {
".": {
"import": "./build/index.js",
"import": "./build/esm/index.js",
"require": "./build/cjs/index.js",
"types": "./build/index.d.ts"
"types": "./build/esm/index.d.ts"
},
"./auth": {
"import": "./build/authMethods.js",
"import": "./build/esm/authMethods.js",
"require": "./build/cjs/authMethods.js",
"types": "./build/authMethods.d.ts"
"types": "./build/esm/authMethods.d.ts"
}
},
"files": [
Expand Down Expand Up @@ -63,6 +63,7 @@
"zod": "^3.24.4"
},
"devDependencies": {
"@types/uuid": "^10.0.0",
"rimraf": "^6.1.2"
}
}
34 changes: 33 additions & 1 deletion packages/toolbox-core/src/toolbox_core/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ import {
createZodSchemaFromParams,
ParameterSchema,
ZodManifestSchema,
Protocol,
getSupportedMcpVersions,
} from './protocol.js';
import {McpHttpTransportV20241105} from './mcp/v20241105/mcp.js';
import {McpHttpTransportV20250618} from './mcp/v20250618/mcp.js';
import {McpHttpTransportV20250326} from './mcp/v20250326/mcp.js';
import {BoundParams, identifyAuthRequirements, resolveValue} from './utils.js';
import {AuthTokenGetters, RequiredAuthnParams} from './tool.js';

Expand Down Expand Up @@ -51,9 +56,36 @@ class ToolboxClient {
url: string,
session?: AxiosInstance | null,
clientHeaders?: ClientHeadersConfig | null,
protocol: Protocol = Protocol.MCP,
) {
this.#transport = new ToolboxTransport(url, session || undefined);
this.#clientHeaders = clientHeaders || {};
if (protocol === Protocol.TOOLBOX) {
this.#transport = new ToolboxTransport(url, session || undefined);
} else if (getSupportedMcpVersions().includes(protocol)) {
if (protocol === Protocol.MCP_v20241105) {
this.#transport = new McpHttpTransportV20241105(
url,
session || undefined,
protocol,
);
} else if (protocol === Protocol.MCP_v20250326) {
this.#transport = new McpHttpTransportV20250326(
url,
session || undefined,
protocol,
);
} else if (protocol === Protocol.MCP_v20250618) {
this.#transport = new McpHttpTransportV20250618(
url,
session || undefined,
protocol,
);
} else {
throw new Error(`Unsupported MCP protocol version: ${protocol}`);
}
} else {
throw new Error(`Unsupported protocol version: ${protocol}`);
}
}

/**
Expand Down
1 change: 1 addition & 0 deletions packages/toolbox-core/src/toolbox_core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ export type {

export type {BoundParams, BoundValue} from './utils.js';
export type {ClientHeadersConfig} from './client.js';
export {Protocol} from './protocol.js';
Loading
Loading