mirror of
https://github.com/googleapis/genai-toolbox.git
synced 2026-02-18 11:02:26 -05:00
Compare commits
39 Commits
lsc-177140
...
binary-npx
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1fb8f6fc5e | ||
|
|
9e92de2cbd | ||
|
|
9670f25fdb | ||
|
|
7df74b16df | ||
|
|
bd342c1b99 | ||
|
|
57a2ade4c5 | ||
|
|
bcb3566ba3 | ||
|
|
47bbef10c5 | ||
|
|
44e782371e | ||
|
|
705be4018d | ||
|
|
c968ed8925 | ||
|
|
6f5911288d | ||
|
|
cf42389d39 | ||
|
|
49cb83ca5d | ||
|
|
961c4726c7 | ||
|
|
6e961ad48b | ||
|
|
d5a9031a65 | ||
|
|
669b9b3b5d | ||
|
|
7bf04ddbb1 | ||
|
|
2705cf642c | ||
|
|
fb8f757eaf | ||
|
|
6731e25cff | ||
|
|
0aece20ada | ||
|
|
401d0307d5 | ||
|
|
7479f5b871 | ||
|
|
a61a1d78a3 | ||
|
|
2fbf51968d | ||
|
|
54b56ee7cc | ||
|
|
39615a6011 | ||
|
|
83562eb5ec | ||
|
|
bb76fc6a84 | ||
|
|
21e4db2ed4 | ||
|
|
05e075b3fe | ||
|
|
e94eebc6af | ||
|
|
e50dc777b7 | ||
|
|
1aaa84313c | ||
|
|
829e3168ff | ||
|
|
3d76f60401 | ||
|
|
d065b41598 |
4
.github/workflows/deploy_versioned_docs.yaml
vendored
4
.github/workflows/deploy_versioned_docs.yaml
vendored
@@ -35,9 +35,7 @@ jobs:
|
||||
ref: ${{ github.event.release.tag_name }}
|
||||
|
||||
- name: Get Version from Release Tag
|
||||
run: echo "VERSION=${GITHUB_EVENT_RELEASE_TAG_NAME}" >> $GITHUB_ENV
|
||||
env:
|
||||
GITHUB_EVENT_RELEASE_TAG_NAME: ${{ github.event.release.tag_name }}
|
||||
run: echo "VERSION=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
|
||||
|
||||
- name: Setup Hugo
|
||||
uses: peaceiris/actions-hugo@75d2e84710de30f6ff7268e08f310b60ef14033f # v3
|
||||
|
||||
36
.github/workflows/link_checker_workflow.yaml
vendored
36
.github/workflows/link_checker_workflow.yaml
vendored
@@ -23,33 +23,8 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Identify Changed Files
|
||||
id: changed-files
|
||||
shell: bash
|
||||
run: |
|
||||
git fetch origin main
|
||||
CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRT origin/main...HEAD)
|
||||
|
||||
if [ -z "$CHANGED_FILES" ]; then
|
||||
echo "No markdown files changed. Skipping checks."
|
||||
echo "HAS_CHANGES=false" >> $GITHUB_ENV
|
||||
else
|
||||
echo "--- Changed Files to Scan ---"
|
||||
echo "$CHANGED_FILES"
|
||||
echo "-----------------------------"
|
||||
|
||||
# Flatten newlines to spaces for the args list
|
||||
FILES_FLAT=$(echo "$CHANGED_FILES" | tr '\n' ' ')
|
||||
|
||||
echo "CHECK_FILES=$FILES_FLAT" >> $GITHUB_ENV
|
||||
echo "HAS_CHANGES=true" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
|
||||
- name: Restore lychee cache
|
||||
if: env.HAS_CHANGES == 'true'
|
||||
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5
|
||||
with:
|
||||
path: .lycheecache
|
||||
@@ -58,7 +33,6 @@ jobs:
|
||||
|
||||
- name: Link Checker
|
||||
id: lychee-check
|
||||
if: env.HAS_CHANGES == 'true'
|
||||
uses: lycheeverse/lychee-action@a8c4c7cb88f0c7386610c35eb25108e448569cb0 # v2
|
||||
continue-on-error: true
|
||||
with:
|
||||
@@ -68,7 +42,8 @@ jobs:
|
||||
--cache
|
||||
--max-cache-age 1d
|
||||
--exclude '^neo4j\+.*' --exclude '^bolt://.*'
|
||||
${{ env.CHECK_FILES }}
|
||||
README.md
|
||||
docs/
|
||||
output: lychee-report.md
|
||||
format: markdown
|
||||
fail: true
|
||||
@@ -76,13 +51,6 @@ jobs:
|
||||
debug: false
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Create PR Comment
|
||||
if: env.HAS_CHANGES == 'true' && steps.lychee-check.outputs.status != '0'
|
||||
uses: peter-evans/create-or-update-comment@v4
|
||||
with:
|
||||
issue-number: ${{ github.event.pull_request.number }}
|
||||
body-path: lychee-report.md
|
||||
edit-mode: replace
|
||||
|
||||
- name: Display Failure Report
|
||||
# Run this ONLY if the link checker failed
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 271 KiB After Width: | Height: | Size: 241 KiB |
@@ -6,7 +6,7 @@ description: >
|
||||
Connect your IDE to Looker using Toolbox.
|
||||
---
|
||||
|
||||
[Model Context Protocol (MCP)](https://modelcotextprotocol.io/introduction) is
|
||||
[Model Context Protocol (MCP)](https://modelcontextprotocol.io/introduction) is
|
||||
an open protocol for connecting Large Language Models (LLMs) to data sources
|
||||
like Postgres. This guide covers how to use [MCP Toolbox for Databases][toolbox]
|
||||
to expose your developer assistant tools to a Looker instance:
|
||||
@@ -20,7 +20,7 @@ to expose your developer assistant tools to a Looker instance:
|
||||
* [Claude code][claudecode]
|
||||
* [Antigravity][antigravity]
|
||||
|
||||
[toolbox]: https://gitub.com/googleapis/genai-toolbox
|
||||
[toolbox]: https://github.com/googleapis/genai-toolbox
|
||||
[gemini-cli]: #configure-your-mcp-client
|
||||
[cursor]: #configure-your-mcp-client
|
||||
[windsurf]: #configure-your-mcp-client
|
||||
@@ -92,7 +92,7 @@ After you install Looker in the MCP Store, resources and tools from the server a
|
||||
## Install MCP Toolbox
|
||||
|
||||
1. Download the latest version of Toolbox as a binary. Select the [correct
|
||||
binary](https://gitub.com/googleapis/genai-toolbox/releases) corresponding
|
||||
binary](https://github.com/googleapis/genai-toolbox/releases) corresponding
|
||||
to your OS and CPU architecture. You are required to use Toolbox version
|
||||
v0.10.0+:
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ curl -O https://storage.googleapis.com/genai-toolbox/v0.27.0/windows/amd64/toolb
|
||||
{{% tab header="Claude code" lang="en" %}}
|
||||
|
||||
1. Install [Claude
|
||||
Code](https://docs.anthropic.com/en/docs/gents-and-tools/claude-code/overview).
|
||||
Code](https://docs.anthropic.com/en/docs/agents-and-tools/claude-code/overview).
|
||||
1. Create a `.mcp.json` file in your project root if it doesn't exist.
|
||||
1. Add the following configuration, replace the environment variables with your
|
||||
values, and save:
|
||||
@@ -133,7 +133,7 @@ curl -O https://storage.googleapis.com/genai-toolbox/v0.27.0/windows/amd64/toolb
|
||||
{{% /tab %}}
|
||||
{{% tab header="Cline" lang="en" %}}
|
||||
|
||||
1. Open the [Cline](https://gihub.com/cline/cline) extension in VS Code and
|
||||
1. Open the [Cline](https://github.com/cline/cline) extension in VS Code and
|
||||
tap the **MCP Servers** icon.
|
||||
1. Tap Configure MCP Servers to open the configuration file.
|
||||
1. Add the following configuration, replace the environment variables with your
|
||||
|
||||
@@ -44,12 +44,6 @@ See [Usage Examples](../reference/cli.md#examples).
|
||||
* **Tools:**
|
||||
* `execute_sql`: Executes a SQL query.
|
||||
* `list_tables`: Lists tables in the database.
|
||||
* `list_active_queries`: Lists ongoing queries.
|
||||
* `list_available_extensions`: Discover all PostgreSQL extensions available for installation.
|
||||
* `list_installed_extensions`: List all installed PostgreSQL extensions.
|
||||
* `long_running_transactions`: Identifies and lists database transactions that exceed a specified time limit.
|
||||
* `list_locks`: Identifies all locks held by active processes.
|
||||
* `replication_stats`: Lists each replica's process ID and sync state.
|
||||
* `list_autovacuum_configurations`: Lists autovacuum configurations in the
|
||||
database.
|
||||
* `list_memory_configurations`: Lists memory-related configurations in the
|
||||
@@ -65,16 +59,12 @@ See [Usage Examples](../reference/cli.md#examples).
|
||||
* `list_triggers`: Lists triggers in the database.
|
||||
* `list_indexes`: List available user indexes in a PostgreSQL database.
|
||||
* `list_sequences`: List sequences in a PostgreSQL database.
|
||||
* `list_query_stats`: Lists query statistics.
|
||||
* `get_column_cardinality`: Gets column cardinality.
|
||||
* `list_table_stats`: Lists table statistics.
|
||||
* `list_publication_tables`: List publication tables in a PostgreSQL database.
|
||||
* `list_tablespaces`: Lists tablespaces in the database.
|
||||
* `list_pg_settings`: List configuration parameters for the PostgreSQL server.
|
||||
* `list_database_stats`: Lists the key performance and activity statistics for
|
||||
each database in the AlloyDB instance.
|
||||
* `list_roles`: Lists all the user-created roles in PostgreSQL database.
|
||||
* `list_stored_procedure`: Lists stored procedures.
|
||||
|
||||
## AlloyDB Postgres Admin
|
||||
|
||||
@@ -123,12 +113,6 @@ See [Usage Examples](../reference/cli.md#examples).
|
||||
* **Tools:**
|
||||
* `execute_sql`: Executes a SQL query.
|
||||
* `list_tables`: Lists tables in the database.
|
||||
* `list_active_queries`: Lists ongoing queries.
|
||||
* `list_available_extensions`: Discover all PostgreSQL extensions available for installation.
|
||||
* `list_installed_extensions`: List all installed PostgreSQL extensions.
|
||||
* `long_running_transactions`: Identifies and lists database transactions that exceed a specified time limit.
|
||||
* `list_locks`: Identifies all locks held by active processes.
|
||||
* `replication_stats`: Lists each replica's process ID and sync state.
|
||||
* `list_autovacuum_configurations`: Lists autovacuum configurations in the
|
||||
database.
|
||||
* `list_columnar_configurations`: List AlloyDB Omni columnar-related configurations.
|
||||
@@ -146,16 +130,12 @@ See [Usage Examples](../reference/cli.md#examples).
|
||||
* `list_triggers`: Lists triggers in the database.
|
||||
* `list_indexes`: List available user indexes in a PostgreSQL database.
|
||||
* `list_sequences`: List sequences in a PostgreSQL database.
|
||||
* `list_query_stats`: Lists query statistics.
|
||||
* `get_column_cardinality`: Gets column cardinality.
|
||||
* `list_table_stats`: Lists table statistics.
|
||||
* `list_publication_tables`: List publication tables in a PostgreSQL database.
|
||||
* `list_tablespaces`: Lists tablespaces in the database.
|
||||
* `list_pg_settings`: List configuration parameters for the PostgreSQL server.
|
||||
* `list_database_stats`: Lists the key performance and activity statistics for
|
||||
each database in the AlloyDB instance.
|
||||
* `list_roles`: Lists all the user-created roles in PostgreSQL database.
|
||||
* `list_stored_procedure`: Lists stored procedures.
|
||||
|
||||
## BigQuery
|
||||
|
||||
@@ -193,21 +173,6 @@ See [Usage Examples](../reference/cli.md#examples).
|
||||
* `list_table_ids`: Lists tables.
|
||||
* `search_catalog`: Search for entries based on the provided query.
|
||||
|
||||
## ClickHouse
|
||||
|
||||
* `--prebuilt` value: `clickhouse`
|
||||
* **Environment Variables:**
|
||||
* `CLICKHOUSE_HOST`: The hostname or IP address of the ClickHouse server.
|
||||
* `CLICKHOUSE_PORT`: The port number of the ClickHouse server.
|
||||
* `CLICKHOUSE_USER`: The database username.
|
||||
* `CLICKHOUSE_PASSWORD`: The password for the database user.
|
||||
* `CLICKHOUSE_DATABASE`: The name of the database to connect to.
|
||||
* `CLICKHOUSE_PROTOCOL`: The protocol to use (e.g., http).
|
||||
* **Tools:**
|
||||
* `execute_sql`: Use this tool to execute SQL.
|
||||
* `list_databases`: Use this tool to list all databases in ClickHouse.
|
||||
* `list_tables`: Use this tool to list all tables in a specific ClickHouse database.
|
||||
|
||||
## Cloud SQL for MySQL
|
||||
|
||||
* `--prebuilt` value: `cloud-sql-mysql`
|
||||
@@ -305,12 +270,6 @@ See [Usage Examples](../reference/cli.md#examples).
|
||||
* **Tools:**
|
||||
* `execute_sql`: Executes a SQL query.
|
||||
* `list_tables`: Lists tables in the database.
|
||||
* `list_active_queries`: Lists ongoing queries.
|
||||
* `list_available_extensions`: Discover all PostgreSQL extensions available for installation.
|
||||
* `list_installed_extensions`: List all installed PostgreSQL extensions.
|
||||
* `long_running_transactions`: Identifies and lists database transactions that exceed a specified time limit.
|
||||
* `list_locks`: Identifies all locks held by active processes.
|
||||
* `replication_stats`: Lists each replica's process ID and sync state.
|
||||
* `list_autovacuum_configurations`: Lists autovacuum configurations in the
|
||||
database.
|
||||
* `list_memory_configurations`: Lists memory-related configurations in the
|
||||
@@ -326,16 +285,12 @@ See [Usage Examples](../reference/cli.md#examples).
|
||||
* `list_triggers`: Lists triggers in the database.
|
||||
* `list_indexes`: List available user indexes in a PostgreSQL database.
|
||||
* `list_sequences`: List sequences in a PostgreSQL database.
|
||||
* `list_query_stats`: Lists query statistics.
|
||||
* `get_column_cardinality`: Gets column cardinality.
|
||||
* `list_table_stats`: Lists table statistics.
|
||||
* `list_publication_tables`: List publication tables in a PostgreSQL database.
|
||||
* `list_tablespaces`: Lists tablespaces in the database.
|
||||
* `list_pg_settings`: List configuration parameters for the PostgreSQL server.
|
||||
* `list_database_stats`: Lists the key performance and activity statistics for
|
||||
each database in the postgreSQL instance.
|
||||
* `list_roles`: Lists all the user-created roles in PostgreSQL database.
|
||||
* `list_stored_procedure`: Lists stored procedures.
|
||||
|
||||
## Cloud SQL for PostgreSQL Observability
|
||||
|
||||
@@ -381,7 +336,6 @@ See [Usage Examples](../reference/cli.md#examples).
|
||||
* `create_user`: Creates a new user in a Cloud SQL instance.
|
||||
* `wait_for_operation`: Waits for a Cloud SQL operation to complete.
|
||||
* `clone_instance`: Creates a clone for an existing Cloud SQL for PostgreSQL instance.
|
||||
* `postgres_upgrade_precheck`: Performs a precheck for a major version upgrade of a Cloud SQL for PostgreSQL instance.
|
||||
* `create_backup`: Creates a backup on a Cloud SQL instance.
|
||||
* `restore_backup`: Restores a backup of a Cloud SQL instance.
|
||||
|
||||
@@ -466,15 +420,6 @@ See [Usage Examples](../reference/cli.md#examples).
|
||||
* `search_aspect_types`: Finds aspect types relevant to the
|
||||
query.
|
||||
|
||||
## Elasticsearch
|
||||
|
||||
* `--prebuilt` value: `elasticsearch`
|
||||
* **Environment Variables:**
|
||||
* `ELASTICSEARCH_HOST`: The hostname or IP address of the Elasticsearch server.
|
||||
* `ELASTICSEARCH_APIKEY`: The API key for authentication.
|
||||
* **Tools:**
|
||||
* `execute_esql_query`: Use this tool to execute ES|QL queries.
|
||||
|
||||
## Firestore
|
||||
|
||||
* `--prebuilt` value: `firestore`
|
||||
@@ -592,19 +537,6 @@ See [Usage Examples](../reference/cli.md#examples).
|
||||
* `execute_sql`: Executes a SQL query.
|
||||
* `list_tables`: Lists tables in the database.
|
||||
|
||||
## MindsDB
|
||||
|
||||
* `--prebuilt` value: `mindsdb`
|
||||
* **Environment Variables:**
|
||||
* `MINDSDB_HOST`: The hostname or IP address of the MindsDB server.
|
||||
* `MINDSDB_PORT`: The port number of the MindsDB server.
|
||||
* `MINDSDB_DATABASE`: The name of the database to connect to.
|
||||
* `MINDSDB_USER`: The database username.
|
||||
* `MINDSDB_PASS`: The password for the database user.
|
||||
* **Tools:**
|
||||
* `mindsdb-execute-sql`: Execute SQL queries directly on MindsDB database.
|
||||
* `mindsdb-sql`: Execute parameterized SQL queries on MindsDB database.
|
||||
|
||||
## MySQL
|
||||
|
||||
* `--prebuilt` value: `mysql`
|
||||
@@ -660,12 +592,6 @@ See [Usage Examples](../reference/cli.md#examples).
|
||||
* **Tools:**
|
||||
* `execute_sql`: Executes a SQL query.
|
||||
* `list_tables`: Lists tables in the database.
|
||||
* `list_active_queries`: Lists ongoing queries.
|
||||
* `list_available_extensions`: Discover all PostgreSQL extensions available for installation.
|
||||
* `list_installed_extensions`: List all installed PostgreSQL extensions.
|
||||
* `long_running_transactions`: Identifies and lists database transactions that exceed a specified time limit.
|
||||
* `list_locks`: Identifies all locks held by active processes.
|
||||
* `replication_stats`: Lists each replica's process ID and sync state.
|
||||
* `list_autovacuum_configurations`: Lists autovacuum configurations in the
|
||||
database.
|
||||
* `list_memory_configurations`: Lists memory-related configurations in the
|
||||
@@ -681,16 +607,12 @@ See [Usage Examples](../reference/cli.md#examples).
|
||||
* `list_triggers`: Lists triggers in the database.
|
||||
* `list_indexes`: List available user indexes in a PostgreSQL database.
|
||||
* `list_sequences`: List sequences in a PostgreSQL database.
|
||||
* `list_query_stats`: Lists query statistics.
|
||||
* `get_column_cardinality`: Gets column cardinality.
|
||||
* `list_table_stats`: Lists table statistics.
|
||||
* `list_publication_tables`: List publication tables in a PostgreSQL database.
|
||||
* `list_tablespaces`: Lists tablespaces in the database.
|
||||
* `list_pg_settings`: List configuration parameters for the PostgreSQL server.
|
||||
* `list_database_stats`: Lists the key performance and activity statistics for
|
||||
each database in the PostgreSQL server.
|
||||
* `list_roles`: Lists all the user-created roles in PostgreSQL database.
|
||||
* `list_stored_procedure`: Lists stored procedures.
|
||||
|
||||
## Google Cloud Serverless for Apache Spark
|
||||
|
||||
@@ -705,38 +627,6 @@ See [Usage Examples](../reference/cli.md#examples).
|
||||
view serverless batches.
|
||||
* **Tools:**
|
||||
* `list_batches`: Lists Spark batches.
|
||||
* `get_batch`: Gets information about a Spark batch.
|
||||
* `cancel_batch`: Cancels a Spark batch.
|
||||
* `create_pyspark_batch`: Creates a PySpark batch.
|
||||
* `create_spark_batch`: Creates a Spark batch.
|
||||
|
||||
## SingleStore
|
||||
|
||||
* `--prebuilt` value: `singlestore`
|
||||
* **Environment Variables:**
|
||||
* `SINGLESTORE_HOST`: The hostname or IP address of the SingleStore server.
|
||||
* `SINGLESTORE_PORT`: The port number of the SingleStore server.
|
||||
* `SINGLESTORE_DATABASE`: The name of the database to connect to.
|
||||
* `SINGLESTORE_USER`: The database username.
|
||||
* `SINGLESTORE_PASSWORD`: The password for the database user.
|
||||
* **Tools:**
|
||||
* `execute_sql`: Use this tool to execute SQL.
|
||||
* `list_tables`: Lists detailed schema information for user-created tables.
|
||||
|
||||
## Snowflake
|
||||
|
||||
* `--prebuilt` value: `snowflake`
|
||||
* **Environment Variables:**
|
||||
* `SNOWFLAKE_ACCOUNT`: The Snowflake account.
|
||||
* `SNOWFLAKE_USER`: The database username.
|
||||
* `SNOWFLAKE_PASSWORD`: The password for the database user.
|
||||
* `SNOWFLAKE_DATABASE`: The name of the database to connect to.
|
||||
* `SNOWFLAKE_SCHEMA`: The schema name.
|
||||
* `SNOWFLAKE_WAREHOUSE`: The warehouse name.
|
||||
* `SNOWFLAKE_ROLE`: The role name.
|
||||
* **Tools:**
|
||||
* `execute_sql`: Use this tool to execute SQL.
|
||||
* `list_tables`: Lists detailed schema information for user-created tables.
|
||||
|
||||
## Spanner (GoogleSQL dialect)
|
||||
|
||||
|
||||
17
packages/release_dep_packages.sh
Normal file
17
packages/release_dep_packages.sh
Normal file
@@ -0,0 +1,17 @@
|
||||
cd server-darwin-arm64
|
||||
npm pack .
|
||||
npm publish --access public
|
||||
|
||||
cd ../server-darwin-x64
|
||||
npm pack .
|
||||
npm publish --access public
|
||||
|
||||
cd ../server-linux-x64
|
||||
npm pack .
|
||||
npm publish --access public
|
||||
|
||||
cd ../server-win32-x64
|
||||
npm pack .
|
||||
npm publish --access public
|
||||
|
||||
cd ..
|
||||
7
packages/release_server_package.sh
Normal file
7
packages/release_server_package.sh
Normal file
@@ -0,0 +1,7 @@
|
||||
cd server
|
||||
npm install --package-lock-only
|
||||
git add package.json package-lock.json
|
||||
git commit -m "update dep versions"
|
||||
|
||||
npm pack .
|
||||
npm publish --access public
|
||||
6
packages/server-darwin-arm64/README.md
Normal file
6
packages/server-darwin-arm64/README.md
Normal file
@@ -0,0 +1,6 @@
|
||||
# @toolbox-sdk/server-darwin-arm64
|
||||
|
||||
Platform-specific binary for the `toolbox` package on Darwin arm64.
|
||||
This package is automatically installed by the main `@toolbox-sdk/server` package and is not intended to be installed directly.
|
||||
|
||||
For more information, visit the [toolbox npm package](https://www.npmjs.com/package/@toolbox-sdk/server).
|
||||
19
packages/server-darwin-arm64/package-lock.json
generated
Normal file
19
packages/server-darwin-arm64/package-lock.json
generated
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "@toolbox-sdk/server-darwin-arm64",
|
||||
"version": "0.27.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@toolbox-sdk/server-darwin-arm64",
|
||||
"version": "0.27.0",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"os": [
|
||||
"darwin"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
20
packages/server-darwin-arm64/package.json
Normal file
20
packages/server-darwin-arm64/package.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "@toolbox-sdk/server-darwin-arm64",
|
||||
"version": "0.27.0",
|
||||
"license": "Apache-2.0",
|
||||
"author": "Google LLC",
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"main": "bin/toolbox",
|
||||
"repository": "googleapis/genai-toolbox",
|
||||
"scripts": {
|
||||
"prepack": "node scripts/downloadBinary.js darwin arm64"
|
||||
},
|
||||
"files": [
|
||||
"bin/toolbox"
|
||||
]
|
||||
}
|
||||
85
packages/server-darwin-arm64/scripts/downloadBinary.js
Normal file
85
packages/server-darwin-arm64/scripts/downloadBinary.js
Normal file
@@ -0,0 +1,85 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const https = require('https');
|
||||
const { execSync } = require('child_process');
|
||||
|
||||
// 1. Configuration
|
||||
const PLATFORM_MAP = {
|
||||
'linux': 'linux',
|
||||
'darwin': 'darwin',
|
||||
'win32': 'windows'
|
||||
};
|
||||
|
||||
const ARCH_MAP = {
|
||||
'x64': 'amd64',
|
||||
'arm64': 'arm64'
|
||||
};
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
if (args.length < 2) {
|
||||
console.error("Usage: node download-binary.js <platform> <arch>");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const [targetPlatform, targetArch] = args;
|
||||
|
||||
// 2. Determine Version
|
||||
const version = fs.readFileSync(path.join(process.cwd(), 'version.txt'), 'utf8').trim();
|
||||
|
||||
// 3. Construct URL
|
||||
const gcsPlatform = PLATFORM_MAP[targetPlatform];
|
||||
const gcsArch = ARCH_MAP[targetArch];
|
||||
|
||||
if (!gcsPlatform || !gcsArch) {
|
||||
console.error(`Unsupported platform/arch: ${targetPlatform}/${targetArch}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const extension = targetPlatform === 'win32' ? '.exe' : '';
|
||||
const binaryName = `toolbox${extension}`;
|
||||
const url = `https://storage.googleapis.com/genai-toolbox/v${version}/${gcsPlatform}/${gcsArch}/${binaryName}`;
|
||||
|
||||
// 4. Prepare Output
|
||||
const binDir = path.join(process.cwd(), 'bin');
|
||||
if (!fs.existsSync(binDir)) {
|
||||
fs.mkdirSync(binDir, { recursive: true });
|
||||
}
|
||||
const destPath = path.join(binDir, binaryName);
|
||||
|
||||
if (fs.existsSync(destPath)) {
|
||||
console.log(`[Skipped] Binary already exists at ${destPath}`);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
console.log(`[Prepack] Downloading ${binaryName} for ${targetPlatform}/${targetArch}...`);
|
||||
console.log(`[Source] ${url}`);
|
||||
|
||||
// 5. Download Function
|
||||
const file = fs.createWriteStream(destPath);
|
||||
https.get(url, function(response) {
|
||||
if (response.statusCode !== 200) {
|
||||
console.error(`❌ Failed to download. Status Code: ${response.statusCode}`);
|
||||
fs.unlink(destPath, () => {}); // Delete partial file
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
response.pipe(file);
|
||||
|
||||
file.on('finish', () => {
|
||||
file.close(() => {
|
||||
// 6. Make executable (Unix only)
|
||||
if (targetPlatform !== 'win32') {
|
||||
try {
|
||||
execSync(`chmod +x "${destPath}"`);
|
||||
} catch (err) {
|
||||
console.warn("⚠️ Could not set executable permissions (chmod failed).");
|
||||
}
|
||||
}
|
||||
console.log(`✅ Success! Binary saved to ${destPath}`);
|
||||
});
|
||||
});
|
||||
}).on('error', function(err) {
|
||||
fs.unlink(destPath, () => {});
|
||||
console.error(`❌ Download Error: ${err.message}`);
|
||||
process.exit(1);
|
||||
});
|
||||
1
packages/server-darwin-arm64/version.txt
Normal file
1
packages/server-darwin-arm64/version.txt
Normal file
@@ -0,0 +1 @@
|
||||
0.27.0
|
||||
6
packages/server-darwin-x64/README.md
Normal file
6
packages/server-darwin-x64/README.md
Normal file
@@ -0,0 +1,6 @@
|
||||
# @toolbox-sdk/server-darwin-x64
|
||||
|
||||
Platform-specific binary for the `toolbox` package on Darwin x64.
|
||||
This package is automatically installed by the main `@toolbox-sdk/server` package and is not intended to be installed directly.
|
||||
|
||||
For more information, visit the [toolbox npm package](https://www.npmjs.com/package/@toolbox-sdk/server).
|
||||
19
packages/server-darwin-x64/package-lock.json
generated
Normal file
19
packages/server-darwin-x64/package-lock.json
generated
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "@toolbox-sdk/server-darwin-x64",
|
||||
"version": "0.27.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@toolbox-sdk/server-darwin-x64",
|
||||
"version": "0.27.0",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"os": [
|
||||
"darwin"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
20
packages/server-darwin-x64/package.json
Normal file
20
packages/server-darwin-x64/package.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "@toolbox-sdk/server-darwin-x64",
|
||||
"version": "0.27.0",
|
||||
"license": "Apache-2.0",
|
||||
"author": "Google LLC",
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"main": "bin/toolbox",
|
||||
"repository": "googleapis/genai-toolbox",
|
||||
"scripts": {
|
||||
"prepack": "node scripts/downloadBinary.js darwin x64"
|
||||
},
|
||||
"files": [
|
||||
"bin/toolbox"
|
||||
]
|
||||
}
|
||||
85
packages/server-darwin-x64/scripts/downloadBinary.js
Normal file
85
packages/server-darwin-x64/scripts/downloadBinary.js
Normal file
@@ -0,0 +1,85 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const https = require('https');
|
||||
const { execSync } = require('child_process');
|
||||
|
||||
// 1. Configuration
|
||||
const PLATFORM_MAP = {
|
||||
'linux': 'linux',
|
||||
'darwin': 'darwin',
|
||||
'win32': 'windows'
|
||||
};
|
||||
|
||||
const ARCH_MAP = {
|
||||
'x64': 'amd64',
|
||||
'arm64': 'arm64'
|
||||
};
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
if (args.length < 2) {
|
||||
console.error("Usage: node download-binary.js <platform> <arch>");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const [targetPlatform, targetArch] = args;
|
||||
|
||||
// 2. Determine Version
|
||||
const version = fs.readFileSync(path.join(process.cwd(), 'version.txt'), 'utf8').trim();
|
||||
|
||||
// 3. Construct URL
|
||||
const gcsPlatform = PLATFORM_MAP[targetPlatform];
|
||||
const gcsArch = ARCH_MAP[targetArch];
|
||||
|
||||
if (!gcsPlatform || !gcsArch) {
|
||||
console.error(`Unsupported platform/arch: ${targetPlatform}/${targetArch}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const extension = targetPlatform === 'win32' ? '.exe' : '';
|
||||
const binaryName = `toolbox${extension}`;
|
||||
const url = `https://storage.googleapis.com/genai-toolbox/v${version}/${gcsPlatform}/${gcsArch}/${binaryName}`;
|
||||
|
||||
// 4. Prepare Output
|
||||
const binDir = path.join(process.cwd(), 'bin');
|
||||
if (!fs.existsSync(binDir)) {
|
||||
fs.mkdirSync(binDir, { recursive: true });
|
||||
}
|
||||
const destPath = path.join(binDir, binaryName);
|
||||
|
||||
if (fs.existsSync(destPath)) {
|
||||
console.log(`[Skipped] Binary already exists at ${destPath}`);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
console.log(`[Prepack] Downloading ${binaryName} for ${targetPlatform}/${targetArch}...`);
|
||||
console.log(`[Source] ${url}`);
|
||||
|
||||
// 5. Download Function
|
||||
const file = fs.createWriteStream(destPath);
|
||||
https.get(url, function(response) {
|
||||
if (response.statusCode !== 200) {
|
||||
console.error(`❌ Failed to download. Status Code: ${response.statusCode}`);
|
||||
fs.unlink(destPath, () => {}); // Delete partial file
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
response.pipe(file);
|
||||
|
||||
file.on('finish', () => {
|
||||
file.close(() => {
|
||||
// 6. Make executable (Unix only)
|
||||
if (targetPlatform !== 'win32') {
|
||||
try {
|
||||
execSync(`chmod +x "${destPath}"`);
|
||||
} catch (err) {
|
||||
console.warn("⚠️ Could not set executable permissions (chmod failed).");
|
||||
}
|
||||
}
|
||||
console.log(`✅ Success! Binary saved to ${destPath}`);
|
||||
});
|
||||
});
|
||||
}).on('error', function(err) {
|
||||
fs.unlink(destPath, () => {});
|
||||
console.error(`❌ Download Error: ${err.message}`);
|
||||
process.exit(1);
|
||||
});
|
||||
1
packages/server-darwin-x64/version.txt
Normal file
1
packages/server-darwin-x64/version.txt
Normal file
@@ -0,0 +1 @@
|
||||
0.27.0
|
||||
7
packages/server-linux-x64/README.md
Normal file
7
packages/server-linux-x64/README.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# @toolbox-sdk/server-linux-x64
|
||||
|
||||
Platform-specific binary for the `toolbox` package on Linux x64.
|
||||
This package is automatically installed by the main `@toolbox-sdk/server` package and is not intended to be installed directly.
|
||||
|
||||
For more information, visit the [toolbox npm package](https://www.npmjs.com/package/@toolbox-sdk/server).
|
||||
|
||||
19
packages/server-linux-x64/package-lock.json
generated
Normal file
19
packages/server-linux-x64/package-lock.json
generated
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "@toolbox-sdk/server-linux-x64",
|
||||
"version": "0.27.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@toolbox-sdk/server-linux-x64",
|
||||
"version": "0.27.0",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"os": [
|
||||
"linux"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
20
packages/server-linux-x64/package.json
Normal file
20
packages/server-linux-x64/package.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "@toolbox-sdk/server-linux-x64",
|
||||
"version": "0.27.0",
|
||||
"license": "Apache-2.0",
|
||||
"author": "Google LLC",
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"main": "bin/toolbox",
|
||||
"repository": "googleapis/genai-toolbox",
|
||||
"scripts": {
|
||||
"prepack": "node scripts/downloadBinary.js linux x64"
|
||||
},
|
||||
"files": [
|
||||
"bin/toolbox"
|
||||
]
|
||||
}
|
||||
85
packages/server-linux-x64/scripts/downloadBinary.js
Normal file
85
packages/server-linux-x64/scripts/downloadBinary.js
Normal file
@@ -0,0 +1,85 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const https = require('https');
|
||||
const { execSync } = require('child_process');
|
||||
|
||||
// 1. Configuration
|
||||
const PLATFORM_MAP = {
|
||||
'linux': 'linux',
|
||||
'darwin': 'darwin',
|
||||
'win32': 'windows'
|
||||
};
|
||||
|
||||
const ARCH_MAP = {
|
||||
'x64': 'amd64',
|
||||
'arm64': 'arm64'
|
||||
};
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
if (args.length < 2) {
|
||||
console.error("Usage: node download-binary.js <platform> <arch>");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const [targetPlatform, targetArch] = args;
|
||||
|
||||
// 2. Determine Version
|
||||
const version = fs.readFileSync(path.join(process.cwd(), 'version.txt'), 'utf8').trim();
|
||||
|
||||
// 3. Construct URL
|
||||
const gcsPlatform = PLATFORM_MAP[targetPlatform];
|
||||
const gcsArch = ARCH_MAP[targetArch];
|
||||
|
||||
if (!gcsPlatform || !gcsArch) {
|
||||
console.error(`Unsupported platform/arch: ${targetPlatform}/${targetArch}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const extension = targetPlatform === 'win32' ? '.exe' : '';
|
||||
const binaryName = `toolbox${extension}`;
|
||||
const url = `https://storage.googleapis.com/genai-toolbox/v${version}/${gcsPlatform}/${gcsArch}/${binaryName}`;
|
||||
|
||||
// 4. Prepare Output
|
||||
const binDir = path.join(process.cwd(), 'bin');
|
||||
if (!fs.existsSync(binDir)) {
|
||||
fs.mkdirSync(binDir, { recursive: true });
|
||||
}
|
||||
const destPath = path.join(binDir, binaryName);
|
||||
|
||||
if (fs.existsSync(destPath)) {
|
||||
console.log(`[Skipped] Binary already exists at ${destPath}`);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
console.log(`[Prepack] Downloading ${binaryName} for ${targetPlatform}/${targetArch}...`);
|
||||
console.log(`[Source] ${url}`);
|
||||
|
||||
// 5. Download Function
|
||||
const file = fs.createWriteStream(destPath);
|
||||
https.get(url, function(response) {
|
||||
if (response.statusCode !== 200) {
|
||||
console.error(`❌ Failed to download. Status Code: ${response.statusCode}`);
|
||||
fs.unlink(destPath, () => {}); // Delete partial file
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
response.pipe(file);
|
||||
|
||||
file.on('finish', () => {
|
||||
file.close(() => {
|
||||
// 6. Make executable (Unix only)
|
||||
if (targetPlatform !== 'win32') {
|
||||
try {
|
||||
execSync(`chmod +x "${destPath}"`);
|
||||
} catch (err) {
|
||||
console.warn("⚠️ Could not set executable permissions (chmod failed).");
|
||||
}
|
||||
}
|
||||
console.log(`✅ Success! Binary saved to ${destPath}`);
|
||||
});
|
||||
});
|
||||
}).on('error', function(err) {
|
||||
fs.unlink(destPath, () => {});
|
||||
console.error(`❌ Download Error: ${err.message}`);
|
||||
process.exit(1);
|
||||
});
|
||||
1
packages/server-linux-x64/version.txt
Normal file
1
packages/server-linux-x64/version.txt
Normal file
@@ -0,0 +1 @@
|
||||
0.27.0
|
||||
7
packages/server-win32-x64/README.md
Normal file
7
packages/server-win32-x64/README.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# @toolbox-sdk/server-win32-x64
|
||||
|
||||
Platform-specific binary for the `toolbox` package on Windows x64.
|
||||
This package is automatically installed by the main `@toolbox-sdk/server` package and is not intended to be installed directly.
|
||||
|
||||
For more information, visit the [toolbox npm package](https://www.npmjs.com/package/@toolbox-sdk/server).
|
||||
|
||||
19
packages/server-win32-x64/package-lock.json
generated
Normal file
19
packages/server-win32-x64/package-lock.json
generated
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "@toolbox-sdk/server-win32-x64",
|
||||
"version": "0.27.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@toolbox-sdk/server-win32-x64",
|
||||
"version": "0.27.0",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"os": [
|
||||
"win32"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
20
packages/server-win32-x64/package.json
Normal file
20
packages/server-win32-x64/package.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "@toolbox-sdk/server-win32-x64",
|
||||
"version": "0.27.0",
|
||||
"license": "Apache-2.0",
|
||||
"author": "Google LLC",
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"main": "bin/toolbox.exe",
|
||||
"repository": "googleapis/genai-toolbox",
|
||||
"scripts": {
|
||||
"prepack": "node scripts/downloadBinary.js win32 x64"
|
||||
},
|
||||
"files": [
|
||||
"bin/toolbox.exe"
|
||||
]
|
||||
}
|
||||
85
packages/server-win32-x64/scripts/downloadBinary.js
Normal file
85
packages/server-win32-x64/scripts/downloadBinary.js
Normal file
@@ -0,0 +1,85 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const https = require('https');
|
||||
const { execSync } = require('child_process');
|
||||
|
||||
// 1. Configuration
|
||||
const PLATFORM_MAP = {
|
||||
'linux': 'linux',
|
||||
'darwin': 'darwin',
|
||||
'win32': 'windows'
|
||||
};
|
||||
|
||||
const ARCH_MAP = {
|
||||
'x64': 'amd64',
|
||||
'arm64': 'arm64'
|
||||
};
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
if (args.length < 2) {
|
||||
console.error("Usage: node download-binary.js <platform> <arch>");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const [targetPlatform, targetArch] = args;
|
||||
|
||||
// 2. Determine Version
|
||||
const version = fs.readFileSync(path.join(process.cwd(), 'version.txt'), 'utf8').trim();
|
||||
|
||||
// 3. Construct URL
|
||||
const gcsPlatform = PLATFORM_MAP[targetPlatform];
|
||||
const gcsArch = ARCH_MAP[targetArch];
|
||||
|
||||
if (!gcsPlatform || !gcsArch) {
|
||||
console.error(`Unsupported platform/arch: ${targetPlatform}/${targetArch}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const extension = targetPlatform === 'win32' ? '.exe' : '';
|
||||
const binaryName = `toolbox${extension}`;
|
||||
const url = `https://storage.googleapis.com/genai-toolbox/v${version}/${gcsPlatform}/${gcsArch}/${binaryName}`;
|
||||
|
||||
// 4. Prepare Output
|
||||
const binDir = path.join(process.cwd(), 'bin');
|
||||
if (!fs.existsSync(binDir)) {
|
||||
fs.mkdirSync(binDir, { recursive: true });
|
||||
}
|
||||
const destPath = path.join(binDir, binaryName);
|
||||
|
||||
if (fs.existsSync(destPath)) {
|
||||
console.log(`[Skipped] Binary already exists at ${destPath}`);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
console.log(`[Prepack] Downloading ${binaryName} for ${targetPlatform}/${targetArch}...`);
|
||||
console.log(`[Source] ${url}`);
|
||||
|
||||
// 5. Download Function
|
||||
const file = fs.createWriteStream(destPath);
|
||||
https.get(url, function(response) {
|
||||
if (response.statusCode !== 200) {
|
||||
console.error(`❌ Failed to download. Status Code: ${response.statusCode}`);
|
||||
fs.unlink(destPath, () => {}); // Delete partial file
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
response.pipe(file);
|
||||
|
||||
file.on('finish', () => {
|
||||
file.close(() => {
|
||||
// 6. Make executable (Unix only)
|
||||
if (targetPlatform !== 'win32') {
|
||||
try {
|
||||
execSync(`chmod +x "${destPath}"`);
|
||||
} catch (err) {
|
||||
console.warn("⚠️ Could not set executable permissions (chmod failed).");
|
||||
}
|
||||
}
|
||||
console.log(`✅ Success! Binary saved to ${destPath}`);
|
||||
});
|
||||
});
|
||||
}).on('error', function(err) {
|
||||
fs.unlink(destPath, () => {});
|
||||
console.error(`❌ Download Error: ${err.message}`);
|
||||
process.exit(1);
|
||||
});
|
||||
1
packages/server-win32-x64/version.txt
Normal file
1
packages/server-win32-x64/version.txt
Normal file
@@ -0,0 +1 @@
|
||||
0.27.0
|
||||
69
packages/server/README.md
Normal file
69
packages/server/README.md
Normal file
@@ -0,0 +1,69 @@
|
||||
# Toolbox
|
||||
|
||||
A CLI tool for running a toolbox server.
|
||||
|
||||
## Installation
|
||||
|
||||
You can install the toolbox globally:
|
||||
|
||||
```bash
|
||||
npm install -g @toolbox-sdk/server
|
||||
```
|
||||
|
||||
Or run it directly using npx:
|
||||
|
||||
```bash
|
||||
npx @toolbox-sdk/server
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
The toolbox requires a `tools.yaml` file in the current working directory to define sources, tools, and prompts.
|
||||
|
||||
### Example `tools.yaml`
|
||||
|
||||
```yaml
|
||||
sources:
|
||||
my-pg-source:
|
||||
kind: postgres
|
||||
host: 127.0.0.1
|
||||
port: 5432
|
||||
database: toolbox_db
|
||||
user: postgres
|
||||
password: password
|
||||
tools:
|
||||
search-hotels-by-name:
|
||||
kind: 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 || '%';
|
||||
prompts:
|
||||
code-review:
|
||||
description: "Asks the LLM to analyze code quality and suggest improvements."
|
||||
messages:
|
||||
- role: "user"
|
||||
content: "Please review the following code for quality, correctness, and potential improvements: \n\n{{.code}}"
|
||||
arguments:
|
||||
- name: "code"
|
||||
description: "The code to review"
|
||||
required: true
|
||||
```
|
||||
|
||||
To learn more on how to configure your toolbox, visit the [official docsite](https://googleapis.github.io/genai-toolbox/getting-started/configure/).
|
||||
|
||||
## Platform Support
|
||||
|
||||
The toolbox automatically handles platform-specific binaries. Supported platforms include:
|
||||
- macOS (arm64, x64)
|
||||
- Linux (x64)
|
||||
- Windows (x64)
|
||||
|
||||
## Resources
|
||||
|
||||
For more information, visit the
|
||||
- [MCP Toolbox repository](https://github.com/googleapis/genai-toolbox)
|
||||
- [Official Documentation](https://googleapis.github.io/genai-toolbox/getting-started/introduction/)
|
||||
49
packages/server/bin/run.js
Executable file
49
packages/server/bin/run.js
Executable file
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env node
|
||||
const { spawn } = require('child_process');
|
||||
const path = require('path');
|
||||
const os = require('os');
|
||||
const fs = require('fs');
|
||||
|
||||
const PLATFORMS = {
|
||||
'darwin-arm64': '@toolbox-sdk/server-darwin-arm64',
|
||||
'darwin-x64': '@toolbox-sdk/server-darwin-x64',
|
||||
'linux-x64': '@toolbox-sdk/server-linux-x64',
|
||||
'win32-x64': '@toolbox-sdk/server-win32-x64'
|
||||
};
|
||||
|
||||
const currentKey = `${os.platform()}-${os.arch()}`;
|
||||
const pkgName = PLATFORMS[currentKey];
|
||||
|
||||
if (!pkgName) {
|
||||
console.error(`Unsupported platform: ${currentKey}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
let binPath;
|
||||
try {
|
||||
const pkgJsonPath = require.resolve(`${pkgName}/package.json`);
|
||||
const pkgDir = path.dirname(pkgJsonPath);
|
||||
const binName = os.platform() === 'win32' ? 'toolbox.exe' : 'toolbox';
|
||||
binPath = path.join(pkgDir, 'bin', binName);
|
||||
} catch (e) {
|
||||
console.error(`Binary for ${currentKey} not found. Installation failed?`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (os.platform() !== 'win32') {
|
||||
try {
|
||||
fs.chmodSync(binPath, 0o755);
|
||||
if (os.platform() === 'darwin') {
|
||||
const { execSync } = require('child_process');
|
||||
try {
|
||||
execSync(`xattr -d com.apple.quarantine "${binPath}"`, { stdio: 'ignore' });
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(`Could not set execute permissions on ${binPath}: ${e.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
spawn(binPath, process.argv.slice(2), { stdio: 'inherit' })
|
||||
.on('exit', process.exit);
|
||||
74
packages/server/package-lock.json
generated
Normal file
74
packages/server/package-lock.json
generated
Normal file
@@ -0,0 +1,74 @@
|
||||
{
|
||||
"name": "@toolbox-sdk/server",
|
||||
"version": "0.27.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@toolbox-sdk/server",
|
||||
"version": "0.27.0",
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"toolbox": "bin/run.js"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@toolbox-sdk/server-darwin-arm64": "0.27.0",
|
||||
"@toolbox-sdk/server-darwin-x64": "0.27.0",
|
||||
"@toolbox-sdk/server-linux-x64": "0.27.0",
|
||||
"@toolbox-sdk/server-win32-x64": "0.27.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@toolbox-sdk/server-darwin-arm64": {
|
||||
"version": "0.27.0",
|
||||
"resolved": "https://registry.npmjs.org/@toolbox-sdk/server-darwin-arm64/-/server-darwin-arm64-0.27.0.tgz",
|
||||
"integrity": "sha512-qGP7t4JCS9TgQTySA7WnFbrebc9CgZNfQUdlmHdCVw1ZbH+xE5eABalLkeMvDJUmevpTy51G3osxRyh3eVDCnQ==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
]
|
||||
},
|
||||
"node_modules/@toolbox-sdk/server-darwin-x64": {
|
||||
"version": "0.27.0",
|
||||
"resolved": "https://registry.npmjs.org/@toolbox-sdk/server-darwin-x64/-/server-darwin-x64-0.27.0.tgz",
|
||||
"integrity": "sha512-ZdHHSbJRt4YmKteuFXRQzixpzHz3q5xqQFv1KUQlLDpjIw8duOTFoA22EZtDssSh74oxVlU/X5yWPT9ED59W2g==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
]
|
||||
},
|
||||
"node_modules/@toolbox-sdk/server-linux-x64": {
|
||||
"version": "0.27.0",
|
||||
"resolved": "https://registry.npmjs.org/@toolbox-sdk/server-linux-x64/-/server-linux-x64-0.27.0.tgz",
|
||||
"integrity": "sha512-XJoUBIFoi02KQuiv7X8XP/eZAigk3sPnfBCtQVZ8zIl5NdbxGKyIYMUj0I8aYwpSk/8pAzow4YqryiIWeMP9aA==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
]
|
||||
},
|
||||
"node_modules/@toolbox-sdk/server-win32-x64": {
|
||||
"version": "0.27.0",
|
||||
"resolved": "https://registry.npmjs.org/@toolbox-sdk/server-win32-x64/-/server-win32-x64-0.27.0.tgz",
|
||||
"integrity": "sha512-xedHjbIRtpxn/x64D8Us8APEGuiXTqABWsQfubcDr4KOD+pnH1vyBZbiCgXRFIEKAeUSYVEMgDPxwUTV6TOlKg==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
19
packages/server/package.json
Normal file
19
packages/server/package.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "@toolbox-sdk/server",
|
||||
"version": "0.27.0",
|
||||
"license": "Apache-2.0",
|
||||
"author": "Google LLC",
|
||||
"bin": {
|
||||
"toolbox": "./bin/run.js"
|
||||
},
|
||||
"files": [
|
||||
"bin/run.js"
|
||||
],
|
||||
"repository": "googleapis/genai-toolbox",
|
||||
"optionalDependencies": {
|
||||
"@toolbox-sdk/server-darwin-arm64": "0.27.0",
|
||||
"@toolbox-sdk/server-darwin-x64": "0.27.0",
|
||||
"@toolbox-sdk/server-linux-x64": "0.27.0",
|
||||
"@toolbox-sdk/server-win32-x64": "0.27.0"
|
||||
}
|
||||
}
|
||||
91
packages/testing.md
Normal file
91
packages/testing.md
Normal file
@@ -0,0 +1,91 @@
|
||||
# How to test on different platforms
|
||||
|
||||
1. Create a local test registry. We are using Verdaccio. During the actual process, we publish to npm instead.
|
||||
```sh
|
||||
# install
|
||||
npm install -g verdaccio
|
||||
|
||||
# start server
|
||||
verdaccio
|
||||
```
|
||||
|
||||
The output will show the config file location and the URL. Open your browser to:
|
||||
http://localhost:4873
|
||||
|
||||
> Note: You can use `npm unpublish @toolbox-sdk/server --force --registry http://localhost:4873` to unpublish the package.
|
||||
|
||||
2. Pack all 4 packages and publish them to the local registry. Go in each package (eg. server-darwin-arm64) and run
|
||||
```sh
|
||||
npm ci --force
|
||||
npm pack .
|
||||
```
|
||||
|
||||
Then publish to the local registry
|
||||
```sh
|
||||
npm publish --registry http://localhost:4873
|
||||
```
|
||||
|
||||
3. Go to the server package and run
|
||||
```sh
|
||||
npm ci --force
|
||||
npm pack .
|
||||
npm publish --registry http://localhost:4873
|
||||
```
|
||||
|
||||
Now, you have published your package.
|
||||
|
||||
4. Now create a new folder (let's call it testing.) Add a tools.yaml file to the folder. It should look like this:
|
||||
```yaml
|
||||
sources:
|
||||
my-pg-source:
|
||||
kind: postgres
|
||||
host: 127.0.0.1
|
||||
port: 5432
|
||||
database: toolbox_db
|
||||
user: postgres
|
||||
password: password
|
||||
tools:
|
||||
search-hotels-by-name:
|
||||
kind: 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 || '%';
|
||||
prompts:
|
||||
code-review:
|
||||
description: "Asks the LLM to analyze code quality and suggest improvements."
|
||||
messages:
|
||||
- role: "user"
|
||||
content: "Please review the following code for quality, correctness, and potential improvements: \n\n{{.code}}"
|
||||
arguments:
|
||||
- name: "code"
|
||||
description: "The code to review"
|
||||
required: true
|
||||
```
|
||||
|
||||
Note: Do not test this directly to the server folder. The registry might pick up local packages instead of global installation.
|
||||
Use a separate testing folder outside the server folder for this testing.
|
||||
|
||||
6. From the testing folder, run
|
||||
```sh
|
||||
npx --registry=http://localhost:4873/ -y @toolbox-sdk/server
|
||||
```
|
||||
|
||||
This should start up the toolbox server with the tools.yaml file.
|
||||
|
||||
7. Run the command to verify that the tools are available:
|
||||
|
||||
```sh
|
||||
curl --location 'http://127.0.0.1:5000/mcp' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data '{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "tools/list",
|
||||
"params": {},
|
||||
"id": 1
|
||||
}'
|
||||
|
||||
```
|
||||
23
packages/update_dep_packages.sh
Executable file
23
packages/update_dep_packages.sh
Executable file
@@ -0,0 +1,23 @@
|
||||
cd server-darwin-arm64
|
||||
npm install --force
|
||||
rm -rf bin/
|
||||
git add version.txt package.json package-lock.json
|
||||
|
||||
cd ../server-darwin-x64
|
||||
npm install --force
|
||||
rm -rf bin/
|
||||
git add version.txt package.json package-lock.json
|
||||
|
||||
|
||||
cd ../server-linux-x64
|
||||
npm install --force
|
||||
rm -rf bin/
|
||||
git add version.txt package.json package-lock.json
|
||||
|
||||
|
||||
cd ../server-win32-x64
|
||||
npm install --force
|
||||
rm -rf bin/
|
||||
git add version.txt package.json package-lock.json
|
||||
|
||||
cd ..
|
||||
@@ -36,17 +36,15 @@ var (
|
||||
AlloyDBDatabase = "postgres"
|
||||
)
|
||||
|
||||
func buildPostgresURL(host, port, user, pass, dbname string) *url.URL {
|
||||
return &url.URL{
|
||||
// Copied over from postgres.go
|
||||
func initPostgresConnectionPool(host, port, user, pass, dbname string) (*pgxpool.Pool, error) {
|
||||
// urlExample := "postgres:dd//username:password@localhost:5432/database_name"
|
||||
url := &url.URL{
|
||||
Scheme: "postgres",
|
||||
User: url.UserPassword(user, pass),
|
||||
Host: fmt.Sprintf("%s:%s", host, port),
|
||||
Path: dbname,
|
||||
}
|
||||
}
|
||||
|
||||
func initPostgresConnectionPool(host, port, user, pass, dbname string) (*pgxpool.Pool, error) {
|
||||
url := buildPostgresURL(host, port, user, pass, dbname)
|
||||
pool, err := pgxpool.New(context.Background(), url.String())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Unable to create connection pool: %w", err)
|
||||
@@ -65,8 +63,7 @@ func setupAlloyDBContainer(ctx context.Context, t *testing.T) (string, string, f
|
||||
"POSTGRES_PASSWORD": AlloyDBPass,
|
||||
},
|
||||
WaitingFor: wait.ForAll(
|
||||
wait.ForLog("database system was shut down at"),
|
||||
wait.ForLog("database system is ready to accept connections"),
|
||||
wait.ForLog("Post Startup: Successfully reinstalled extensions"),
|
||||
wait.ForExposedPort(),
|
||||
),
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
package bigtable
|
||||
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
package clickhouse
|
||||
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
package cloudmonitoring
|
||||
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
Reference in New Issue
Block a user