mcpserver

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: Apache-2.0 Imports: 18 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 Bubbles to MCP clients (AI agents) as eight tools. The tools talk to a Backend bound to one identity, the bot user of an app token: LocalBackend calls the server's own services in-process (the Streamable HTTP endpoint /api/v1/mcp), RemoteBackend calls the REST API through pkg/bubblesclient (the `bubbles mcp --conn` stdio bridge). Both apply the same permission rules because both end in the same services: no permission logic lives here beyond the scope pre-check.

Index

Constants

This section is empty.

Variables

View Source
var ToolNames = []string{
	"list_channels", "read_messages", "search_messages", "post_message",
	"list_alerts", "post_alert", "ack_alert", "resolve_alert",
}

ToolNames are the tools the server registers, in registration order.

Functions

func New

func New(b Backend, info Info) *mcp.Server

New returns an MCP server with the eight Bubbles tools, all served from b.

Types

type Backend

type Backend interface {
	// Scopes returns the scopes of the token.
	Scopes(ctx context.Context) ([]string, error)
	// ListChannels returns the channels the bot can use.
	ListChannels(ctx context.Context) ([]protocol.Channel, error)
	// ReadMessages returns up to limit messages of a channel, oldest first,
	// older than the message id before when it is set.
	ReadMessages(ctx context.Context, channelID, before string, limit int) (protocol.MessagePage, error)
	// Search runs a search query over the bot's channels; cursor is the
	// next_cursor of the previous page (empty for the first).
	Search(ctx context.Context, query, cursor string) (protocol.SearchPage, error)
	// PostMessage posts as the bot.
	PostMessage(ctx context.Context, channelID string, m protocol.NewMessage) (protocol.Message, error)
	// ListAlerts returns alert messages, newest first; cursor as for Search.
	ListAlerts(ctx context.Context, state, channelID, cursor string) (protocol.AlertPage, error)
	// PostAlert creates or updates an alert.
	PostAlert(ctx context.Context, in protocol.AlertInput) (protocol.PostedAlert, error)
	// AckAlert acknowledges an alert by message id.
	AckAlert(ctx context.Context, id string) (protocol.Message, error)
	// ResolveAlert resolves an alert by message id (id) or by dedupe key.
	ResolveAlert(ctx context.Context, id, dedupeKey, text string) (protocol.Message, error)
}

Backend is the data access of the tools, bound to one app token.

func NewLocal

func NewLocal(svc Services, actor chat.Actor, aud audit.Actor, lim Limits) Backend

NewLocal returns the backend that calls services directly as actor, the app's bot with its token's scopes and channel allowlist. aud is recorded in the audit log for alert changes, and lim is the REST API's ingest limits.

func NewRemote

func NewRemote(c *bubblesclient.Client) Backend

NewRemote returns the backend that calls a Bubbles server's REST API with the client's app token (the stdio bridge).

type Info

type Info struct {
	// Version is the Bubbles version; empty means "dev".
	Version string
	Logger  *slog.Logger
}

Info identifies the server to MCP clients.

type Limits

type Limits struct {
	Posts  *auth.BucketLimiter
	Alerts *auth.BucketLimiter
}

Limits are the ingest limiters of the REST API, shared with the local backend so MCP posts draw from the same buckets as REST posts: Posts is keyed by the acting user id, Alerts by the app's bot user id. A nil limiter does not limit.

type RateLimitedError

type RateLimitedError struct {
	RetryAfter time.Duration
}

RateLimitedError is returned when a post is refused by a limiter. Its text is what the tool result shows.

func (RateLimitedError) Error

func (e RateLimitedError) Error() string

type Services

type Services struct {
	Chat   *chat.Service
	Search *search.Service
	Alerts *alerts.Service
}

Services are the in-process services the local backend calls.

Jump to

Keyboard shortcuts

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