mcp: Add some buildbucket tools and the mcp server

These tools are still being evaluated and may change. get_build vs
get_build_from_id and get_build_from_build_number in particular are two
distinct ways of implementing the same tool that need to be compared.
get_build gives flexibility but is extremely verbose which means it
might be too flaky or consume unnecessary tokens. The return of these
might also need filtering for unnecessary output. Particularly steps
which can be very verbose without much information.

Bug: 430952168
Change-Id: Ia9b092a6b6c546198939deb36ea1b89ff33d7fc6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6758660
Auto-Submit: Struan Shrimpton <sshrimp@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Reviewed-by: Erik Staab <estaab@chromium.org>
Commit-Queue: Struan Shrimpton <sshrimp@google.com>
This commit is contained in:
Struan Shrimpton
2025-07-21 10:33:13 -07:00
committed by LUCI CQ
parent 068f8379e9
commit 75449d2000
6 changed files with 692 additions and 0 deletions

View File

@@ -113,3 +113,23 @@ def initialize(service_name,
def get_tracer(name: str, version: Optional[str] = None):
return otel_trace_api.get_tracer(name, version)
def opted_in(cfg_file=config.DEFAULT_CONFIG_FILE):
"""Get if the user is opted-in
Unlike initialize which continues when not explicitly opted out this will
return if the user is opted in, either by user or automatically after the
banner display period.
"""
cfg = config.Config(cfg_file)
if cfg.trace_config.disabled():
return False
bot_enabled = (cfg.trace_config.has_enabled()
and cfg.trace_config.enabled_reason == 'BOT_USER')
if not is_google_host() and not bot_enabled:
return False
cfg = config.Config(cfg_file)
return cfg.trace_config.enabled