Documentation
¶
Overview ¶
Package mcpserver implements slowmonster's MCP Resource Server.
Index ¶
- func GRPCStatusToMCPError(err error) error
- func RegisterAll(s *mcp.Server, getSession func(ctx context.Context) (*client.Session, error))
- type AddReportLineInput
- type AddReportLineOutput
- type AmountDTO
- type Claims
- type Config
- type CreateAmountInput
- type CreateAmountOutput
- type CreateReportInput
- type CreateReportOutput
- type CreateTicketInput
- type CreateTicketOutput
- type CreateTimeInput
- type CreateTimeOutput
- type DeleteAmountInput
- type DeleteAmountOutput
- type DeleteReportInput
- type DeleteReportLineInput
- type DeleteReportLineOutput
- type DeleteReportOutput
- type DeleteTicketInput
- type DeleteTicketOutput
- type DeleteTimeInput
- type DeleteTimeOutput
- type Error
- type ExecutedLineDTO
- type ExecutedReportDTO
- type FindTicketsInput
- type FindTicketsOutput
- type GetAmountInput
- type GetAmountOutput
- type GetCurrentUserInput
- type GetCurrentUserOutput
- type GetReportInput
- type GetReportOutput
- type GetTicketInput
- type GetTicketOutput
- type GetTimeInput
- type GetTimeOutput
- type ListAmountsInput
- type ListAmountsOutput
- type ListReportsInput
- type ListReportsOutput
- type ListTicketsInput
- type ListTicketsOutput
- type ListTimesInput
- type ListTimesOutput
- type Nullable
- type ReorderTicketsInput
- type ReorderTicketsOutput
- type ReparentTicketsInput
- type ReparentTicketsOutput
- type ReportDTO
- type ReportLineDTO
- type ReportLineInput
- type RunReportsInput
- type RunReportsOutput
- type Server
- type SimpleTicketIDInput
- type TicketDTO
- type TicketListItem
- type TicketRef
- type TimeDTO
- type UpdateAmountInput
- type UpdateAmountOutput
- type UpdateReportInput
- type UpdateReportLineInput
- type UpdateReportLineOutput
- type UpdateReportOutput
- type UpdateTicketInput
- type UpdateTicketOutput
- type UpdateTimeInput
- type UpdateTimeOutput
- type Validator
- type ValidatorConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GRPCStatusToMCPError ¶
GRPCStatusToMCPError converts an error returned by a gRPC call into an *Error suitable for surfacing in an MCP tool result. nil maps to nil. Non-gRPC errors map to "internal".
func RegisterAll ¶
RegisterAll registers every MCP tool on the given server. getSession is called from each tool handler to obtain the per-request slowmo Session that was attached to the request context by the auth middleware.
Types ¶
type AddReportLineInput ¶
type AddReportLineInput struct {
ReportName string `json:"report_name"`
TicketID string `json:"ticket_id"`
Metric string `json:"metric"`
Style string `json:"style"`
PeriodWeeks int32 `json:"period_weeks"`
Goal float64 `json:"goal"`
}
AddReportLineInput is the input for add_report_line.
type AddReportLineOutput ¶
type AddReportLineOutput struct {
Line ReportLineDTO `json:"line"`
}
AddReportLineOutput is the output for add_report_line.
type AmountDTO ¶
type AmountDTO struct {
ID string `json:"id"`
TicketID string `json:"ticket_id"`
Description string `json:"description"`
AmountedAt string `json:"amounted_at"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
Amount float64 `json:"amount"`
}
AmountDTO is the MCP-side shape of an amount — same fields as api.Amount but with timestamps as RFC3339 strings.
type Config ¶
type Config struct {
Listen string
PublicURL string
ASIssuer string
ASMetadataURL string
JWKSURL string
GRPCHost string
TLSCert string
TLSKey string
ScopesSupported []string
GRPCPort int
GRPCSkipTLS bool
}
Config holds the runtime configuration for the MCP server.
type CreateAmountInput ¶
type CreateAmountInput struct {
TicketID string `json:"ticket_id"`
AmountedAt string `json:"amounted_at,omitempty"`
Description string `json:"description,omitempty"`
Amount float64 `json:"amount"`
}
CreateAmountInput is the input for create_amount.
type CreateAmountOutput ¶
type CreateAmountOutput struct {
Amount AmountDTO `json:"amount"`
}
CreateAmountOutput is the output for create_amount.
type CreateReportInput ¶
type CreateReportInput struct {
Name string `json:"name"`
Lines []ReportLineInput `json:"lines"`
}
CreateReportInput is the input for create_report.
type CreateReportOutput ¶
type CreateReportOutput struct {
Report ReportDTO `json:"report"`
}
CreateReportOutput is the output for create_report.
type CreateTicketInput ¶
type CreateTicketInput struct {
Priority *int64 `json:"priority,omitempty"`
RecurrenceCount *int64 `json:"recurrence_count,omitempty"`
Description string `json:"description"`
ParentID string `json:"parent_id,omitempty"`
StartTime string `json:"start_time,omitempty"`
Notes string `json:"notes,omitempty"`
RecurrenceUnit string `json:"recurrence_unit,omitempty"`
StartTimeAnchor string `json:"start_time_anchor,omitempty"`
}
CreateTicketInput is the input for create_ticket.
type CreateTicketOutput ¶
type CreateTicketOutput struct {
Ticket TicketDTO `json:"ticket"`
}
CreateTicketOutput is the output for create_ticket.
type CreateTimeInput ¶
type CreateTimeInput struct {
TicketID string `json:"ticket_id"`
StartedAt string `json:"started_at"`
EndedAt string `json:"ended_at,omitempty"`
Description string `json:"description,omitempty"`
}
CreateTimeInput is the input for create_time.
type CreateTimeOutput ¶
type CreateTimeOutput struct {
Time TimeDTO `json:"time"`
}
CreateTimeOutput is the output for create_time.
type DeleteAmountInput ¶
type DeleteAmountInput struct {
ID string `json:"id"`
}
DeleteAmountInput is the input for delete_amount.
type DeleteAmountOutput ¶
type DeleteAmountOutput struct {
OK bool `json:"ok"`
}
DeleteAmountOutput is the output for delete_amount.
type DeleteReportInput ¶
type DeleteReportInput struct {
Name string `json:"name"`
}
DeleteReportInput is the input for delete_report.
type DeleteReportLineInput ¶
type DeleteReportLineInput struct {
ID string `json:"id"`
}
DeleteReportLineInput is the input for delete_report_line.
type DeleteReportLineOutput ¶
type DeleteReportLineOutput struct {
OK bool `json:"ok"`
}
DeleteReportLineOutput is the output for delete_report_line.
type DeleteReportOutput ¶
type DeleteReportOutput struct {
OK bool `json:"ok"`
}
DeleteReportOutput is the output for delete_report.
type DeleteTicketInput ¶
type DeleteTicketInput struct {
ID string `json:"id"`
}
DeleteTicketInput is the input for delete_ticket.
type DeleteTicketOutput ¶
type DeleteTicketOutput struct {
OK bool `json:"ok"`
}
DeleteTicketOutput is the output for delete_ticket.
type DeleteTimeInput ¶
type DeleteTimeInput struct {
ID string `json:"id"`
}
DeleteTimeInput is the input for delete_time.
type DeleteTimeOutput ¶
type DeleteTimeOutput struct {
OK bool `json:"ok"`
}
DeleteTimeOutput is the output for delete_time.
type Error ¶
Error is the MCP-side error returned by tool handlers. The SDK surfaces Code in the tool error payload and Message in human-facing content.
type ExecutedLineDTO ¶
type ExecutedLineDTO struct {
TicketID string `json:"ticket_id"`
TicketDescription string `json:"ticket_description"`
Metric string `json:"metric"`
Style string `json:"style"`
PeriodWeeks int32 `json:"period_weeks"`
Goal float64 `json:"goal"`
Value float64 `json:"value"`
Today float64 `json:"today"`
}
ExecutedLineDTO is one evaluated line in a run result. Time-metric Goal and Value are seconds (per day when style=average). Today is the raw total since local midnight in the user's timezone (seconds for time metric), never averaged.
type ExecutedReportDTO ¶
type ExecutedReportDTO struct {
Name string `json:"name"`
GeneratedAt string `json:"generated_at"`
Lines []ExecutedLineDTO `json:"lines"`
}
ExecutedReportDTO is a report's run result.
type FindTicketsInput ¶
type FindTicketsInput struct {
Query string `` /* 161-byte string literal not displayed */
Limit int `json:"limit,omitempty" jsonschema:"max results (default 10)"`
}
FindTicketsInput is the input for find_tickets.
type FindTicketsOutput ¶
type FindTicketsOutput struct {
Tickets []TicketListItem `json:"tickets"`
}
FindTicketsOutput is the output for find_tickets.
type GetAmountInput ¶
type GetAmountInput struct {
ID string `json:"id"`
}
GetAmountInput is the input for get_amount.
type GetAmountOutput ¶
type GetAmountOutput struct {
Amount AmountDTO `json:"amount"`
}
GetAmountOutput is the output for get_amount.
type GetCurrentUserInput ¶
type GetCurrentUserInput struct{}
GetCurrentUserInput is empty — the tool takes no parameters.
type GetCurrentUserOutput ¶
type GetCurrentUserOutput struct {
UserID string `json:"user_id" jsonschema:"the authenticated user's UUID"`
Username string `json:"username" jsonschema:"the authenticated user's username"`
Timezone string `json:"timezone" jsonschema:"IANA timezone, empty if not set"`
}
GetCurrentUserOutput is what the AI client receives.
type GetReportInput ¶
type GetReportInput struct {
Name string `json:"name"`
}
GetReportInput is the input for get_report.
type GetReportOutput ¶
type GetReportOutput struct {
Report ReportDTO `json:"report"`
}
GetReportOutput is the output for get_report.
type GetTicketInput ¶
type GetTicketInput struct {
ID string `json:"id" jsonschema:"ticket UUID"`
}
GetTicketInput is the input for get_ticket.
type GetTicketOutput ¶
type GetTicketOutput struct {
Ticket TicketDTO `json:"ticket"`
Children []TicketRef `json:"children"`
Ancestors []TicketRef `json:"ancestors"`
}
GetTicketOutput is the output for get_ticket. Children are the ticket's direct children; Ancestors is the chain root -> ... -> immediate parent.
type GetTimeInput ¶
type GetTimeInput struct {
ID string `json:"id"`
}
GetTimeInput is the input for get_time.
type GetTimeOutput ¶
type GetTimeOutput struct {
Time TimeDTO `json:"time"`
}
GetTimeOutput is the output for get_time.
type ListAmountsInput ¶
type ListAmountsInput struct {
AmountedAfter string `json:"amounted_after,omitempty"`
AmountedBefore string `json:"amounted_before,omitempty"`
TicketIDs []string `json:"ticket_ids,omitempty"`
}
ListAmountsInput is the input for list_amounts.
type ListAmountsOutput ¶
type ListAmountsOutput struct {
Amounts []AmountDTO `json:"amounts"`
}
ListAmountsOutput is the output for list_amounts.
type ListReportsInput ¶
type ListReportsInput struct{}
ListReportsInput is the input for list_reports.
type ListReportsOutput ¶
type ListReportsOutput struct {
Reports []ReportDTO `json:"reports"`
}
ListReportsOutput is the output for list_reports.
type ListTicketsInput ¶
type ListTicketsInput struct {
Priority *int64 `json:"priority,omitempty" jsonschema:"if set, return only tickets whose priority exactly equals this value"`
ParentID string `` /* 177-byte string literal not displayed */
RootsOnly bool `` /* 132-byte string literal not displayed */
Descendants bool `` /* 131-byte string literal not displayed */
IncludeCompleted bool `json:"include_completed,omitempty" jsonschema:"include completed tickets"`
IncludeClosed bool `json:"include_closed,omitempty" jsonschema:"include closed tickets"`
}
ListTicketsInput is the input for list_tickets.
type ListTicketsOutput ¶
type ListTicketsOutput struct {
Tickets []TicketListItem `json:"tickets"`
}
ListTicketsOutput is the output for list_tickets.
type ListTimesInput ¶
type ListTimesInput struct {
StartedAfter string `json:"started_after,omitempty"`
StartedBefore string `json:"started_before,omitempty"`
TicketIDs []string `json:"ticket_ids,omitempty"`
OmitEnded bool `json:"omit_ended,omitempty"`
}
ListTimesInput is the input for list_times.
type ListTimesOutput ¶
type ListTimesOutput struct {
Times []TimeDTO `json:"times"`
}
ListTimesOutput is the output for list_times.
type Nullable ¶
type Nullable[T any] struct { Value *T // nil means the JSON value was null Present bool // the key appeared in the JSON object }
Nullable is a tri-state value for MCP partial-update inputs. A plain pointer cannot distinguish an omitted key from an explicit JSON null; Nullable can:
- key absent → Present == false
- key set to null → Present == true, Value == nil
- key set to value → Present == true, Value != nil
This lets an update handler tell "leave unchanged" apart from "clear to null".
func (*Nullable[T]) UnmarshalJSON ¶
UnmarshalJSON records that the key was present and captures null vs value. The JSON decoder only calls this for keys that actually appear in the object, so an absent key leaves Present false.
type ReorderTicketsInput ¶
type ReorderTicketsInput struct {
Orders []struct {
TicketID string `json:"ticket_id"`
Priority int64 `json:"priority"`
Order int64 `json:"order"`
} `json:"orders"`
ClearIDs []string `json:"clear_ids,omitempty"`
}
ReorderTicketsInput is the input for reorder_tickets.
type ReorderTicketsOutput ¶
type ReorderTicketsOutput struct {
OK bool `json:"ok"`
}
ReorderTicketsOutput is the output for reorder_tickets.
type ReparentTicketsInput ¶ added in v0.0.13
type ReparentTicketsInput struct {
ParentID Nullable[string] `json:"parent_id,omitzero" jsonschema:"new parent UUID; null makes the tickets top-level roots"`
IDs []string `json:"ids" jsonschema:"ticket UUIDs to move (non-empty)"`
}
ReparentTicketsInput is the input for reparent_tickets.
type ReparentTicketsOutput ¶ added in v0.0.13
type ReparentTicketsOutput struct {
Tickets []TicketListItem `json:"tickets"`
}
ReparentTicketsOutput is the output for reparent_tickets.
type ReportDTO ¶
type ReportDTO struct {
ID string `json:"id"`
Name string `json:"name"`
Lines []ReportLineDTO `json:"lines"`
}
ReportDTO is the MCP-side shape of a report definition.
type ReportLineDTO ¶
type ReportLineDTO struct {
ID string `json:"id"`
TicketID string `json:"ticket_id"`
Metric string `json:"metric"`
Style string `json:"style"`
PeriodWeeks int32 `json:"period_weeks"`
Goal float64 `json:"goal"`
}
ReportLineDTO is the MCP-side shape of a report entry ("line"). Time-metric Goal is seconds (per day when style=average).
type ReportLineInput ¶
type ReportLineInput struct {
TicketID string `json:"ticket_id"`
Metric string `json:"metric"`
Style string `json:"style"`
PeriodWeeks int32 `json:"period_weeks"`
Goal float64 `json:"goal"`
}
ReportLineInput is a line in create_report.
type RunReportsOutput ¶
type RunReportsOutput struct {
Reports []ExecutedReportDTO `json:"reports"`
}
RunReportsOutput is the output for run_reports.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server bundles the long-lived state.
type SimpleTicketIDInput ¶
type SimpleTicketIDInput struct {
ID string `json:"id"`
}
SimpleTicketIDInput is the input for tools that act on a ticket by id alone.
type TicketDTO ¶
type TicketDTO struct {
Priority *int64 `json:"priority,omitempty"`
RecurrenceCount *int64 `json:"recurrence_count,omitempty"`
Order *float64 `json:"order,omitempty"`
Notes string `json:"notes"`
UpdatedAt string `json:"updated_at"`
ParentID string `json:"parent_id,omitempty"`
StartTime string `json:"start_time,omitempty"`
ID string `json:"id"`
CreatedAt string `json:"created_at"`
ClosedAt string `json:"closed_at,omitempty"`
CompletedAt string `json:"completed_at,omitempty"`
Description string `json:"description"`
RecurrenceUnit string `json:"recurrence_unit,omitempty"`
StartTimeAnchor string `json:"start_time_anchor,omitempty"`
}
TicketDTO is the MCP-side shape of a ticket — same fields as api.Ticket but with timestamps as RFC3339 strings.
type TicketListItem ¶
type TicketListItem struct {
Priority *int64 `json:"priority,omitempty"`
Order *float64 `json:"order,omitempty"`
ID string `json:"id"`
Description string `json:"description"`
ParentID string `json:"parent_id,omitempty"`
StartTime string `json:"start_time,omitempty"`
ClosedAt string `json:"closed_at,omitempty"`
CompletedAt string `json:"completed_at,omitempty"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
TicketListItem is the compact shape returned by list_tickets / find_tickets. It mirrors TicketDTO but deliberately OMITS the notes body, which can be hundreds of KB per ticket and would blow the result token budget across a full list. The full notes are available via get_ticket.
type TicketRef ¶ added in v0.0.10
type TicketRef struct {
ID string `json:"id"`
Description string `json:"description"`
Status string `json:"status,omitempty"`
}
TicketRef is a compact reference to a ticket used in hierarchy context (get_ticket's children and ancestors). Status is "", "closed", or "done".
type TimeDTO ¶
type TimeDTO struct {
ID string `json:"id"`
TicketID string `json:"ticket_id"`
Description string `json:"description"`
StartedAt string `json:"started_at"`
EndedAt string `json:"ended_at,omitempty"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
TimeDTO is the MCP-side shape of a time entry with RFC3339 timestamps.
type UpdateAmountInput ¶
type UpdateAmountInput struct {
TicketID *string `json:"ticket_id,omitempty"`
Amount *float64 `json:"amount,omitempty"`
AmountedAt *string `json:"amounted_at,omitempty"`
Description *string `json:"description,omitempty"`
ID string `json:"id"`
}
UpdateAmountInput is the input for update_amount.
type UpdateAmountOutput ¶
type UpdateAmountOutput struct {
Amount AmountDTO `json:"amount"`
}
UpdateAmountOutput is the output for update_amount.
type UpdateReportInput ¶
UpdateReportInput is the input for update_report.
type UpdateReportLineInput ¶
type UpdateReportLineInput struct {
TicketID *string `json:"ticket_id,omitempty"`
Metric *string `json:"metric,omitempty"`
Style *string `json:"style,omitempty"`
PeriodWeeks *int32 `json:"period_weeks,omitempty"`
Goal *float64 `json:"goal,omitempty"`
ID string `json:"id"`
}
UpdateReportLineInput is the input for update_report_line. Optional fields are pointers so omission means "leave unchanged".
type UpdateReportLineOutput ¶
type UpdateReportLineOutput struct {
Line ReportLineDTO `json:"line"`
}
UpdateReportLineOutput is the output for update_report_line.
type UpdateReportOutput ¶
type UpdateReportOutput struct {
Report ReportDTO `json:"report"`
}
UpdateReportOutput is the output for update_report.
type UpdateTicketInput ¶
type UpdateTicketInput struct {
Description *string `json:"description,omitempty"`
ParentID Nullable[string] `json:"parent_id,omitzero"`
Priority *int64 `json:"priority,omitempty"`
StartTime *string `json:"start_time,omitempty"`
Notes *string `json:"notes,omitempty"`
RecurrenceCount *int64 `json:"recurrence_count,omitempty"`
RecurrenceUnit *string `json:"recurrence_unit,omitempty"`
ID string `json:"id"`
}
UpdateTicketInput is the input for update_ticket.
type UpdateTicketOutput ¶
type UpdateTicketOutput struct {
Ticket TicketDTO `json:"ticket"`
}
UpdateTicketOutput is the output for update_ticket.
type UpdateTimeInput ¶
type UpdateTimeInput struct {
TicketID *string `json:"ticket_id,omitempty"`
StartedAt *string `json:"started_at,omitempty"`
EndedAt *string `json:"ended_at,omitempty"`
Description *string `json:"description,omitempty"`
ID string `json:"id"`
}
UpdateTimeInput is the input for update_time.
type UpdateTimeOutput ¶
type UpdateTimeOutput struct {
Time TimeDTO `json:"time"`
}
UpdateTimeOutput is the output for update_time.
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator validates incoming bearer tokens.
func NewValidator ¶
func NewValidator(cfg ValidatorConfig) *Validator
NewValidator returns a Validator. JWKSRefresh defaults to 1 hour.