mcp

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 37 Imported by: 0

Documentation

Overview

Package mcp exposes the analytics engine over the Model Context Protocol so the user connects smolanalytics to THEIR OWN Claude / Cursor / Claude Code and asks questions in plain English — their model calls these tools, we never call a model ourselves (no API keys, no inference cost on our side). Same model as a Telegram-bot-style MCP: we make the data trivially askable, the user's agent does the reasoning.

Two transports share one Dispatch: newline-delimited JSON-RPC over stdio (for local Claude Desktop / Cursor) and Streamable HTTP at POST /mcp (point a remote MCP client at the running server, sharing its live data).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FilterSet added in v0.8.0

type FilterSet []query.Filter

FilterSet is []query.Filter that also accepts what an agent naturally writes. Three shapes decode:

  • the canonical array: [{"property":"plan","op":"eq","value":"pro"}]
  • an equality map: {"plan":"pro","source":"hn"} — each key becomes an eq filter
  • a bare filter object: {"property":"plan","op":"eq","value":"pro"} — one filter minus its array wrapper (reading it as an equality map would silently filter on a property literally named "property" and return a zeros-report)

Anything else errors with the shapes above — never a silent no-op.

func (*FilterSet) UnmarshalJSON added in v0.8.0

func (fs *FilterSet) UnmarshalJSON(b []byte) error

type Server

type Server struct {
	// contains filtered or unexported fields
}

func New

func New(s store.Store) *Server

func (*Server) Dispatch

func (s *Server) Dispatch(req request) *response

Dispatch handles one JSON-RPC request. Returns nil for notifications (no id / no reply expected), matching the MCP wire contract.

func (*Server) HTTPDispatch

func (s *Server) HTTPDispatch(body []byte) (status int, resp []byte)

HTTPDispatch handles one Streamable-HTTP MCP request body (POST /mcp), returning the HTTP status and response bytes. Notifications return 202 with a nil body.

func (*Server) ServeStdio

func (s *Server) ServeStdio() error

ServeStdio runs the newline-delimited JSON-RPC loop on stdin/stdout. Protocol goes on stdout; logs must go to stderr only.

func (*Server) SetAlerts added in v0.3.0

func (s *Server) SetAlerts(st *alert.Store)

func (*Server) SetAliases added in v0.8.0

func (s *Server) SetAliases(a *alias.Map)

SetAliases attaches the identity-stitching map so imported $identify events record anon→user exactly like the HTTP ingest path does.

func (*Server) SetCohorts added in v0.3.0

func (s *Server) SetCohorts(st *cohort.Store)

func (*Server) SetDefined added in v0.9.0

func (s *Server) SetDefined(d *defined.Store)

SetDefined attaches the retroactive defined-events store (the define_event tools).

func (s *Server) SetExportLinks(st *exportlink.Store)

func (*Server) SetGSC added in v0.4.1

func (s *Server) SetGSC(g *gsc.Store)

func (*Server) SetGoals added in v0.4.0

func (s *Server) SetGoals(g *goal.Store)

func (*Server) SetInsights added in v0.3.0

func (s *Server) SetInsights(st *insights.Store)

SetInsights / SetCohorts / SetWebhooks / SetAlerts attach the persistent stores. The API server forwards its own stores here so both surfaces share one source of truth.

func (*Server) SetSettings added in v0.3.0

func (s *Server) SetSettings(st *settings.Store)

SetSettings / SetTrackPlan attach the instance-control stores.

func (*Server) SetShares added in v0.4.0

func (s *Server) SetShares(st *share.Store)

func (*Server) SetTrackPlan added in v0.3.0

func (s *Server) SetTrackPlan(tp *trackplan.Store)

func (*Server) SetWebhooks added in v0.3.0

func (s *Server) SetWebhooks(st *webhook.Store)

Jump to

Keyboard shortcuts

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