Commit Graph

28 Commits

Author SHA1 Message Date
Wenxin Du
17b70ccaa7 feat(tools/postgressql): Add Parameter embeddedBy config support (#2151)
Add parameter `embeddedBy` field to support vector embedding & semantic
search.
Major change in `internal/util/parameters/parameters.go`

This PR only adds vector formatter for the postgressql tool. Other tools
requiring vector formatting may not work with embeddedBy.

Second part of the Semantic Search support. First part:
https://github.com/googleapis/genai-toolbox/pull/2121
2026-01-06 17:54:43 -05:00
Yuan Teoh
967a72da11 refactor: decouple Source from Tool (#2204)
This PR update the linking mechanism between Source and Tool.

Tools are directly linked to their Source, either by pointing to the
Source's functions or by assigning values from the source during Tool's
initialization. However, the existing approach means that any
modification to the Source after Tool's initialization might not be
reflected. To address this limitation, each tool should only store a
name reference to the Source, rather than direct link or assigned
values.

Tools will provide interface for `compatibleSource`. This will be used
to determine if a Source is compatible with the Tool.
```
type compatibleSource interface{
    Client() http.Client
    ProjectID() string
}
```

During `Invoke()`, the tool will run the following operations:
* retrieve Source from the `resourceManager` with source's named defined
in Tool's config
* validate Source via `compatibleSource interface{}`
* run the remaining `Invoke()` function. Fields that are needed is
retrieved directly from the source.

With this update, resource manager is also added as input to other
Tool's function that require access to source (e.g.
`RequiresClientAuthorization()`).
2025-12-19 21:27:55 -08:00
Yuan Teoh
f59a06bd10 chore: add new argument to invoke() and RequiresClientAuthorization() (#2000)
## Description

Tool `invoke()` and `RequiresClientAuthorization()` takes a new input
argument -- Resource Manager. Resource manager will be used to retrieve
Source in the next step.

In order to achieve the goal, this PR implements the follows:
* move resource manager from the server package to a new package to
prevent import cycles (between server and mcp)
* added a new interface in `tools.go` to prevent import cycle (between
resources and tools package)
* add new input argument in all tools

## PR Checklist

> Thank you for opening a Pull Request! Before submitting your PR, there
are a
> few things you can do to make sure it goes smoothly:

- [x] Make sure you reviewed

[CONTRIBUTING.md](https://github.com/googleapis/genai-toolbox/blob/main/CONTRIBUTING.md)
- [x] Make sure to open an issue as a

[bug/issue](https://github.com/googleapis/genai-toolbox/issues/new/choose)
  before writing your code! That way we can discuss the change, evaluate
  designs, and agree on the general idea
- [x] Ensure the tests and linter pass
- [x] Code coverage does not decrease (if any source code was changed)
- [x] Appropriate docs were updated (if necessary)
- [x] Make sure to add `!` if this involve a breaking change
2025-11-29 02:46:15 -08:00
Dr. Strangelove
ac21335f4e feat: support for annotations (#2007)
## Description

The MCP spec supports tool annotations like the below structure in the
2025-06-18 version of the spec.

https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations

```
{
  destructiveHint?: boolean;
  idempotentHint?: boolean;
  openWorldHint?: boolean;
  readOnlyHint?: boolean;
}
```

Added a ToolAnnotations structure, an Annotations member to the
McpManifest structure, and a nil initializer for the Annotations member
to all calls to GetMcpManifest.

The ToolAnnotations structure and the member annotations are all defined
as pointers so that they are omited when not set. There are times when
the zero value is meaningful so this was the only way to make sure that
we distinguish between not setting the annotation and setting it with a
zero value.

## PR Checklist

> Thank you for opening a Pull Request! Before submitting your PR, there
are a
> few things you can do to make sure it goes smoothly:

- [x] Make sure you reviewed

[CONTRIBUTING.md](https://github.com/googleapis/genai-toolbox/blob/main/CONTRIBUTING.md)
- [x] Make sure to open an issue as a

[bug/issue](https://github.com/googleapis/genai-toolbox/issues/new/choose)
  before writing your code! That way we can discuss the change, evaluate
  designs, and agree on the general idea
- [x] Ensure the tests and linter pass
- [x] Code coverage does not decrease (if any source code was changed)
- [x] Appropriate docs were updated (if necessary)
- [x] Make sure to add `!` if this involve a breaking change

🛠️ Fixes #927

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2025-11-26 08:53:55 -05:00
Dr. Strangelove
18017d6545 feat: support alternate accessToken header name (#1968)
## Description

This commit allows a tool to pull an alternate authorization
token from the header of the http request.

This is initially being built for the Looker integration. Looker
uses its own OAuth token. When deploying MCP Toolbox to Cloud
Run, the default token in the "Authorization" header is for
authentication with Cloud Run. An alternate token can be put into
another header by a client such as ADK or any other client that
can programatically set http headers. This token will be used
to authenticate with Looker.

If needed, other sources can use this by setting the header name
in the source config, passing it into the tool config, and returning
the header name in the Tool GetAuthTokenHeaderName() function.

## PR Checklist

> Thank you for opening a Pull Request! Before submitting your PR, there
are a
> few things you can do to make sure it goes smoothly:

- [x] Make sure you reviewed

[CONTRIBUTING.md](https://github.com/googleapis/genai-toolbox/blob/main/CONTRIBUTING.md)
- [x] Make sure to open an issue as a

[bug/issue](https://github.com/googleapis/genai-toolbox/issues/new/choose)
  before writing your code! That way we can discuss the change, evaluate
  designs, and agree on the general idea
- [x] Ensure the tests and linter pass
- [x] Code coverage does not decrease (if any source code was changed)
- [x] Appropriate docs were updated (if necessary)
- [x] Make sure to add `!` if this involve a breaking change

🛠️ Fixes #1540
2025-11-19 23:00:13 +00:00
google-labs-jules[bot]
42c8dd7ddd chore: embed Config into Tool (#1875)
To keep a persistent backend storage for configuration, we will have to
keep a single source of truth. This involves supporting bi-directional
conversion between Config and Tool.


This PR make the following changes:
* Embed Config in Tool
* Add `ToConfig()` to extract Config from Tool.


Jules PR

---
*PR created automatically by Jules for task
[11947649751737965380](https://jules.google.com/task/11947649751737965380)*

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: Yuan Teoh <yuanteoh@google.com>
2025-11-14 00:21:15 +00:00
Yuan Teoh
4aabb4aaca chore: move parameters to internal/util (#1907)
To facilitate the transition of moving invocation implementation to
Source, we will have to move parameter to `internal/util`. This approach
is crucial because certain parameters may not be fully resolvable
pre-implementation. Since both `internal/sources` and `internal/tools`
will need access to `parameters`, it will be more relevant to move
parameters implementation to utils.
2025-11-13 21:37:12 +00:00
Dr. Strangelove
50c400063b chore: fix linter issues (#1859) 2025-11-05 09:27:31 -08:00
Wenxin Du
bd16ba3921 fix(tools/http): omit optional nil query parameters (#1762)
🛠️ Fixes https://github.com/googleapis/genai-toolbox/issues/1737
2025-10-23 02:56:12 +00:00
Wenxin Du
a06d0d8735 fix(tools/http): allow 2xx status code on tool invocation (#1761)
🛠️ Fixes https://github.com/googleapis/genai-toolbox/issues/1759
2025-10-22 20:15:59 +00:00
Yuan Teoh
0b3dac4132 feat: add metadata in MCP Manifest for Toolbox auth (#1395)
Add `_meta` for `tools/list` method in MCP Toolbox.

If there are authorized invocation, the following will be return in
`_meta`:
```
{
    "name":"my-tool-name",
    "description":"my tool description",
     "inputSchema":{
        "type":"object",
         "properties":{
             "user_id":{"type":"string","description":"user's name from google login"}
         },
         "required":["user_id"]
     },
     "_meta":{
         "toolbox/authParam":{"user_id":["my_auth"]}
     }
}
```

If there are authenticated parameter, the following will be return in
`_meta`:
```
{
    "name":"my-tool-name",
    "description":"my tool description",
    "inputSchema":{
        "type":"object",
        "properties":{
            "sql":{"type":"string","description":"The sql to execute."}
        },
        "required":["sql"]
    },
    "_meta":{
        "toolbox/authInvoke":["my_auth"]
    }
}
```

If there are no authorized invocation or authenticated prameter, the
`_meta` field will be omitted.


With this feature, the following were updated in the source code: 
* In each `func(p CommonParameter) McpManifest()`, we will return a
`[]string` for the list of authenticated parameters. This is similar to
how Manifest() return the list of authNames in non-MCP Toolbox's
manifest.
* The `func(ps Parameters) McpManifest()` will return a
`map[string][]string` that with key as param's name, and value as the
param's auth.
* Added a new function `GetMcpManifest()` in `tools.go`. This function
will consctruct the McpManifest, and add the `Metadata` field.
* Associated tests were added or updated.
2025-09-26 17:48:57 -07:00
Wenxin Du
b1abbeb380 refactor: Add Tool method to check client authorization (#1217)
Add `RequiresClientAuthorization()` method to the `Tool` interface.
Currently returning false for all tools.
Supports: https://github.com/googleapis/genai-toolbox/pull/1067
2025-08-22 20:53:14 +00:00
Wenxin Du
bffe7b0661 refactor: Pass Authorization header token to Tool call functions (#1200)
Pass in authorization token to the Tool invocation functions.
Support: https://github.com/googleapis/genai-toolbox/pull/1067
2025-08-21 18:20:42 -04:00
Wenxin Du
e8006d31eb chore(tools/http): Refactor HTTP manifest creation (#1135)
Simplify manifest creation and replace duplication checking with common
helper.
2025-08-12 18:22:41 +00:00
prernakakkar-google
6f55b78e96 feat(source/http): Add User Agent to calls (#1102)
This change adds a User Agent for all http calls as part of source. This
will append the user agent being passed as part of prebuilt tools
context to default headers.
2025-08-11 18:43:28 +00:00
Wenxin Du
a7474752d8 feat: Add MongoDB find Tools (#970)
Add MongoDB Tools:
- mongodb-find
- mongodb-find-one

---------
Co-authored-by: Author: Dennis Geurts <dennisg@dennisg.nl>
Co-authored-by: Kurtis Van Gent <31518063+kurtisvg@users.noreply.github.com>
2025-07-24 14:46:29 -04:00
prernakakkar-google
3f6ec2944e feat: Add wait for operation tool with exponential backoff (#920)
Example:

```
  alloydb-operations-get:
    kind: wait-for-operation
    source: alloydb-api-source
    method: GET
    path: /v1/projects/{{.projectId}}/locations/{{.locationId}}/operations/{{.operationId}}
    description: "Makes API call to check whether operation is done or not. This tool is run first then wait for tool. if its still in create phase trigger it after 3 minutes.  Print a message saying still not done. We will notify once its done."
    pathParams:
      - name: projectId
        type: string
        description: The dynamic path parameter
      - name: locationId
        type: string
        description: The dynamic path parameter
        default: us-central1
      - name: operationId
        type: string
        description: Operation status check for previous task

```
2025-07-24 00:04:36 +05:30
Yuan Teoh
53afed5b76 chore(tools): invoke return type any instead of []any (#904)
Update `tool.Invoke()` to return type `any` instead of `[]any`.

Toolbox return a map with the `results` key, and the SDK reads the
string from the key. So this won't break existing SDK implementation.

Fixes #870
2025-07-17 11:03:54 -07:00
Yuan Teoh
5c54cc973d chore(tools/http): replace nil query parameter with empty string (#892)
Replace `nil` values with empty string for query parameter.
2025-07-16 22:26:53 +00:00
Wenxin Du
fd300dc606 feat: Add support for HTTP Tool pathParams (#726)
Allow users to specify dynamic path for HTTP tools.

fix: https://github.com/googleapis/genai-toolbox/issues/680
2025-06-20 14:53:49 -04:00
Yuan
518a0e4c70 refactor(tools/http): dedup to use GetParams (#659) 2025-06-05 10:54:08 -07:00
Kurtis Van Gent
b4862825e8 refactor: implement dynamic tool registration (#613)
This PR refactors the tool configuration and loading mechanism to use a
dynamic registration pattern. Each tool package now registers itself
with a central registry, and the server configuration code uses this
registry to decode and initialize tools.

Key changes:
- Introduced tools.Register and tools.DecodeToolConfig for dynamic tool
handling.
- Removed direct imports of specific tool packages from
internal/server/config.go.
- Updated individual tool packages to include init() functions for
self-registration.
- Modified ToolKind constants to be local kind constants within each
tool package.
- Adjusted test files to reflect the changes in tool kind identifiers.

This change simplifies adding new tools and decouples the server
configuration from specific tool implementations.

---------

Co-authored-by: Yuan Teoh <yuanteoh@google.com>
Co-authored-by: Yuan <45984206+Yuan325@users.noreply.github.com>
2025-06-04 10:19:42 -07:00
Yuan
04dcf47912 fix: reinitialize required slice if nil (#571)
`slices.Concat` will return `nil` if arrays are all empty instead of an
empty slice `[]`. Fix this by setting `[]` if it's `nil`.

Fixes #564
2025-05-16 00:54:03 +00:00
Yuan
b6cd99e859 chore(http): update invocation results formatting (#502)
Update http tools `Invoke` method.
* use `json.Unmarshal` for response body that are either list or json
map. This will allow us to return lists as is (e.g. `[{map}]` instead of
having to nest it in an additional list (e.g. `[]any{ [{map}] }`)
* for response body that are strings or fail to unmarshal, return it as
is.
2025-04-28 21:09:07 -07:00
Wenxin Du
d9388ad57e feat: Add AuthRequired to Tool Manifest (#433)
Add `AuthRequired` to Tool Manifest so SDK could throw an error early
for unauthorized Tool invocations.
SDK changes:
https://github.com/googleapis/mcp-toolbox-sdk-python/pull/72/files

Also added `authRequired` to Neo4j and dgraph tools.
2025-04-23 12:52:04 -04:00
Yuan
dced46ad88 chore: cleanup go context (#457) 2025-04-21 20:16:05 +00:00
Yuan
a7d1d4eb2a feat: adding support for Model Context Protocol (MCP). (#396)
Adding Toolbox support for MCP. Toolbox can now be run as an MCP server.

Fixes #312.

---------

Co-authored-by: Jack Wotherspoon <jackwoth@google.com>
Co-authored-by: Kurtis Van Gent <31518063+kurtisvg@users.noreply.github.com>
Co-authored-by: Averi Kitsch <akitsch@google.com>
2025-04-04 18:24:34 +00:00
Wenxin Du
64da5b4efe feat: Add HTTP Source and Tool (#332)
Add Source and Tool for tool invocation through HTTP requests.
2025-04-02 14:52:35 -04:00