mcptools

package
v0.9.268 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 26, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package mcptools wires Coremetry's telemetry surfaces as MCP tools (v0.6.5). Lives in its own package — not inside `mcp` — so the protocol layer stays storage-agnostic and we don't risk a chstore↔mcp import dance.

Each tool closes over a Deps struct containing the chstore + logstore handles. Register(srv, deps) is called once at boot after the MCP server is constructed, before SetMCP is called on the api.Server.

Design choices:

  • Args are decoded into a typed struct per tool. JSON Schema in the registration matches that struct field-for-field so a Claude Desktop-style inspector renders the right form.

  • Time windows are expressed as `range_s` (seconds back from now) instead of from/to nanoseconds. LLMs are notoriously bad at constructing big nanosecond integers; "give me the last 30 minutes" → range_s=1800 is a much more reliable prompt for them than two unix-nano timestamps.

  • Every tool caps Limit at a tool-specific sane default. The LLM can ask for 10 or 100 but not 10000 — context windows are precious and an oversized list_problems response trashes downstream reasoning. Server-side cap is the backstop.

  • Errors are returned as Go errors; the mcp package wraps them into MCP isError=true content. No need to format them here.

Tool catalogue (v0.6.5):

  • list_services
  • get_service_health
  • list_problems
  • list_anomalies
  • search_logs
  • get_trace
  • query_metric

Cross-signal pivot tools (v0.8.333, pivots.go):

  • get_logs_for_trace
  • get_exemplar_traces
  • get_linked_traces
  • get_metrics_for_span

CoSRE Faz-2 (structured chart cards):

  • render_chart — the model PICKS which live RED chart to show; the chat server emits the deterministic ```chart``` block (copilot_chat.go), the UI draws it from real telemetry.

Env-awareness (v0.8.398, AI audit): list_services, get_service_health and list_problems accept an OPTIONAL `env` arg (deployment environment, spans.deploy_env — int/uat/prep style values) because their underlying reads already support it (GetServicesFilteredIn's env conjunct v0.8.385; ProblemFilter.Env service-scoped semantics v0.8.387). Results echo the applied env. The other tools stay env-less ON PURPOSE: search_logs/list_anomalies/query_metric reads carry no env path yet (env-separation Phase 4 pending) and get_trace/pivot tools are id-anchored point lookups — no silent half-support.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(srv *mcp.Server, d Deps)

func ToolList added in v0.6.53

func ToolList(d Deps) []mcp.Tool

Register installs every v0.6.5/v0.6.6 tool and resource on the given MCP server. Idempotent — calling twice overwrites with the latest closures, but that's a logic-error pattern the mcp package logs about. ToolList returns the full telemetry tool set as plain mcp.Tool values closed over the given Deps, WITHOUT registering them on an MCP server. v0.6.53 — the in-app chatbot reuses this exact set as its function-calling backend: it maps each tool's Name / Description / InputSchema into a copilot.ToolSpec for the LLM, and invokes Handler(ctx, args) directly (the handler signature is transport- agnostic — no JSON-RPC envelope needed). Register() delegates here so the MCP server and the chatbot can never drift to different tool sets.

Types

type Deps

type Deps struct {
	Store    *chstore.Store
	LogStore logstore.Store
}

Deps bundles the data-access handles concrete tools close over. Kept here (rather than passed through Register) so test setups can construct a Deps with mocks for just the surfaces under test instead of building a full chstore.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL