mcpserver

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 17 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 exposes a WhatsApp client as Model Context Protocol tools.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsLoopback

func IsLoopback(addr string) bool

IsLoopback reports whether addr (host:port) only listens on the local machine.

func LoadOrCreateToken

func LoadOrCreateToken(path string) (string, error)

LoadOrCreateToken returns the token stored at path, creating a random one (0600) on first use.

func New

func New(client *wa.Client, mediaDir, version string, opts Options) *mcp.Server

New builds the MCP server with its tools registered.

func RequireBearer

func RequireBearer(token string, next http.Handler) http.Handler

RequireBearer rejects requests whose Authorization header does not carry token.

Types

type ChatOut

type ChatOut struct {
	JID           string      `json:"jid"`
	Name          string      `json:"name"`
	IsGroup       bool        `json:"is_group"`
	LastMessageAt string      `json:"last_message_at,omitempty"`
	LastMessage   *MessageOut `json:"last_message,omitempty"`
}

ChatOut is a chat as returned to the model.

type ChatsOut

type ChatsOut struct {
	Chats []ChatOut `json:"chats"`
}

ChatsOut wraps a list of chats.

type ContactsOut

type ContactsOut struct {
	Contacts []wa.Candidate `json:"contacts"`
}

ContactsOut wraps contact matches.

type DeletedOut added in v0.2.0

type DeletedOut struct {
	Deleted bool `json:"deleted"`
}

DeletedOut confirms a deletion.

type DownloadOut

type DownloadOut struct {
	Path     string `json:"path"`
	MimeType string `json:"mime_type,omitempty"`
}

DownloadOut describes a downloaded file.

type LoadOlderOut added in v0.2.0

type LoadOlderOut struct {
	NewMessages int    `json:"new_messages"`
	Note        string `json:"note,omitempty"`
}

LoadOlderOut reports a history request.

type MessageOut

type MessageOut struct {
	ID        string        `json:"id"`
	Chat      string        `json:"chat_jid,omitempty"`
	ChatName  string        `json:"chat_name,omitempty"`
	Sender    string        `json:"sender"`
	SenderJID string        `json:"sender_jid,omitempty"`
	FromMe    bool          `json:"from_me"`
	Time      string        `json:"time"`
	Text      string        `json:"text"`
	MediaType string        `json:"media_type,omitempty"`
	Filename  string        `json:"filename,omitempty"`
	ReplyTo   string        `json:"reply_to_message_id,omitempty"`
	Reactions []ReactionOut `json:"reactions,omitempty"`
	Edited    bool          `json:"edited,omitempty"`
	Deleted   bool          `json:"deleted,omitempty"`
}

MessageOut is a message as returned to the model.

type MessagesOut

type MessagesOut struct {
	Chat     string       `json:"chat_jid"`
	ChatName string       `json:"chat_name"`
	Messages []MessageOut `json:"messages"`
}

MessagesOut wraps messages of one chat.

type Options added in v0.2.0

type Options struct {
	// ReadOnly hides every tool that sends something to WhatsApp.
	ReadOnly bool
	// AllowedChats, when non-nil, is the only set of chat JIDs the tools may
	// read from or send to.
	AllowedChats []string
}

Options restrict what the tools may do.

type ReactionOut added in v0.2.0

type ReactionOut struct {
	Emoji  string `json:"emoji"`
	Sender string `json:"sender"`
}

ReactionOut is an emoji reaction to a message.

type SearchOut

type SearchOut struct {
	Messages []MessageOut `json:"messages"`
}

SearchOut wraps search results.

type SentOut

type SentOut struct {
	ID     string `json:"id"`
	To     string `json:"to"`
	ToName string `json:"to_name"`
	Time   string `json:"time"`
}

SentOut confirms a sent message.

type Server

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

Server holds the dependencies shared by the tools.

type StatusOut

type StatusOut struct {
	LoggedIn  bool   `json:"logged_in"`
	Connected bool   `json:"connected"`
	Account   string `json:"account,omitempty"`
	Chats     int    `json:"stored_chats"`
	Messages  int    `json:"stored_messages"`
}

StatusOut is the result of whatsapp_status.

Jump to

Keyboard shortcuts

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