mcpserver

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 35 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 MaxFrameBytes = 32 << 20

MaxFrameBytes is the largest JSON-RPC frame hey mcp reads from its client: room for the largest file as content_base64 (a third larger than the file) and the rest of the call. The SDK's default (16 MiB) holds about 12 MB of file, and a frame past the cap ends the session rather than answering, so a file up to attachmentMaxBytes must fit and one a little past it is answered "too large".

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",
		Title: "HEY 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",
		Title: "HEY Search",
		Tags:  []string{"Search"},
		Blurb: "Search HEY mail: advanced search with the same refinements the search page offers.",
	},
	{
		Key:   "threads",
		Title: "HEY 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",
		Title: "HEY Contacts & Screener",
		Tags:  []string{"Contacts"},
		Blurb: "HEY contacts and The Screener: contact records and notes, bundling, and clearance (screening) decisions.",
	},
	{
		Key:   "todos",
		Title: "HEY Calendar To-dos",
		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",
		Title: "HEY Calendars",
		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",
		Title: "HEY 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 AttachConfig added in v1.14.0

type AttachConfig struct {
	Files DraftFiles
	// Origin is the HEY this runs against, e.g. https://app.hey.com: links point there.
	Origin string
}

AttachConfig serves attach_file. Nil serves none.

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
	// Attach serves attach_file in its own hey_attach tool (attach.go) when the threads
	// domain is served and the server isn't read-only. Nil serves none.
	Attach *AttachConfig
}

Config selects the served tool surface.

type DraftFiles added in v1.14.0

type DraftFiles interface {
	GetEdit(ctx context.Context, draftID int64) (*generated.MessageEditState, error)
	Put(ctx context.Context, path string, body any) (*hey.Response, error)
	Upload(ctx context.Context, filename, contentType string, content io.ReadSeeker) (*generated.DirectUpload, error)
}

DraftFiles is the slice of hey-sdk attach_file drives. Put (the draft's revision) and Upload must go through a client that never retries. The revision is a plain PUT, as update_message's is, so its answer is read as update_message's is (savedAsDraft): the SDK's UpdateDraft takes any 2xx as saved.

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, hey_attach when attach_file is served, and hey_send when send_draft is served.

func (*Server) Domains

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

Domains returns the served domains.

func (*Server) ServesAttach added in v1.14.0

func (s *Server) ServesAttach() bool

ServesAttach reports whether attach_file is served.

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