googleapis/mcp-toolbox · error

tool type %q already registered

Error message

tool type %q already registered

What it means

The package's init() registers the 'postgres-list-stored-procedure' tool type in the global registry and panics if tools.Register returns false, meaning the type string was already claimed. This is a duplicate-registration guard for programming errors (e.g. a vendored or duplicated package copy linked into the binary), not a user config issue.

Source

Thrown at internal/tools/postgres/postgresliststoredprocedure/postgresliststoredprocedure.go:58

          l.lanname AS language,
          pg_catalog.pg_get_functiondef(p.oid) AS definition,
          pg_catalog.obj_description(p.oid, 'pg_proc') AS description
      FROM pg_catalog.pg_proc p
      JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace
      JOIN pg_catalog.pg_roles r ON r.oid = p.proowner
      JOIN pg_catalog.pg_language l ON l.oid = p.prolang
      WHERE
          p.prokind = 'p' AND
          ($1::text IS NULL OR r.rolname LIKE '%' || $1::text || '%') AND
          ($2::text IS NULL OR n.nspname LIKE '%' || $2::text || '%')
      ORDER BY n.nspname, p.proname
      LIMIT
        COALESCE($3::int, 20);
`

func init() {
	if !tools.Register(resourceType, newConfig) {
		panic(fmt.Sprintf("tool type %q already registered", resourceType))
	}
}

func newConfig(ctx context.Context, name string, decoder *yaml.Decoder) (tools.ToolConfig, error) {
	actual := Config{ConfigBase: tools.ConfigBase{Name: name}}
	if err := decoder.DecodeContext(ctx, &actual); err != nil {
		return nil, err
	}
	return actual, nil
}

type compatibleSource interface {
	PostgresPool() *pgxpool.Pool
}

// validate compatible sources are still compatible
var _ compatibleSource = &alloydbpg.Source{}
var _ compatibleSource = &cloudsqlpg.Source{}

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Ensure the package is not imported twice under different paths (e.g. vendored and module copies)
  2. Rename the conflicting resourceType constant if two distinct tools share it
  3. Clean go.mod/go.sum and rebuild to eliminate stale duplicate dependencies
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/tools/postgres/postgresliststoredprocedure/postgresliststoredprocedure.go:58 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05). Data as JSON: /api/errors/77d7afa7fc78b22a. Report an issue: GitHub.