You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -32,71 +32,111 @@ use GitHub pull requests for this purpose. Consult
32
32
[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
33
33
information on using pull requests.
34
34
35
-
Within 2-5 days, a reviewer will review your PR. They may approve it, or request changes. When requesting changes, reviewers should self-assign the PR to ensure they are aware of any updates.
36
-
If additional changes are needed, push additional commits to your PR branch - this helps the reviewer know which parts of the PR have changed. Commits will be squashed when merged.
37
-
Please follow up with changes promptly. If a PR is awaiting changes by the author for more than 10 days, maintainers may mark that PR as Draft. PRs that are inactive for more than 30 days may be closed.
38
-
35
+
Within 2-5 days, a reviewer will review your PR. They may approve it, or request
36
+
changes. When requesting changes, reviewers should self-assign the PR to ensure
37
+
they are aware of any updates.
38
+
If additional changes are needed, push additional commits to your PR branch -
39
+
this helps the reviewer know which parts of the PR have changed. Commits will be
40
+
squashed when merged.
41
+
Please follow up with changes promptly. If a PR is awaiting changes by the
42
+
author for more than 10 days, maintainers may mark that PR as Draft. PRs that
43
+
are inactive for more than 30 days may be closed.
39
44
40
45
### Adding a New Database Source and Tool
41
46
42
-
We recommend creating an [issue](https://github.com/googleapis/genai-toolbox/issues) before implementation to ensure we can accept the contribution and no duplicated work. If you have any questions, reach out on our [Discord](https://discord.gg/Dmm69peqjh) to chat directly with the team. New contributions should be added with both unit tests and integration tests.
47
+
We recommend creating an
48
+
[issue](https://github.com/googleapis/genai-toolbox/issues) before
49
+
implementation to ensure we can accept the contribution and no duplicated work.
50
+
If you have any questions, reach out on our
51
+
[Discord](https://discord.gg/Dmm69peqjh) to chat directly with the team. New
52
+
contributions should be added with both unit tests and integration tests.
43
53
44
54
#### 1. Implement the New Data Source
45
55
46
-
We recommend looking at an [example source implementation](https://github.com/googleapis/genai-toolbox/blob/main/internal/sources/postgres/postgres.go).
47
-
48
-
***Create a new directory** under `internal/sources` for your database type (e.g., `internal/sources/newdb`).
49
-
***Define a configuration struct** for your data source in a file named `newdb.go`. Create a `Config` struct to include all the necessary parameters for connecting to the database (e.g., host, port, username, password, database name) and a `Source` struct to store necessary parameters for tools (e.g., Name, Kind, connection object, additional config).
50
-
***Implement the [`SourceConfig`](https://github.com/googleapis/genai-toolbox/blob/fd300dc606d88bf9f7bba689e2cee4e3565537dd/internal/sources/sources.go#L57) interface**. This interface requires two methods:
51
-
*`SourceConfigKind() string`: Returns a unique string identifier for your data source (e.g., `"newdb"`).
52
-
*`Initialize(ctx context.Context, tracer trace.Tracer) (Source, error)`: Creates a new instance of your data source and establishes a connection to the database.
53
-
***Implement the [`Source`](https://github.com/googleapis/genai-toolbox/blob/fd300dc606d88bf9f7bba689e2cee4e3565537dd/internal/sources/sources.go#L63) interface**. This interface requires one method:
54
-
*`SourceKind() string`: Returns the same string identifier as `SourceConfigKind()`.
55
-
***Implement `init()`** to register the new Source.
56
-
***Implement Unit Tests** in a file named `newdb_test.go`.
*`SourceKind() string`: Returns the same string identifier as `SourceConfigKind()`.
78
+
***Implement `init()`** to register the new Source.
79
+
***Implement Unit Tests** in a file named `newdb_test.go`.
57
80
58
81
#### 2. Implement the New Tool
59
82
60
-
We recommend looking at an [example tool implementation](https://github.com/googleapis/genai-toolbox/tree/main/internal/tools/postgressql).
61
-
62
-
***Create a new directory** under `internal/tools` for your tool type (e.g., `internal/tools/newdb` or `internal/tools/newdb<tool_name>`).
63
-
***Define a configuration struct** for your tool in a file named `newdbtool.go`.
64
-
Create a `Config` struct and a `Tool` struct to store necessary parameters for tools.
65
-
***Implement the [`ToolConfig`](https://github.com/googleapis/genai-toolbox/blob/fd300dc606d88bf9f7bba689e2cee4e3565537dd/internal/tools/tools.go#L61) interface**. This interface requires one method:
66
-
*`ToolConfigKind() string`: Returns a unique string identifier for your tool (e.g., `"newdb"`).
67
-
*`Initialize(sources map[string]Source) (Tool, error)`: Creates a new instance of your tool and validates that it can connect to the specified data source.
68
-
***Implement the `Tool` interface**. This interface requires the following methods:
69
-
*`Invoke(ctx context.Context, params map[string]any) ([]any, error)`: Executes the operation on the database using the provided parameters.
70
-
*`ParseParams(data map[string]any, claims map[string]map[string]any) (ParamValues, error)`: Parses and validates the input parameters.
71
-
*`Manifest() Manifest`: Returns a manifest describing the tool's capabilities and parameters.
72
-
*`McpManifest() McpManifest`: Returns an MCP manifest describing the tool for use with the Model Context Protocol.
73
-
*`Authorized(services []string) bool`: Checks if the tool is authorized to run based on the provided authentication services.
74
-
***Implement `init()`** to register the new Tool.
75
-
***Implement Unit Tests** in a file named `newdb_test.go`.
***Update the documentation** to include information about your new data source and tool. This includes:
117
-
* Adding a new page to the `docs/en/resources/sources` directory for your data source.
118
-
* Adding a new page to the `docs/en/resources/tools` directory for your tool.
156
+
***Update the documentation** to include information about your new data source
157
+
and tool. This includes:
158
+
* Adding a new page to the `docs/en/resources/sources` directory for your data
159
+
source.
160
+
* Adding a new page to the `docs/en/resources/tools` directory for your tool.
119
161
120
-
***(Optional) Add samples** to the `docs/en/samples/<newdb>` directory.
162
+
***(Optional) Add samples** to the `docs/en/samples/<newdb>` directory.
121
163
122
164
#### (Optional) 5. Add Prebuilt Tools
123
165
124
-
You can provide developers with a set of "build-time" tools to aid common software development user journeys like viewing and creating tables/collections and data.
166
+
You can provide developers with a set of "build-time" tools to aid common
167
+
software development user journeys like viewing and creating tables/collections
168
+
and data.
125
169
126
-
***Create a set of prebuilt tools** by defining a new `tools.yaml` and adding it to `internal/tools`. Make sure the file name matches the source (i.e. for source "alloydb-postgres" create a file named "alloydb-postgres.yaml").
127
-
***Update `cmd/root.go`** to add new source to the `prebuilt` flag.
128
-
***Add tests** in [internal/prebuiltconfigs/prebuiltconfigs_test.go](internal/prebuiltconfigs/prebuiltconfigs_test.go) and [cmd/root_test.go](cmd/root_test.go).
170
+
***Create a set of prebuilt tools** by defining a new `tools.yaml` and adding
171
+
it to `internal/tools`. Make sure the file name matches the source (i.e. for
172
+
source "alloydb-postgres" create a file named "alloydb-postgres.yaml").
173
+
***Update `cmd/root.go`** to add new source to the `prebuilt` flag.
***Submit a pull request** to the repository with your changes. Be sure to include a detailed description of your changes and any requests for long term testing resources.
180
+
***Submit a pull request** to the repository with your changes. Be sure to
181
+
include a detailed description of your changes and any requests for long term
0 commit comments