Documentation
¶
Index ¶
- func CreateOAuthMetadataHandler(resourceURL, authServerURL, resourceName string) http.HandlerFunc
- type BaseConfig
- type HTTPConfig
- type InMemoryConfig
- type MattermostHTTPMCPServer
- type MattermostInMemoryMCPServer
- type MattermostMCPServer
- type MattermostStdioMCPServer
- type PluginMCPHandlers
- type ProtectedResourceMetadata
- type StdioConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateOAuthMetadataHandler ¶ added in v1.6.0
func CreateOAuthMetadataHandler(resourceURL, authServerURL, resourceName string) http.HandlerFunc
CreateOAuthMetadataHandler creates an HTTP handler for OAuth 2.0 Protected Resource Metadata (RFC 9728)
Types ¶
type BaseConfig ¶
type BaseConfig struct {
// Mattermost server URL (e.g., "https://mattermost.company.com")
MMServerURL string `json:"mm_server_url"`
// Internal Mattermost server URL for API communication (e.g., "http://localhost:8065")
// If empty, MMServerURL will be used for internal communication
MMInternalServerURL string `json:"mm_internal_server_url"`
// Development mode enables additional tools for setting up test data
DevMode bool `json:"dev_mode"`
// TrackAIGenerated controls whether to add ai_generated_by props to posts
// For embedded servers: uses Bot UserID from metadata
// For external servers: uses authenticated user's ID
// Default: true for embedded, true for HTTP, false for stdio
TrackAIGenerated *bool `json:"track_ai_generated,omitempty"`
}
BaseConfig represents common configuration for all MCP server types
func (BaseConfig) GetDevMode ¶
func (c BaseConfig) GetDevMode() bool
GetDevMode returns the development mode setting
func (BaseConfig) GetMMInternalServerURL ¶
func (c BaseConfig) GetMMInternalServerURL() string
GetMMInternalServerURL returns the internal Mattermost server URL for API communication If not set, falls back to the external server URL for backward compatibility
func (BaseConfig) GetMMServerURL ¶
func (c BaseConfig) GetMMServerURL() string
GetMMServerURL returns the Mattermost server URL
func (BaseConfig) GetTrackAIGenerated ¶ added in v1.6.0
func (c BaseConfig) GetTrackAIGenerated() bool
GetTrackAIGenerated returns whether to track AI-generated content Defaults to true (always track) if not explicitly set
type HTTPConfig ¶
type HTTPConfig struct {
BaseConfig
// HTTP server configuration
HTTPPort int `json:"http_port"` // Port for HTTP server (default: 8080)
HTTPBindAddr string `json:"http_bind_addr"` // Bind address (default: "127.0.0.1" for security)
SiteURL string `json:"site_url"` // Site URL for external access (optional)
}
HTTPConfig represents configuration for HTTP transport MCP server
func (HTTPConfig) GetTrackAIGenerated ¶ added in v1.6.0
func (c HTTPConfig) GetTrackAIGenerated() bool
GetTrackAIGenerated returns whether to track AI-generated content For HTTP, defaults to true (enabled) unless explicitly disabled
type InMemoryConfig ¶ added in v1.5.0
type InMemoryConfig struct {
BaseConfig
}
InMemoryConfig represents configuration for in-memory transport MCP server Used for embedded MCP servers that run within the same process as the plugin
func (InMemoryConfig) GetTrackAIGenerated ¶ added in v1.6.0
func (c InMemoryConfig) GetTrackAIGenerated() bool
GetTrackAIGenerated returns whether to track AI-generated content For embedded/in-memory servers, always returns true (always track)
type MattermostHTTPMCPServer ¶
type MattermostHTTPMCPServer struct {
*MattermostMCPServer
// contains filtered or unexported fields
}
MattermostHTTPMCPServer wraps MattermostMCPServer for HTTP transport
func NewHTTPServer ¶
func NewHTTPServer(config HTTPConfig, logger loggerlib.Logger) (*MattermostHTTPMCPServer, error)
NewHTTPServer creates a new HTTP transport MCP server
func (*MattermostHTTPMCPServer) GetTestHandler ¶
func (s *MattermostHTTPMCPServer) GetTestHandler() http.Handler
GetTestHandler returns the HTTP handler for testing purposes
func (*MattermostHTTPMCPServer) Serve ¶
func (s *MattermostHTTPMCPServer) Serve() error
Serve starts the HTTP MCP server
type MattermostInMemoryMCPServer ¶ added in v1.5.0
type MattermostInMemoryMCPServer struct {
*MattermostMCPServer
// contains filtered or unexported fields
}
MattermostInMemoryMCPServer wraps MattermostMCPServer for in-memory transport This server runs embedded within the plugin process and uses session-based authentication
func NewInMemoryServer ¶ added in v1.5.0
func NewInMemoryServer(config InMemoryConfig, logger loggerlib.Logger) (*MattermostInMemoryMCPServer, error)
NewInMemoryServer creates a new in-memory transport MCP server This server is designed to run embedded within the plugin process
func (*MattermostInMemoryMCPServer) CreateConnectionForUser ¶ added in v1.5.0
func (s *MattermostInMemoryMCPServer) CreateConnectionForUser(userID, sessionID string, tokenResolver auth.TokenResolver) (*mcp.InMemoryTransport, error)
CreateConnectionForUser creates a new in-memory transport connection for a specific user Returns the client-side transport that should be used by the MCP client Accepts either: - sessionID + tokenResolver: Creates authenticated connection - empty sessionID + nil tokenResolver: Creates unauthenticated connection (for tool discovery)
type MattermostMCPServer ¶
type MattermostMCPServer struct {
// contains filtered or unexported fields
}
MattermostMCPServer provides a high-level interface for creating an MCP server with Mattermost-specific tools and authentication
func (*MattermostMCPServer) GetMCPServer ¶
func (s *MattermostMCPServer) GetMCPServer() *mcp.Server
GetMCPServer returns the underlying MCP server for testing purposes
type MattermostStdioMCPServer ¶
type MattermostStdioMCPServer struct {
*MattermostMCPServer
// contains filtered or unexported fields
}
MattermostStdioMCPServer wraps MattermostMCPServer for STDIO transport
func NewStdioServer ¶
func NewStdioServer(config StdioConfig, logger loggerlib.Logger) (*MattermostStdioMCPServer, error)
NewStdioServer creates a new STDIO transport MCP server
func (*MattermostStdioMCPServer) Serve ¶
func (s *MattermostStdioMCPServer) Serve() error
Serve starts the STDIO MCP server
type PluginMCPHandlers ¶ added in v1.6.0
type PluginMCPHandlers struct {
MCPHandler http.Handler
OAuthMetadataHandler http.HandlerFunc
// contains filtered or unexported fields
}
PluginMCPHandlers contains the HTTP handlers for MCP endpoints These handlers are designed to be embedded in a plugin's HTTP router
func NewPluginMCPHandlers ¶ added in v1.6.0
func NewPluginMCPHandlers(siteURL string, logger loggerlib.Logger) (*PluginMCPHandlers, error)
NewPluginMCPHandlers creates MCP handlers for use within a Mattermost plugin The handlers expect requests to have an Authorization Bearer token injected by the plugin middleware
type ProtectedResourceMetadata ¶
type ProtectedResourceMetadata struct {
Resource string `json:"resource"` // Required: The protected resource's resource identifier URL
AuthorizationServers []string `json:"authorization_servers,omitempty"` // Optional: Authorization servers
ScopesSupported []string `json:"scopes_supported,omitempty"` // Recommended: OAuth scopes
ResourceName string `json:"resource_name,omitempty"` // Recommended: Human-readable name
}
ProtectedResourceMetadata represents OAuth 2.0 Protected Resource Metadata (RFC 9728)
type StdioConfig ¶
type StdioConfig struct {
BaseConfig
// Personal Access Token for authentication
PersonalAccessToken string `json:"personal_access_token"`
}
StdioConfig represents configuration for STDIO transport MCP server
func (StdioConfig) GetTrackAIGenerated ¶ added in v1.6.0
func (c StdioConfig) GetTrackAIGenerated() bool
GetTrackAIGenerated returns whether to track AI-generated content For stdio, defaults to false (disabled) unless explicitly enabled