mcpserver

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: MIT Imports: 32 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

View Source
var DomainSpecs = []catalog.DomainSpec{
	{
		Key:   "boxes",
		Tags:  []string{"Boxes"},
		Blurb: "HEY mail boxes: the Imbox, Feed, Paper Trail, Reply Later, Set Aside and Bubble Up stacks, box groups and designations, and incremental posting changes.",
	},
	{
		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. When they ask to send it, call hey_send's send_draft at once where hey_send is listed: its confirmation shows them what goes out, so don't show the draft again or ask them again first. Where hey_send isn't listed, the person sends the draft from its page in HEY (app_url) or with `hey draft send <id>`.",
	},
	{
		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 todos: create, update, complete, uncomplete, and delete. Read existing todos through the calendar domain's get_calendar_recordings.",
	},
	{
		Key:   "calendar",
		Tags:  []string{"Calendars"},
		Blurb: "HEY Calendars: list calendars, read their recordings (todos and events — the todo 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

func New(api API, cfg Config) (*Server, error)

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

func (s *Server) BuildMCPServer(logger *slog.Logger) *mcp.Server

BuildMCPServer constructs the SDK MCP server with one gateway tool per served domain, and hey_send when send_draft is served.

func (*Server) Domains

func (s *Server) Domains() []gateway.Domain

Domains returns the served domains.

func (*Server) ServesSend added in v1.11.0

func (s *Server) ServesSend() bool

ServesSend reports whether send_draft is served.

Jump to

Keyboard shortcuts

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