Documentation
¶
Index ¶
- func BuildProxyTools(ctx context.Context, cfg mcppkg.PluginServerConfig, ...) ([]*gosdkmcp.Tool, []gosdkmcp.ToolHandler, error)
- 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 PluginServerRegistry
- type ProtectedResourceMetadata
- type StdioConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildProxyTools ¶
func BuildProxyTools( ctx context.Context, cfg mcppkg.PluginServerConfig, sourcePluginAPI mmapi.Client, ) ([]*gosdkmcp.Tool, []gosdkmcp.ToolHandler, error)
BuildProxyTools proxies a source plugin's MCP tools into the external server.
func CreateOAuthMetadataHandler ¶
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 ¶
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)
Stateless bool `json:"stateless"` // Stateless mode for multi-node/HA deployments (default: false)
}
HTTPConfig represents configuration for HTTP transport MCP server
func (HTTPConfig) GetTrackAIGenerated ¶
func (c HTTPConfig) GetTrackAIGenerated() bool
GetTrackAIGenerated returns whether to track AI-generated content For HTTP, defaults to true (enabled) unless explicitly disabled
type InMemoryConfig ¶
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 ¶
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 ¶
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 ¶
func NewInMemoryServer(config InMemoryConfig, logger loggerlib.Logger, searchService tools.SemanticSearchService, fileContentService tools.FileContentService) (*MattermostInMemoryMCPServer, error)
NewInMemoryServer creates a new in-memory transport MCP server This server is designed to run embedded within the plugin process searchService and fileContentService are optional and can be nil when the corresponding capability is unavailable
func (*MattermostInMemoryMCPServer) CreateConnectionForUser ¶
func (s *MattermostInMemoryMCPServer) CreateConnectionForUser(userID, sessionID string, tokenResolver auth.TokenResolver, beforeHookResolver auth.BeforeHookResolver) (*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, searchService tools.SemanticSearchService, fileContentService tools.FileContentService) (*MattermostStdioMCPServer, error)
NewStdioServer creates a new STDIO transport MCP server. searchService and fileContentService are optional — if nil, default HTTP-based services are created that call back to the plugin's /api/v1 endpoints.
func (*MattermostStdioMCPServer) Serve ¶
func (s *MattermostStdioMCPServer) Serve() error
Serve starts the STDIO MCP server
type PluginMCPHandlers ¶
type PluginMCPHandlers struct {
OAuthMetadataHandler http.HandlerFunc
// MCPHandler reads the active *mcp.Server on every request.
MCPHandler http.Handler
// contains filtered or unexported fields
}
PluginMCPHandlers wires the MCP HTTP handlers used by the Agents plugin's external MCP endpoint.
func NewPluginMCPHandlers ¶
func NewPluginMCPHandlers( siteURL, internalURL string, logger loggerlib.Logger, registry PluginServerRegistry, sourcePluginAPI mmapi.Client, ) (*PluginMCPHandlers, error)
NewPluginMCPHandlers creates MCP handlers for the Mattermost plugin. registry may be nil to disable plugin-server aggregation. Callers must inject auth (bearer token or user-ID) via plugin middleware.
func (*PluginMCPHandlers) RebuildExternalServer ¶
func (h *PluginMCPHandlers) RebuildExternalServer()
RebuildExternalServer reconstructs the underlying *mcp.Server from the current plugin-server registry.
type PluginServerRegistry ¶
type PluginServerRegistry interface {
ListPluginServers() []mcppkg.PluginServerConfig
}
PluginServerRegistry is the read-side contract for plugin-server aggregation.
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 ¶
func (c StdioConfig) GetTrackAIGenerated() bool
GetTrackAIGenerated returns whether to track AI-generated content For stdio, defaults to false (disabled) unless explicitly enabled