mcp

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2025 License: Apache-2.0 Imports: 47 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*nmcp.Client
	ID     string
	Config ServerConfig
}

func (*Client) Capabilities

func (c *Client) Capabilities() nmcp.ServerCapabilities

type Config

type Config struct {
	MCPServers map[string]ServerConfig `json:"mcpServers"`
}

type File

type File struct {
	Data   string `json:"data"`
	EnvKey string `json:"envKey"`
}

type GlobalTokenStore

type GlobalTokenStore interface {
	ForUserAndMCP(userID, mcpID string) nmcp.TokenStorage
}

type Options

type Options struct {
	MCPBaseImage         string `usage:"The base image to use for MCP containers"`
	MCPNamespace         string `usage:"The namespace to use for MCP containers" default:"obot-mcp"`
	MCPClusterDomain     string `usage:"The cluster domain to use for MCP containers" default:"cluster.local"`
	DisallowLocalhostMCP bool   `usage:"Allow MCP containers to run on localhost"`
}

type ServerConfig

type ServerConfig struct {
	DisableInstruction bool     `json:"disableInstruction"`
	Command            string   `json:"command"`
	Args               []string `json:"args"`
	Env                []string `json:"env"`
	URL                string   `json:"url"`
	Headers            []string `json:"headers"`
	Scope              string   `json:"scope"`
	AllowedTools       []string `json:"allowedTools"`

	Files          []File        `json:"files"`
	ContainerImage string        `json:"containerImage"`
	ContainerPort  int           `json:"containerPort"`
	ContainerPath  string        `json:"containerPath"`
	Runtime        types.Runtime `json:"runtime"`
}

func ProjectServerToConfig

func ProjectServerToConfig(tokenService *jwt.TokenService, projectMCPServer v1.ProjectMCPServer, baseURL, userID string, userIsAdmin bool, allowedTools ...string) (ServerConfig, error)

func ServerToServerConfig

func ServerToServerConfig(mcpServer v1.MCPServer, scope string, credEnv map[string]string, allowedTools ...string) (ServerConfig, []string, error)

type SessionManager

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

func NewSessionManager

func NewSessionManager(ctx context.Context, tokenStorage GlobalTokenStore, baseURL string, opts Options) (*SessionManager, error)

func (*SessionManager) ClientForMCPServer

func (sm *SessionManager) ClientForMCPServer(ctx context.Context, userID string, mcpServer v1.MCPServer, serverConfig ServerConfig) (*Client, error)

func (*SessionManager) ClientForMCPServerWithOptions

func (sm *SessionManager) ClientForMCPServerWithOptions(ctx context.Context, clientScope string, mcpServer v1.MCPServer, serverConfig ServerConfig, opts ...nmcp.ClientOption) (*Client, error)

func (*SessionManager) ClientForServer

func (sm *SessionManager) ClientForServer(ctx context.Context, userID, mcpServerName, mcpServerID string, serverConfig ServerConfig) (*Client, error)

func (*SessionManager) Close

func (sm *SessionManager) Close() error

Close does nothing with the deployments and services. It just closes the local session. This should return an error to satisfy the GPTScript loader interface.

func (*SessionManager) CloseClient

func (sm *SessionManager) CloseClient(ctx context.Context, server ServerConfig, clientScope string) error

CloseClient will close the client for this MCP server, but leave the deployment running.

func (*SessionManager) GPTScriptTools

func (sm *SessionManager) GPTScriptTools(ctx context.Context, tokenService *jwt.TokenService, projectMCPServer v1.ProjectMCPServer, userID, mcpServerDisplayName, serverURL string, userIsAdmin bool, allowedTools []string) ([]gptscript.ToolDef, error)

func (*SessionManager) GetPrompt

func (sm *SessionManager) GetPrompt(ctx context.Context, userID string, mcpServer v1.MCPServer, serverConfig ServerConfig, name string, args map[string]string) ([]mcp.PromptMessage, string, error)

func (*SessionManager) GetServerDetails

func (sm *SessionManager) GetServerDetails(ctx context.Context, mcpServerName string, serverConfig ServerConfig) (types.MCPServerDetails, error)

func (*SessionManager) KubernetesEnabled

func (sm *SessionManager) KubernetesEnabled() bool

func (*SessionManager) ListPrompts

func (sm *SessionManager) ListPrompts(ctx context.Context, userID string, mcpServer v1.MCPServer, serverConfig ServerConfig) ([]mcp.Prompt, error)

func (*SessionManager) ListResources

func (sm *SessionManager) ListResources(ctx context.Context, userID string, mcpServer v1.MCPServer, serverConfig ServerConfig) ([]mcp.Resource, error)

func (*SessionManager) ListTools

func (sm *SessionManager) ListTools(ctx context.Context, userID string, mcpServer v1.MCPServer, serverConfig ServerConfig) ([]mcp.Tool, error)

func (*SessionManager) Load

func (sm *SessionManager) Load(_ context.Context, t types.Tool) ([]types.Tool, error)

Load is used by GPTScript to load tools from dynamic MCP server tool definitions. Obot is responsible for loading these tools and managing the clients and sessions. Error here to catch any server tools that slipped through. This should never be called.

func (*SessionManager) PingServer

func (sm *SessionManager) PingServer(ctx context.Context, userID string, mcpServer v1.MCPServer, serverConfig ServerConfig) (*nmcp.PingResult, error)

func (*SessionManager) ReadResource

func (sm *SessionManager) ReadResource(ctx context.Context, userID string, mcpServer v1.MCPServer, serverConfig ServerConfig, uri string) ([]mcp.ResourceContent, error)

func (*SessionManager) RestartK8sDeployment

func (sm *SessionManager) RestartK8sDeployment(ctx context.Context, server ServerConfig) error

RestartK8sDeployment restarts the Kubernetes deployment using kubectl rollout restart style. This patches the deployment with a restart annotation to trigger a rolling restart.

func (*SessionManager) Run

func (sm *SessionManager) Run(ctx engine.Context, _ chan<- types.CompletionStatus, tool types.Tool, input string) (string, error)

Run is responsible for calling MCP tools when the LLM requests their execution. This method is called by GPTScript.

func (*SessionManager) ServerCapabilities

func (sm *SessionManager) ServerCapabilities(ctx context.Context, userID string, mcpServer v1.MCPServer, serverConfig ServerConfig) (nmcp.ServerCapabilities, error)

func (*SessionManager) ShutdownServer

func (sm *SessionManager) ShutdownServer(ctx context.Context, server ServerConfig) error

ShutdownServer will close the connections to the MCP server and remove the Kubernetes objects.

func (*SessionManager) StreamServerLogs

func (sm *SessionManager) StreamServerLogs(ctx context.Context, serverConfig ServerConfig) (io.ReadCloser, error)

type Webhook

type Webhook struct {
	URL, Secret string
}

type WebhookHelper

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

func NewWebhookHelper

func NewWebhookHelper(indexer cache.Indexer) *WebhookHelper

func (*WebhookHelper) GetWebhooksForMCPServer

func (wh *WebhookHelper) GetWebhooksForMCPServer(ctx context.Context, gptClient *gptscript.GPTScript, mcpServerNamespace, mcpServerName, mcpServerCatalogEntryName, method, identifier string) ([]Webhook, error)

Jump to

Keyboard shortcuts

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