Documentation
¶
Overview ¶
Package mcpserver assembles the MCP server behind `hey mcp`: hey's tool catalog derived from hey-sdk's model exports, dispatched through the CLI's authenticated SDK client.
The generic machinery — joining behavior-model.json with openapi.json, rendering domain gateway tools, action dispatch, read-only filtering, the in-band describe action — lives in the shared toolkit at github.com/basecamp/mcp. This package supplies the product half: the curated DomainSpecs mapping hey-sdk tags to domains, the vendored model snapshot under model/ (synced by scripts/sync-mcp-model.sh, provenance recorded), and the dispatcher that turns catalog operations into hey-sdk requests.
Index ¶
Constants ¶
const Name = "hey-cli"
Name identifies the server in the MCP initialize handshake. The version is the CLI's own: `hey mcp` is the CLI serving MCP, not a separate product.
Variables ¶
var DomainSpecs = []catalog.DomainSpec{ { Key: "boxes", Tags: []string{"Boxes"}, Blurb: "HEY mail boxes: the Imbox, The Feed, the Paper Trail, Reply Later, Set Aside and Bubble Up, box groups and designations, and incremental posting changes. " + boxPaging, }, { Key: "search", Tags: []string{"Search"}, Blurb: "Search HEY mail: advanced search with the same refinements the search page offers.", }, { Key: "threads", Tags: []string{"Topics", "Entries", "Messages"}, Blurb: "HEY email threads: topics and their entries, renaming a thread, full message content, replies and forwards, drafts, and triage (trash, spam, restore, move). create_message, create_reply and update_message only ever save drafts: they never send or schedule mail, and a request to send, schedule or triage in the same call is refused. Updating a scheduled draft clears its schedule. The person can have a draft shown or revised as they like, and sends it with one press of their own: from its page in HEY (app_url), with `hey draft send <id>`, or on a confirmation this assistant asks for, where it can. Each draft save's note says which this client has.", }, { Key: "contacts", Tags: []string{"Contacts"}, Blurb: "HEY contacts and The Screener: contact records and notes, bundling, and clearance (screening) decisions.", }, { Key: "todos", Tags: []string{"Calendar Todos"}, Blurb: "HEY Calendar to-dos: create, update, complete, uncomplete, and delete. Read existing to-dos through the calendar domain's get_calendar_recordings.", }, { Key: "calendar", Tags: []string{"Calendars"}, Blurb: "HEY Calendars: list calendars, read their recordings (to-dos and events — the to-do read path), and toggle calendar visibility.", }, { Key: "identity", Tags: []string{"Identity"}, Blurb: "Your HEY identity: accounts, senders, and preferences — the acting_sender_id and acting_user_id lookups that replies and contact writes ask for.", }, }
DomainSpecs curates which slice of the hey-sdk surface each domain gateway tool exposes, in tool display order. Tags are hey-sdk's OpenAPI tags (each operation carries exactly one); a spec may merge several tags into one tool. This mapping is the only hand-maintained part of the catalog — everything else derives from the SDK model via the toolkit.
The first release serves five domains covering everyday mail and task work: boxes, search, threads, contacts, todos. Tags left unmapped are reported in Catalog.Unmapped and pinned by tests, so growing the surface is a one-line change here plus a snapshot refresh.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API interface {
Get(ctx context.Context, path string) (*hey.Response, error)
Post(ctx context.Context, path string, body any) (*hey.Response, error)
Put(ctx context.Context, path string, body any) (*hey.Response, error)
Patch(ctx context.Context, path string, body any) (*hey.Response, error)
Delete(ctx context.Context, path string) (*hey.Response, error)
}
API is the slice of the hey-sdk client the dispatcher drives. *hey.Client satisfies it; the client carries auth, account scoping, retry, and base URL resolution, so the dispatcher only assembles paths and bodies. Retry policy is the implementation's to choose per verb — the CLI wires reads through a retrying client and every mutation through one that never retries, because a retried PUT can deliver a message twice.
type Config ¶
type Config struct {
// ReadOnly drops every write action from the catalog and refuses write
// dispatch outright. Without it, the operations that can deliver mail
// still only save drafts (drafts.go).
ReadOnly bool
// Domains narrows the served domains by key ("boxes", "search", ...).
// Empty means all. Unknown keys are a startup error — fail closed.
Domains []string
// Send is set when the sign-in can send. It serves send_draft in its own hey_send
// tool (send.go) when the threads domain is served and the server isn't read-only.
// Nil serves no way to send.
Send *SendConfig
}
Config selects the served tool surface.
type Drafts ¶ added in v1.11.0
type Drafts interface {
GetEdit(ctx context.Context, draftID int64) (*generated.MessageEditState, error)
SendDraft(ctx context.Context, draftID int64, draft hey.DraftContent) (*generated.SentMessage, error)
}
Drafts is the slice of hey-sdk send_draft drives. SendDraft must go through a client that never retries, because a retried send can deliver twice (D2.4).
type SendConfig ¶ added in v1.11.0
type SendConfig struct {
Drafts Drafts
// GrantKey names hey mcp's sign-in this process started on. A confirmation is bound
// to it, so an answer given under one sign-in isn't redeemed under another.
GrantKey string
// Origin is the HEY this runs against, e.g. https://app.hey.com: links point there.
Origin string
// Now is the clock; nil is time.Now.
Now func() time.Time
// CurrentGrant answers the sign-in's key as stored now, renewing a token about to
// expire first, so the send that may follow goes out on a live one. When it no
// longer matches GrantKey (hey mcp was signed in again or out since this process
// started, or a renewal narrowed the grant below sending), sends are refused until
// hey mcp restarts. Nil skips the check.
CurrentGrant func(context.Context) (string, error)
}
SendConfig serves send_draft. Nil serves none.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server wraps the toolkit gateway serving hey's derived catalog, dispatching through the CLI's authenticated SDK client.
func New ¶
New derives the catalog and hands it to the gateway, which applies the config's domain and read-only filters. Tool calls dispatch through api.
func (*Server) BuildMCPServer ¶
BuildMCPServer constructs the SDK MCP server with one gateway tool per served domain, and hey_send when send_draft is served.
func (*Server) ServesSend ¶ added in v1.11.0
ServesSend reports whether send_draft is served.