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
16 changes: 8 additions & 8 deletions cmd/internal/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -955,8 +955,8 @@ func TestParseConfigWithAuth(t *testing.T) {
Statement: "SELECT * FROM SQL_STATEMENT;\n",
Parameters: []parameters.Parameter{
parameters.NewStringParameter("country", "some description"),
parameters.NewIntParameterWithAuth("id", "user id", []parameters.ParamAuthService{{Name: "my-google-service", Field: "user_id"}}),
parameters.NewStringParameterWithAuth("email", "user email", []parameters.ParamAuthService{{Name: "my-google-service", Field: "email"}, {Name: "other-google-service", Field: "other_email"}}),
parameters.NewIntParameter("id", "user id", parameters.WithIntAuth([]parameters.ParamAuthService{{Name: "my-google-service", Field: "user_id"}})),
parameters.NewStringParameter("email", "user email", parameters.WithStringAuth([]parameters.ParamAuthService{{Name: "my-google-service", Field: "email"}, {Name: "other-google-service", Field: "other_email"}})),
},
},
},
Expand Down Expand Up @@ -1063,8 +1063,8 @@ func TestParseConfigWithAuth(t *testing.T) {
Statement: "SELECT * FROM SQL_STATEMENT;\n",
Parameters: []parameters.Parameter{
parameters.NewStringParameter("country", "some description"),
parameters.NewIntParameterWithAuth("id", "user id", []parameters.ParamAuthService{{Name: "my-google-service", Field: "user_id"}}),
parameters.NewStringParameterWithAuth("email", "user email", []parameters.ParamAuthService{{Name: "my-google-service", Field: "email"}, {Name: "other-google-service", Field: "other_email"}}),
parameters.NewIntParameter("id", "user id", parameters.WithIntAuth([]parameters.ParamAuthService{{Name: "my-google-service", Field: "user_id"}})),
parameters.NewStringParameter("email", "user email", parameters.WithStringAuth([]parameters.ParamAuthService{{Name: "my-google-service", Field: "email"}, {Name: "other-google-service", Field: "other_email"}})),
},
},
},
Expand Down Expand Up @@ -1234,9 +1234,9 @@ func TestEnvVarReplacement(t *testing.T) {
Method: "GET",
Path: "search?name=alice&pet=cat",
QueryParams: []parameters.Parameter{
parameters.NewStringParameterWithAuth("country", "some description",
parameters.NewStringParameter("country", "some description", parameters.WithStringAuth(
[]parameters.ParamAuthService{{Name: "my-google-auth-service", Field: "user_id"},
{Name: "other-auth-service", Field: "user_id"}}),
{Name: "other-auth-service", Field: "user_id"}})),
},
RequestBody: `{
"age": {{.age}},
Expand Down Expand Up @@ -1382,9 +1382,9 @@ func TestEnvVarReplacement(t *testing.T) {
Method: "GET",
Path: "search?name=alice&pet=cat",
QueryParams: []parameters.Parameter{
parameters.NewStringParameterWithAuth("country", "some description",
parameters.NewStringParameter("country", "some description", parameters.WithStringAuth(
[]parameters.ParamAuthService{{Name: "my-google-auth-service", Field: "user_id"},
{Name: "other-auth-service", Field: "user_id"}}),
{Name: "other-auth-service", Field: "user_id"}})),
},
RequestBody: `{
"age": {{.age}},
Expand Down
2 changes: 1 addition & 1 deletion internal/prompts/arguments_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func TestParseArguments(t *testing.T) {
t.Parallel()
testArguments := prompts.Arguments{
{Parameter: parameters.NewStringParameter("name", "A required name.")},
{Parameter: parameters.NewIntParameterWithRequired("count", "An optional count.", false)},
{Parameter: parameters.NewIntParameter("count", "An optional count.", parameters.WithIntRequired(false))},
}

testCases := []struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/prompts/custom/custom_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestConfig(t *testing.T) {
// Setup a shared config for testing its methods
testArgs := prompts.Arguments{
{Parameter: parameters.NewStringParameter("name", "The name to use.")},
{Parameter: parameters.NewStringParameterWithRequired("location", "The location.", false)},
{Parameter: parameters.NewStringParameter("location", "The location.", parameters.WithStringRequired(false))},
}

cfg := custom.Config{
Expand Down
2 changes: 1 addition & 1 deletion internal/prompts/messages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func TestSubstituteMessages(t *testing.T) {
t.Run("Success", func(t *testing.T) {
arguments := prompts.Arguments{
{Parameter: parameters.NewStringParameter("name", "The name to use.")},
{Parameter: parameters.NewStringParameterWithRequired("location", "The location.", false)},
{Parameter: parameters.NewStringParameter("location", "The location.", parameters.WithStringRequired(false))},
}
messages := []prompts.Message{
{Role: "user", Content: "Hello, my name is {{.name}} and I am in {{.location}}."},
Expand Down
2 changes: 1 addition & 1 deletion internal/prompts/prompts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func TestGetManifest(t *testing.T) {
description: "Prompt with arguments.",
args: prompts.Arguments{
{Parameter: parameters.NewStringParameter("param1", "First param")},
{Parameter: parameters.NewBooleanParameterWithRequired("param2", "Second param", false)},
{Parameter: parameters.NewBooleanParameter("param2", "Second param", parameters.WithBooleanRequired(false))},
},
want: prompts.Manifest{
Description: "Prompt with arguments.",
Expand Down
10 changes: 5 additions & 5 deletions internal/server/mcp/v20241105/manifests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func TestGenerateToolManifest(t *testing.T) {
name: "basic",
description: "foo bar",
authInvoke: []string{},
params: parameters.Parameters{parameters.NewStringParameterWithAuth("string-param", "string parameter", authServices)},
params: parameters.Parameters{parameters.NewStringParameter("string-param", "string parameter", parameters.WithStringAuth(authServices))},
annotations: nil,
wantMetadata: map[string]any{
"toolbox/authParam": map[string][]string{
Expand All @@ -96,7 +96,7 @@ func TestGenerateToolManifest(t *testing.T) {
name: "basic",
description: "foo bar",
authInvoke: []string{"auth1", "auth2"},
params: parameters.Parameters{parameters.NewStringParameterWithAuth("string-param", "string parameter", authServices)},
params: parameters.Parameters{parameters.NewStringParameter("string-param", "string parameter", parameters.WithStringAuth(authServices))},
annotations: nil,
wantMetadata: map[string]any{
"toolbox/authInvoke": []string{"auth1", "auth2"},
Expand Down Expand Up @@ -147,9 +147,9 @@ func TestParamManifest(t *testing.T) {
{
name: "all types",
in: parameters.Parameters{
parameters.NewStringParameterWithDefault("foo-string", "foo", "bar"),
parameters.NewStringParameter("foo-string", "bar", parameters.WithStringDefault("foo")),
parameters.NewStringParameter("foo-string2", "bar"),
parameters.NewStringParameterWithAuth("foo-string3-auth", "bar", authServices),
parameters.NewStringParameter("foo-string3-auth", "bar", parameters.WithStringAuth(authServices)),
parameters.NewIntParameter("foo-int2", "bar"),
parameters.NewFloatParameter("foo-float", "bar"),
parameters.NewArrayParameter("foo-array2", "bar", parameters.NewStringParameter("foo-string", "bar")),
Expand Down Expand Up @@ -321,7 +321,7 @@ func TestGeneratePromptManifest(t *testing.T) {
description: "Prompt with args.",
args: prompts.Arguments{
{Parameter: parameters.NewStringParameter("param1", "First param")},
{Parameter: parameters.NewIntParameterWithRequired("param2", "Second param", false)},
{Parameter: parameters.NewIntParameter("param2", "Second param", parameters.WithIntRequired(false))},
},
want: Prompt{
Name: "arg-prompt",
Expand Down
10 changes: 5 additions & 5 deletions internal/server/mcp/v20250326/manifests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func TestGenerateToolManifest(t *testing.T) {
name: "basic",
description: "foo bar",
authInvoke: []string{},
params: parameters.Parameters{parameters.NewStringParameterWithAuth("string-param", "string parameter", authServices)},
params: parameters.Parameters{parameters.NewStringParameter("string-param", "string parameter", parameters.WithStringAuth(authServices))},
annotations: nil,
wantMetadata: map[string]any{
"toolbox/authParam": map[string][]string{
Expand All @@ -96,7 +96,7 @@ func TestGenerateToolManifest(t *testing.T) {
name: "basic",
description: "foo bar",
authInvoke: []string{"auth1", "auth2"},
params: parameters.Parameters{parameters.NewStringParameterWithAuth("string-param", "string parameter", authServices)},
params: parameters.Parameters{parameters.NewStringParameter("string-param", "string parameter", parameters.WithStringAuth(authServices))},
annotations: nil,
wantMetadata: map[string]any{
"toolbox/authInvoke": []string{"auth1", "auth2"},
Expand Down Expand Up @@ -147,9 +147,9 @@ func TestParamManifest(t *testing.T) {
{
name: "all types",
in: parameters.Parameters{
parameters.NewStringParameterWithDefault("foo-string", "foo", "bar"),
parameters.NewStringParameter("foo-string", "bar", parameters.WithStringDefault("foo")),
parameters.NewStringParameter("foo-string2", "bar"),
parameters.NewStringParameterWithAuth("foo-string3-auth", "bar", authServices),
parameters.NewStringParameter("foo-string3-auth", "bar", parameters.WithStringAuth(authServices)),
parameters.NewIntParameter("foo-int2", "bar"),
parameters.NewFloatParameter("foo-float", "bar"),
parameters.NewArrayParameter("foo-array2", "bar", parameters.NewStringParameter("foo-string", "bar")),
Expand Down Expand Up @@ -321,7 +321,7 @@ func TestGeneratePromptManifest(t *testing.T) {
description: "Prompt with args.",
args: prompts.Arguments{
{Parameter: parameters.NewStringParameter("param1", "First param")},
{Parameter: parameters.NewIntParameterWithRequired("param2", "Second param", false)},
{Parameter: parameters.NewIntParameter("param2", "Second param", parameters.WithIntRequired(false))},
},
want: Prompt{
Name: "arg-prompt",
Expand Down
10 changes: 5 additions & 5 deletions internal/server/mcp/v20250618/manifests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func TestGenerateToolManifest(t *testing.T) {
name: "basic",
description: "foo bar",
authInvoke: []string{},
params: parameters.Parameters{parameters.NewStringParameterWithAuth("string-param", "string parameter", authServices)},
params: parameters.Parameters{parameters.NewStringParameter("string-param", "string parameter", parameters.WithStringAuth(authServices))},
annotations: nil,
wantMetadata: map[string]any{
"toolbox/authParam": map[string][]string{
Expand All @@ -96,7 +96,7 @@ func TestGenerateToolManifest(t *testing.T) {
name: "basic",
description: "foo bar",
authInvoke: []string{"auth1", "auth2"},
params: parameters.Parameters{parameters.NewStringParameterWithAuth("string-param", "string parameter", authServices)},
params: parameters.Parameters{parameters.NewStringParameter("string-param", "string parameter", parameters.WithStringAuth(authServices))},
annotations: nil,
wantMetadata: map[string]any{
"toolbox/authInvoke": []string{"auth1", "auth2"},
Expand Down Expand Up @@ -147,9 +147,9 @@ func TestParamManifest(t *testing.T) {
{
name: "all types",
in: parameters.Parameters{
parameters.NewStringParameterWithDefault("foo-string", "foo", "bar"),
parameters.NewStringParameter("foo-string", "bar", parameters.WithStringDefault("foo")),
parameters.NewStringParameter("foo-string2", "bar"),
parameters.NewStringParameterWithAuth("foo-string3-auth", "bar", authServices),
parameters.NewStringParameter("foo-string3-auth", "bar", parameters.WithStringAuth(authServices)),
parameters.NewIntParameter("foo-int2", "bar"),
parameters.NewFloatParameter("foo-float", "bar"),
parameters.NewArrayParameter("foo-array2", "bar", parameters.NewStringParameter("foo-string", "bar")),
Expand Down Expand Up @@ -321,7 +321,7 @@ func TestGeneratePromptManifest(t *testing.T) {
description: "Prompt with args.",
args: prompts.Arguments{
{Parameter: parameters.NewStringParameter("param1", "First param")},
{Parameter: parameters.NewIntParameterWithRequired("param2", "Second param", false)},
{Parameter: parameters.NewIntParameter("param2", "Second param", parameters.WithIntRequired(false))},
},
want: Prompt{
BaseMetadata: BaseMetadata{Name: "arg-prompt"},
Expand Down
10 changes: 5 additions & 5 deletions internal/server/mcp/v20251125/manifests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func TestGenerateToolManifest(t *testing.T) {
name: "basic",
description: "foo bar",
authInvoke: []string{},
params: parameters.Parameters{parameters.NewStringParameterWithAuth("string-param", "string parameter", authServices)},
params: parameters.Parameters{parameters.NewStringParameter("string-param", "string parameter", parameters.WithStringAuth(authServices))},
annotations: nil,
wantMetadata: map[string]any{
"toolbox/authParam": map[string][]string{
Expand All @@ -96,7 +96,7 @@ func TestGenerateToolManifest(t *testing.T) {
name: "basic",
description: "foo bar",
authInvoke: []string{"auth1", "auth2"},
params: parameters.Parameters{parameters.NewStringParameterWithAuth("string-param", "string parameter", authServices)},
params: parameters.Parameters{parameters.NewStringParameter("string-param", "string parameter", parameters.WithStringAuth(authServices))},
annotations: nil,
wantMetadata: map[string]any{
"toolbox/authInvoke": []string{"auth1", "auth2"},
Expand Down Expand Up @@ -147,9 +147,9 @@ func TestParamManifest(t *testing.T) {
{
name: "all types",
in: parameters.Parameters{
parameters.NewStringParameterWithDefault("foo-string", "foo", "bar"),
parameters.NewStringParameter("foo-string", "bar", parameters.WithStringDefault("foo")),
parameters.NewStringParameter("foo-string2", "bar"),
parameters.NewStringParameterWithAuth("foo-string3-auth", "bar", authServices),
parameters.NewStringParameter("foo-string3-auth", "bar", parameters.WithStringAuth(authServices)),
parameters.NewIntParameter("foo-int2", "bar"),
parameters.NewFloatParameter("foo-float", "bar"),
parameters.NewArrayParameter("foo-array2", "bar", parameters.NewStringParameter("foo-string", "bar")),
Expand Down Expand Up @@ -321,7 +321,7 @@ func TestGeneratePromptManifest(t *testing.T) {
description: "Prompt with args.",
args: prompts.Arguments{
{Parameter: parameters.NewStringParameter("param1", "First param")},
{Parameter: parameters.NewIntParameterWithRequired("param2", "Second param", false)},
{Parameter: parameters.NewIntParameter("param2", "Second param", parameters.WithIntRequired(false))},
},
want: Prompt{
BaseMetadata: BaseMetadata{Name: "arg-prompt"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,15 @@ func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) (boo
func buildParams(project string) parameters.Parameters {
projectParam := parameters.NewStringParameter("project", "The GCP project ID.")
if project != "" {
projectParam = parameters.NewStringParameterWithDefault("project", project, "The GCP project ID. This is pre-configured; do not ask for it unless the user explicitly provides a different one.")
projectParam = parameters.NewStringParameter("project", "The GCP project ID. This is pre-configured; do not ask for it unless the user explicitly provides a different one.", parameters.WithStringDefault(project))
}
return parameters.Parameters{
projectParam,
parameters.NewStringParameterWithDefault("location", "us-central1", "The location to create the cluster in. The default value is us-central1. If quota is exhausted then use other regions."),
parameters.NewStringParameter("location", "The location to create the cluster in. The default value is us-central1. If quota is exhausted then use other regions.", parameters.WithStringDefault("us-central1")),
parameters.NewStringParameter("cluster", "A unique ID for the AlloyDB cluster."),
parameters.NewStringParameter("password", "A secure password for the initial user."),
parameters.NewStringParameterWithDefault("network", "default", "The name of the VPC network to connect the cluster to (e.g., 'default')."),
parameters.NewStringParameterWithDefault("user", "postgres", "The name for the initial superuser. Defaults to 'postgres' if not provided."),
parameters.NewStringParameter("network", "The name of the VPC network to connect the cluster to (e.g., 'default').", parameters.WithStringDefault("default")),
parameters.NewStringParameter("user", "The name for the initial superuser. Defaults to 'postgres' if not provided.", parameters.WithStringDefault("postgres")),
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,16 @@ func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) (boo
func buildParams(project string) parameters.Parameters {
projectParam := parameters.NewStringParameter("project", "The GCP project ID.")
if project != "" {
projectParam = parameters.NewStringParameterWithDefault("project", project, "The GCP project ID. This is pre-configured; do not ask for it unless the user explicitly provides a different one.")
projectParam = parameters.NewStringParameter("project", "The GCP project ID. This is pre-configured; do not ask for it unless the user explicitly provides a different one.", parameters.WithStringDefault(project))
}
return parameters.Parameters{
projectParam,
parameters.NewStringParameter("location", "The location of the cluster (e.g., 'us-central1')."),
parameters.NewStringParameter("cluster", "The ID of the cluster to create the instance in."),
parameters.NewStringParameter("instance", "A unique ID for the new AlloyDB instance."),
parameters.NewStringParameterWithDefault("instanceType", "PRIMARY", "The type of instance to create. Valid values are: PRIMARY and READ_POOL. Default is PRIMARY"),
parameters.NewStringParameterWithRequired("displayName", "An optional, user-friendly name for the instance.", false),
parameters.NewIntParameterWithDefault("nodeCount", 1, "The number of nodes in the read pool. Required only if instanceType is READ_POOL. Default is 1."),
parameters.NewStringParameter("instanceType", "The type of instance to create. Valid values are: PRIMARY and READ_POOL. Default is PRIMARY", parameters.WithStringDefault("PRIMARY")),
parameters.NewStringParameter("displayName", "An optional, user-friendly name for the instance.", parameters.WithStringRequired(false)),
parameters.NewIntParameter("nodeCount", "The number of nodes in the read pool. Required only if instanceType is READ_POOL. Default is 1.", parameters.WithIntDefault(1)),
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,15 @@ func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) (boo
func buildParams(project string) parameters.Parameters {
projectParam := parameters.NewStringParameter("project", "The GCP project ID.")
if project != "" {
projectParam = parameters.NewStringParameterWithDefault("project", project, "The GCP project ID. This is pre-configured; do not ask for it unless the user explicitly provides a different one.")
projectParam = parameters.NewStringParameter("project", "The GCP project ID. This is pre-configured; do not ask for it unless the user explicitly provides a different one.", parameters.WithStringDefault(project))
}
return parameters.Parameters{
projectParam,
parameters.NewStringParameter("location", "The location of the cluster (e.g., 'us-central1')."),
parameters.NewStringParameter("cluster", "The ID of the cluster where the user will be created."),
parameters.NewStringParameter("user", "The name for the new user. Must be unique within the cluster."),
parameters.NewStringParameterWithRequired("password", "A secure password for the new user. Required only for ALLOYDB_BUILT_IN userType.", false),
parameters.NewArrayParameterWithDefault("databaseRoles", []any{}, "Optional. A list of database roles to grant to the new user (e.g., ['pg_read_all_data']).", parameters.NewStringParameter("role", "A single database role to grant to the user (e.g., 'pg_read_all_data').")),
parameters.NewStringParameter("password", "A secure password for the new user. Required only for ALLOYDB_BUILT_IN userType.", parameters.WithStringRequired(false)),
parameters.NewArrayParameter("databaseRoles", "Optional. A list of database roles to grant to the new user (e.g., ['pg_read_all_data']).", parameters.NewStringParameter("role", "A single database role to grant to the user (e.g., 'pg_read_all_data')."), parameters.WithArrayDefault([]any{})),
parameters.NewStringParameter("userType", "The type of user to create. Valid values are: ALLOYDB_BUILT_IN and ALLOYDB_IAM_USER. ALLOYDB_IAM_USER is recommended."),
}
}
Expand Down
Loading
Loading