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 ¶
- type FilterSet
- type Server
- func (s *Server) Dispatch(req request) *response
- func (s *Server) HTTPDispatch(body []byte) (status int, resp []byte)
- func (s *Server) ServeStdio() error
- func (s *Server) SetAlerts(st *alert.Store)
- func (s *Server) SetAliases(a *alias.Map)
- func (s *Server) SetCohorts(st *cohort.Store)
- func (s *Server) SetDefined(d *defined.Store)
- func (s *Server) SetExportLinks(st *exportlink.Store)
- func (s *Server) SetGSC(g *gsc.Store)
- func (s *Server) SetGoals(g *goal.Store)
- func (s *Server) SetInsights(st *insights.Store)
- func (s *Server) SetSettings(st *settings.Store)
- func (s *Server) SetShares(st *share.Store)
- func (s *Server) SetTrackPlan(tp *trackplan.Store)
- func (s *Server) SetWebhooks(st *webhook.Store)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FilterSet ¶ added in v0.8.0
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
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
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 ¶
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 ¶
ServeStdio runs the newline-delimited JSON-RPC loop on stdin/stdout. Protocol goes on stdout; logs must go to stderr only.
func (*Server) SetAliases ¶ added in v0.8.0
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 (*Server) SetDefined ¶ added in v0.9.0
SetDefined attaches the retroactive defined-events store (the define_event tools).
func (*Server) SetExportLinks ¶ added in v0.8.0
func (s *Server) SetExportLinks(st *exportlink.Store)
func (*Server) SetInsights ¶ added in v0.3.0
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
SetSettings / SetTrackPlan attach the instance-control stores.