mcp

package
v0.0.0-...-d59b4eb Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package mcp wraps calls to CockroachDB's Managed MCP Server.

This is intentionally read-only: it never issues writes. All state- changing actions go through the ccloud package instead, gated by human approval. Keeping these concerns in separate packages makes the "observe vs act" boundary obvious in code review and in the demo.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Endpoint   string
	APIKey     string
	HTTPClient *http.Client
}

Client holds the connection to the Managed MCP Server endpoint.

func NewClient

func NewClient(endpoint, apiKey string) *Client

func (*Client) GetClusterHealth

func (c *Client) GetClusterHealth(ctx context.Context) (*ClusterSnapshot, error)

GetClusterHealth calls the MCP server's cluster-health tool (list databases/tables, node status, replication) — read-only.

func (*Client) GetSlowQueries

func (c *Client) GetSlowQueries(ctx context.Context, limit int) ([]map[string]interface{}, error)

GetSlowQueries calls the MCP server's slow-query / statement-stats tool.

type ClusterSnapshot

type ClusterSnapshot struct {
	CPUPercent        float64                `json:"cpu_percent"`
	ActiveQueries     int                    `json:"active_queries"`
	ContentionEvents  int                    `json:"contention_events"`
	ReplicationStatus string                 `json:"replication_status"`
	Raw               map[string]interface{} `json:"raw"`
	CapturedAt        time.Time              `json:"captured_at"`
}

ClusterSnapshot is our own normalized view of whatever the MCP server returns — MCP tool responses are free-form JSON, so we shape them into something the rest of the app can rely on.

func (*ClusterSnapshot) ToJSON

func (s *ClusterSnapshot) ToJSON() ([]byte, error)

ToJSON is a convenience for logging the raw context alongside a decision

type MCPToolCallRequest

type MCPToolCallRequest struct {
	Method string                 `json:"method"`
	Params map[string]interface{} `json:"params"`
}

type MCPToolCallResponse

type MCPToolCallResponse struct {
	Result map[string]interface{} `json:"result"`
	Error  *struct {
		Code    int    `json:"code"`
		Message string `json:"message"`
	} `json:"error"`
}

Jump to

Keyboard shortcuts

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