tools

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GetDataDirectoryInternal = getDataDirectory

GetDataDirectoryInternal is the internal function that can be overridden in tests

Functions

func EnsureDataDirectory added in v1.6.0

func EnsureDataDirectory() error

EnsureDataDirectory creates the data directory if it doesn't exist

func NewJSONSchemaForAccessMode

func NewJSONSchemaForAccessMode[T any](accessMode string) *jsonschema.Schema

NewJSONSchemaForAccessMode creates a JSONSchema from a Go struct, filtering fields based on access mode

Access tag examples:

  • access:"local" - only available for local access mode
  • access:"remote" - only available for remote access mode
  • access:"local,remote" - available for both local and remote access modes
  • no access tag - available in all access modes

The function uses comma-separated parsing, so you can specify multiple access modes.

Types

type AccessMode added in v1.5.0

type AccessMode string

AccessMode represents the security access level for MCP operations

const (
	// AccessModeLocal indicates the mode has local filesystem access and can execute local operations
	AccessModeLocal AccessMode = "local"
	// AccessModeRemote indicates the mode operates over network and has security restrictions
	AccessModeRemote AccessMode = "remote"
)

type AddUserToChannelArgs

type AddUserToChannelArgs struct {
	UserID    string `json:"user_id" jsonschema:"ID of the user to add"`
	ChannelID string `json:"channel_id" jsonschema:"ID of the channel to add user to"`
}

AddUserToChannelArgs represents arguments for the add_user_to_channel tool

type AddUserToTeamArgs

type AddUserToTeamArgs struct {
	UserID string `json:"user_id" jsonschema:"ID of the user to add"`
	TeamID string `json:"team_id" jsonschema:"ID of the team to add user to"`
}

AddUserToTeamArgs represents arguments for the add_user_to_team tool (dev mode only)

type CombinedSearchArgs added in v1.14.0

type CombinedSearchArgs struct {
	Query          string `json:"query" jsonschema:"The search query,minLength=1,maxLength=4000"`
	TeamID         string `json:"team_id,omitempty" jsonschema:"Optional team ID to limit search scope,minLength=26,maxLength=26"`
	ChannelID      string `json:"channel_id,omitempty" jsonschema:"Optional channel ID to limit search to a specific channel,minLength=26,maxLength=26"`
	SemanticLimit  int    `json:"semantic_limit,omitempty" jsonschema:"Max results from semantic search (default 10; max 50),minimum=1,maximum=50"`
	SemanticOffset int    `json:"semantic_offset,omitempty" jsonschema:"Offset for semantic search pagination,minimum=0"`
	KeywordLimit   int    `json:"keyword_limit,omitempty" jsonschema:"Max results from keyword search (default 10; max 100),minimum=1,maximum=100"`
	KeywordOffset  int    `json:"keyword_offset,omitempty" jsonschema:"Offset for keyword search pagination,minimum=0"`
}

CombinedSearchArgs represents arguments for search_posts when both semantic and keyword search are available.

type CreateChannelArgs

type CreateChannelArgs struct {
	Name        string `json:"name" jsonschema:"The channel name (URL-friendly),minLength=1,maxLength=64"`
	DisplayName string `json:"display_name" jsonschema:"The channel display name,minLength=1,maxLength=64"`
	Type        string `json:"type" jsonschema:"Channel type,enum=O,enum=P"`
	TeamID      string `json:"team_id" jsonschema:"The team ID where the channel will be created,minLength=26,maxLength=26"`
	Purpose     string `json:"purpose" jsonschema:"Optional channel purpose,maxLength=250"`
	Header      string `json:"header" jsonschema:"Optional channel header,maxLength=1024"`
}

CreateChannelArgs represents arguments for the create_channel tool

type CreatePostArgs

type CreatePostArgs struct {
	ChannelID          string   `json:"channel_id" jsonschema:"The ID of the channel to post in,minLength=26,maxLength=26"`
	ChannelDisplayName string   `json:"channel_display_name" jsonschema:"The display name of the channel (for context verification),minLength=1"`
	TeamDisplayName    string   `json:"team_display_name" jsonschema:"The display name of the team (for context verification),minLength=1"`
	Message            string   `json:"message" jsonschema:"The message content,minLength=1"`
	RootID             string   `json:"root_id,omitempty" jsonschema:"Optional root post ID for replies,minLength=26,maxLength=26"`
	Attachments        []string `json:"attachments,omitempty" access:"local" jsonschema:"Optional list of file paths or URLs to attach to the post"`
}

CreatePostArgs represents arguments for the create_post tool

type CreatePostAsUserArgs

type CreatePostAsUserArgs struct {
	Username    string   `json:"username" jsonschema:"Username to login as"`
	Password    string   `json:"password" jsonschema:"Password to login with"`
	ChannelID   string   `json:"channel_id" jsonschema:"The ID of the channel to post in"`
	Message     string   `json:"message" jsonschema:"The message content"`
	RootID      string   `json:"root_id" jsonschema:"Optional root post ID for replies"`
	Props       string   `json:"props" jsonschema:"Optional post properties (JSON string)"`
	Attachments []string `json:"attachments,omitempty" access:"local" jsonschema:"Optional list of file paths or URLs to attach to the post"`
}

CreatePostAsUserArgs represents arguments for the create_post_as_user tool (dev mode only)

type CreateTeamArgs

type CreateTeamArgs struct {
	Name        string `json:"name" jsonschema:"URL name for the team,minLength=1,maxLength=64"`
	DisplayName string `json:"display_name" jsonschema:"Display name for the team,minLength=1,maxLength=64"`
	Type        string `json:"type" jsonschema:"Team type,enum=O,enum=I"`
	Description string `json:"description" jsonschema:"Team description,maxLength=255"`
	TeamIcon    string `` /* 126-byte string literal not displayed */
}

CreateTeamArgs represents arguments for the create_team tool (dev mode only)

type CreateUserArgs

type CreateUserArgs struct {
	Username     string `json:"username" jsonschema:"Username for the new user"`
	Email        string `json:"email" jsonschema:"Email address for the new user"`
	Password     string `json:"password" jsonschema:"Password for the new user"`
	FirstName    string `json:"first_name" jsonschema:"First name of the user"`
	LastName     string `json:"last_name" jsonschema:"Last name of the user"`
	Nickname     string `json:"nickname" jsonschema:"Nickname for the user"`
	ProfileImage string `` /* 136-byte string literal not displayed */
}

CreateUserArgs represents arguments for the create_user tool (dev mode only)

type DMArgs added in v1.12.0

type DMArgs struct {
	Username    string   `json:"username,omitempty" jsonschema:"Target username. If omitted the message is sent to yourself."`
	Message     string   `json:"message" jsonschema:"The message content to send,minLength=1"`
	Attachments []string `json:"attachments,omitempty" access:"local" jsonschema:"Optional list of file paths or URLs to attach"`
}

DMArgs represents arguments for the dm tool

type GetChannelInfoArgs

type GetChannelInfoArgs struct {
	ChannelID          string `json:"channel_id,omitempty" jsonschema:"The exact channel ID (fastest, most reliable method),maxLength=26"`
	ChannelDisplayName string `` /* 174-byte string literal not displayed */
	ChannelName        string `` /* 158-byte string literal not displayed */
	TeamID             string `` /* 153-byte string literal not displayed */
}

GetChannelInfoArgs represents arguments for the get_channel_info tool

type GetChannelMembersArgs

type GetChannelMembersArgs struct {
	ChannelID string `json:"channel_id" jsonschema:"ID of the channel to get members for,minLength=26,maxLength=26"`
	Limit     int    `json:"limit,omitempty" jsonschema:"Number of members to return (default: 50, max: 200),minimum=1,maximum=200"`
	Page      int    `json:"page,omitempty" jsonschema:"Page number for pagination (default: 0),minimum=0"`
}

GetChannelMembersArgs represents arguments for the get_channel_members tool

type GetTeamInfoArgs

type GetTeamInfoArgs struct {
	TeamID          string `json:"team_id,omitempty" jsonschema:"The exact team ID (fastest, most reliable method)"`
	TeamDisplayName string `json:"team_display_name,omitempty" jsonschema:"The human-readable display name users see (e.g. 'Engineering Team')"`
	TeamName        string `json:"team_name,omitempty" jsonschema:"The URL-friendly team name (e.g. 'engineering-team')"`
}

GetTeamInfoArgs represents arguments for the get_team_info tool

type GetTeamMembersArgs

type GetTeamMembersArgs struct {
	TeamID string `json:"team_id" jsonschema:"ID of the team to get members for,minLength=26,maxLength=26"`
	Limit  int    `json:"limit,omitempty" jsonschema:"Number of members to return (default: 50, max: 200),minimum=1,maximum=200"`
	Page   int    `json:"page,omitempty" jsonschema:"Page number for pagination (default: 0),minimum=0"`
}

GetTeamMembersArgs represents arguments for the get_team_members tool

type GetUserChannelsArgs added in v1.12.0

type GetUserChannelsArgs struct {
	TeamID  string `json:"team_id,omitempty" jsonschema:"Optional team ID to filter channels by team,maxLength=26"`
	Page    int    `json:"page,omitempty" jsonschema:"Page number for pagination (default: 0),minimum=0"`
	PerPage int    `json:"per_page,omitempty" jsonschema:"Number of channels per page (default: 60, max: 200),minimum=1,maximum=200"`
}

GetUserChannelsArgs represents arguments for the get_user_channels tool

type GroupMessageArgs added in v1.12.0

type GroupMessageArgs struct {
	Usernames   []string `json:"usernames" jsonschema:"Target usernames (must be at least 2)."`
	Message     string   `json:"message" jsonschema:"The message content to send,minLength=1"`
	Attachments []string `json:"attachments,omitempty" access:"local" jsonschema:"Optional list of file paths or URLs to attach"`
}

GroupMessageArgs represents arguments for the group_message tool

type HTTPSemanticSearchService added in v1.14.0

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

HTTPSemanticSearchService provides semantic search by calling back to the plugin API. This allows external MCP servers (HTTP, Stdio) to access semantic search capabilities.

func NewHTTPSemanticSearchService added in v1.14.0

func NewHTTPSemanticSearchService(pluginURL string) *HTTPSemanticSearchService

NewHTTPSemanticSearchService creates a new HTTP-based semantic search service. pluginURL should be the base URL to the plugin, e.g., "https://mattermost.example.com/plugins/mattermost-ai"

func (*HTTPSemanticSearchService) Enabled added in v1.14.0

func (s *HTTPSemanticSearchService) Enabled() bool

Enabled returns true since this service is always available when created. The actual availability check happens at the plugin endpoint.

func (*HTTPSemanticSearchService) Search added in v1.14.0

Search performs a semantic search by calling the plugin's MCP semantic search endpoint

type KeywordOnlySearchArgs added in v1.14.0

type KeywordOnlySearchArgs struct {
	Query         string `json:"query" jsonschema:"The search query,minLength=1,maxLength=4000"`
	TeamID        string `json:"team_id,omitempty" jsonschema:"Optional team ID to limit search scope,minLength=26,maxLength=26"`
	ChannelID     string `json:"channel_id,omitempty" jsonschema:"Optional channel ID to limit search to a specific channel,minLength=26,maxLength=26"`
	KeywordLimit  int    `json:"keyword_limit,omitempty" jsonschema:"Max results from keyword search (default 10; max 100),minimum=1,maximum=100"`
	KeywordOffset int    `json:"keyword_offset,omitempty" jsonschema:"Offset for keyword search pagination,minimum=0"`
}

KeywordOnlySearchArgs represents arguments for search_posts when only keyword search is available.

type MCPTool

type MCPTool struct {
	Name        string
	Description string
	Schema      *jsonschema.Schema
	Resolver    MCPToolResolver
}

MCPTool represents a tool specifically for MCP use with our custom context

type MCPToolContext

type MCPToolContext struct {
	Ctx        context.Context
	Client     *model.Client4
	AccessMode AccessMode
	BotUserID  string // User ID for AI-generated content tracking: Bot ID (embedded) or authenticated user ID (external servers)
}

MCPToolContext provides MCP-specific functionality with the authenticated client.

type MCPToolResolver

type MCPToolResolver func(*MCPToolContext, llm.ToolArgumentGetter) (string, error)

MCPToolResolver defines the signature for MCP tool resolvers

type MattermostToolProvider

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

MattermostToolProvider provides Mattermost tools following the mmtools pattern

func NewMattermostToolProvider

func NewMattermostToolProvider(authProvider auth.AuthenticationProvider, logger logger.Logger, config types.ServerConfig, accessMode AccessMode, searchService SemanticSearchService) *MattermostToolProvider

NewMattermostToolProvider creates a new tool provider Now accepts a ServerConfig interface to avoid circular dependencies searchService is optional and can be nil if semantic search is not available

func (*MattermostToolProvider) ProvideTools

func (p *MattermostToolProvider) ProvideTools(mcpServer *mcp.Server)

ProvideTools registers all available MCP tools with the server.

type ReadChannelArgs

type ReadChannelArgs struct {
	ChannelID string `json:"channel_id" jsonschema:"The ID of the channel to read from,minLength=26,maxLength=26"`
	Limit     int    `json:"limit,omitempty" jsonschema:"Number of posts to retrieve (default: 20, max: 100),minimum=1,maximum=100"`
	Since     string `json:"since,omitempty" jsonschema:"Only get posts since this timestamp (ISO 8601 format),format=date-time"`
}

ReadChannelArgs represents arguments for the read_channel tool

type ReadPostArgs

type ReadPostArgs struct {
	PostID        string `json:"post_id" jsonschema:"The ID of the post to read,minLength=26,maxLength=26"`
	IncludeThread bool   `json:"include_thread,omitempty" jsonschema:"Whether to include the entire thread (default: true)"`
}

ReadPostArgs represents arguments for the read_post tool

type SearchUsersArgs

type SearchUsersArgs struct {
	Term  string `json:"term" jsonschema:"Search term (username, email, first name, or last name),minLength=1,maxLength=64"`
	Limit int    `json:"limit,omitempty" jsonschema:"Maximum number of results to return (default: 20, max: 100),minimum=1,maximum=100"`
}

SearchUsersArgs represents arguments for the search_users tool.

type SemanticSearchService added in v1.14.0

type SemanticSearchService interface {
	Enabled() bool
	Search(ctx context.Context, query string, opts search.Options) ([]search.RAGResult, error)
}

SemanticSearchService provides semantic search capabilities for the MCP server. *search.Search implements this interface directly for embedded servers. HTTPSemanticSearchService implements it for external servers via HTTP callbacks.

type ToolProvider

type ToolProvider interface {
	ProvideTools(*mcp.Server)
}

Jump to

Keyboard shortcuts

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