Documentation
¶
Overview ¶
Package mcpserver exposes a WhatsApp client as Model Context Protocol tools.
Index ¶
- func IsLoopback(addr string) bool
- func LoadOrCreateToken(path string) (string, error)
- func New(client *wa.Client, mediaDir, version string, opts Options) *mcp.Server
- func RequireBearer(token string, next http.Handler) http.Handler
- type ChatOut
- type ChatsOut
- type ContactsOut
- type DeletedOut
- type DownloadOut
- type LoadOlderOut
- type MessageOut
- type MessagesOut
- type Options
- type ReactionOut
- type SearchOut
- type SentOut
- type Server
- type StatusOut
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsLoopback ¶
IsLoopback reports whether addr (host:port) only listens on the local machine.
func LoadOrCreateToken ¶
LoadOrCreateToken returns the token stored at path, creating a random one (0600) on first use.
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 ¶
ContactsOut wraps contact matches.
type DeletedOut ¶ added in v0.2.0
type DeletedOut struct {
Deleted bool `json:"deleted"`
}
DeletedOut confirms a deletion.
type DownloadOut ¶
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
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.