mcp

package
v0.1.33 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserSubjectCtxKey ctxKey = "user_subject"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BloodPressureResponse

type BloodPressureResponse struct {
	Readings []BloodPressureResult `json:"readings"`
	Count    int                   `json:"count"`
	Period   string                `json:"period"`
	Warning  string                `json:"warning,omitempty"`
}

BloodPressureResponse is the response for the get_blood_pressure tool

type BloodPressureResult

type BloodPressureResult struct {
	MeasuredAt string `json:"measured_at"`
	Systolic   int    `json:"systolic"`
	Diastolic  int    `json:"diastolic"`
	Pulse      int    `json:"pulse,omitempty"`
	Category   string `json:"category"`
	Notes      string `json:"notes,omitempty"`
}

BloodPressureResult represents a blood pressure reading for the tool response

type Config

type Config struct {
	Port           int
	DatabasePath   string
	PocketIDURL    string
	ClientID       string
	ClientSecret   string
	AllowedSubject string
	MaxQueryDays   int
	MCPServerURL   string // The public URL of this MCP server (for OAuth audience validation)
	JWKSJSON       string // Optional fallback JWKS JSON content
	UserID         int64  // The database user ID to query data for
}

Config holds MCP server configuration

func LoadConfigFromEnv

func LoadConfigFromEnv() (*Config, error)

LoadConfigFromEnv loads configuration from environment variables

type DateRangeInput

type DateRangeInput struct {
	StartDate string `json:"start_date"`
	EndDate   string `json:"end_date"`
}

DateRangeInput is a common input type for date range queries

type ExerciseLogResult

type ExerciseLogResult struct {
	ExerciseName  string   `json:"exercise_name"`
	SetsCompleted *int     `json:"sets_completed,omitempty"`
	RepsCompleted *int     `json:"reps_completed,omitempty"`
	WeightKg      *float64 `json:"weight_kg,omitempty"`
	Status        string   `json:"status"`
	Notes         string   `json:"notes,omitempty"`
}

ExerciseLogResult represents an exercise log for the tool response

type FoodIntakeResponse added in v0.1.17

type FoodIntakeResponse struct {
	Logs    []FoodIntakeResult `json:"logs"`
	Count   int                `json:"count"`
	Period  string             `json:"period"`
	Target  *FoodTargetResult  `json:"target,omitempty"`
	Warning string             `json:"warning,omitempty"`
}

FoodIntakeResponse is the response for the get_food_intake tool

type FoodIntakeResult added in v0.1.17

type FoodIntakeResult struct {
	EatenAt  string `json:"eaten_at"`
	Meal     string `json:"meal"` // Breakfast, Lunch, Dinner, Snack
	Name     string `json:"name,omitempty"`
	Weight   int    `json:"weight_g"`
	Calories int    `json:"calories"`
	Carbs    int    `json:"carbs_g"`
	Protein  int    `json:"protein_g"`
	Fat      int    `json:"fat_g"`
}

FoodIntakeResult represents a food log for the tool response

type FoodTargetResult added in v0.1.17

type FoodTargetResult struct {
	Calories int `json:"calories"`
	Carbs    int `json:"carbs_g"`
	Protein  int `json:"protein_g"`
	Fat      int `json:"fat_g"`
}

FoodTargetResult represents configured daily nutrition targets

type JWK

type JWK struct {
	Kty string `json:"kty"`
	Use string `json:"use"`
	Kid string `json:"kid"`
	Alg string `json:"alg"`
	N   string `json:"n"` // RSA modulus
	E   string `json:"e"` // RSA exponent
}

JWK represents a JSON Web Key

type JWKS

type JWKS struct {
	Keys []JWK `json:"keys"`
}

JWKS represents a JSON Web Key Set

type JWKSCache

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

JWKSCache caches JWKS (JSON Web Key Set) for token validation

type MedicationIntakeInput

type MedicationIntakeInput struct {
	StartDate      string `json:"start_date"`
	EndDate        string `json:"end_date"`
	MedicationName string `json:"medication_name"`
}

MedicationIntakeInput includes optional medication filter

type MedicationIntakeResponse

type MedicationIntakeResponse struct {
	Intakes []MedicationIntakeResult `json:"intakes"`
	Count   int                      `json:"count"`
	Period  string                   `json:"period"`
	Warning string                   `json:"warning,omitempty"`
}

MedicationIntakeResponse is the response for the get_medication_intake tool

type MedicationIntakeResult

type MedicationIntakeResult struct {
	MedicationName string  `json:"medication_name"`
	Dosage         string  `json:"dosage"`
	ScheduledAt    string  `json:"scheduled_at"`
	TakenAt        *string `json:"taken_at,omitempty"`
	Status         string  `json:"status"`
}

MedicationIntakeResult represents a medication intake for the tool response

type OAuthHandler

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

OAuthHandler handles OAuth-related endpoints and token validation

func NewOAuthHandler

func NewOAuthHandler(cfg *Config) *OAuthHandler

NewOAuthHandler creates a new OAuth handler

func (*OAuthHandler) HandleProtectedResourceMetadata

func (h *OAuthHandler) HandleProtectedResourceMetadata(w http.ResponseWriter, r *http.Request)

HandleProtectedResourceMetadata returns the OAuth Protected Resource Metadata

func (*OAuthHandler) Middleware

func (h *OAuthHandler) Middleware(next http.Handler) http.Handler

Middleware validates OAuth tokens and extracts user info

type ProtectedResourceMetadata

type ProtectedResourceMetadata struct {
	Resource             string   `json:"resource"`
	AuthorizationServers []string `json:"authorization_servers"`
	ScopesSupported      []string `json:"scopes_supported,omitempty"`
}

ProtectedResourceMetadata represents OAuth 2.0 Protected Resource Metadata (RFC9728)

type Server

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

Server represents the MCP server

func NewServer

func NewServer(cfg *Config, st *store.Store) (*Server, error)

NewServer creates a new MCP server

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Run starts the HTTP server and blocks until shutdown

type SleepLogResponse

type SleepLogResponse struct {
	Logs    []SleepLogResult `json:"logs"`
	Count   int              `json:"count"`
	Period  string           `json:"period"`
	Warning string           `json:"warning,omitempty"`
}

SleepLogResponse is the response for the get_sleep_logs tool

type SleepLogResult

type SleepLogResult struct {
	StartTime    string `json:"start_time"`
	EndTime      string `json:"end_time"`
	TotalMinutes *int   `json:"total_minutes,omitempty"`
	DeepMinutes  *int   `json:"deep_minutes,omitempty"`
	LightMinutes *int   `json:"light_minutes,omitempty"`
	REMMinutes   *int   `json:"rem_minutes,omitempty"`
	AwakeMinutes *int   `json:"awake_minutes,omitempty"`
	HeartRateAvg *int   `json:"heart_rate_avg,omitempty"`
	SpO2Avg      *int   `json:"spo2_avg,omitempty"`
	Notes        string `json:"notes,omitempty"`
}

SleepLogResult represents a sleep log for the tool response

type WeightResponse

type WeightResponse struct {
	Logs    []WeightResult `json:"logs"`
	Count   int            `json:"count"`
	Period  string         `json:"period"`
	Warning string         `json:"warning,omitempty"`
}

WeightResponse is the response for the get_weight tool

type WeightResult

type WeightResult struct {
	MeasuredAt string   `json:"measured_at"`
	Weight     float64  `json:"weight_kg"`
	Trend      *float64 `json:"trend_kg,omitempty"`
	BodyFat    *float64 `json:"body_fat_percent,omitempty"`
	Notes      string   `json:"notes,omitempty"`
}

WeightResult represents a weight log for the tool response

type WorkoutHistoryInput

type WorkoutHistoryInput struct {
	StartDate        string `json:"start_date"`
	EndDate          string `json:"end_date"`
	IncludeExercises bool   `json:"include_exercises"`
}

WorkoutHistoryInput includes option to include exercises

type WorkoutHistoryResponse

type WorkoutHistoryResponse struct {
	Sessions []WorkoutSessionResult `json:"sessions"`
	Count    int                    `json:"count"`
	Period   string                 `json:"period"`
	Warning  string                 `json:"warning,omitempty"`
}

WorkoutHistoryResponse is the response for the get_workout_history tool

type WorkoutSessionResult

type WorkoutSessionResult struct {
	GroupName     string              `json:"group_name"`
	VariantName   string              `json:"variant_name"`
	ScheduledDate string              `json:"scheduled_date"`
	Status        string              `json:"status"`
	StartedAt     *string             `json:"started_at,omitempty"`
	CompletedAt   *string             `json:"completed_at,omitempty"`
	Notes         string              `json:"notes,omitempty"`
	Exercises     []ExerciseLogResult `json:"exercises,omitempty"`
	TotalVolumeKg *float64            `json:"total_volume_kg,omitempty"`
}

WorkoutSessionResult represents a workout session for the tool response

Jump to

Keyboard shortcuts

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