Documentation
¶
Index ¶
- Variables
- type ContainerTool
- type ContainerToolConfig
- type MCPAdapter
- func (a *MCPAdapter) AddContainerTool(name string, config ContainerToolConfig) *MCPAdapter
- func (a *MCPAdapter) AddTool(tool Tool) *MCPAdapter
- func (a *MCPAdapter) AddTools(tools ...Tool) *MCPAdapter
- func (a *MCPAdapter) AttachToServer(ctx context.Context, mcpServer *server.MCPServer) error
- func (a *MCPAdapter) Close() error
- func (a *MCPAdapter) GetEngine() *dagger.Engine
- func (a *MCPAdapter) GetRegistry() *Registry
- func (a *MCPAdapter) ImportRegistry(registry *Registry) *MCPAdapter
- func (a *MCPAdapter) WithEngine(engine *dagger.Engine) *MCPAdapter
- type MCPProxy
- type MCPServer
- func (s *MCPServer) Close() error
- func (s *MCPServer) GetEngine() *dagger.Engine
- func (s *MCPServer) GetMCPGoServer() *server.MCPServer
- func (s *MCPServer) GetRegistry() *Registry
- func (s *MCPServer) LogError(message string)
- func (s *MCPServer) LogInfo(message string)
- func (s *MCPServer) ServeHTTP(host string, port int) error
- func (s *MCPServer) ServeStdio() error
- func (s *MCPServer) Start(ctx context.Context) error
- func (s *MCPServer) WriteOutput(w io.Writer, message string) error
- type MCPServerConfig
- type Parameter
- type Prompt
- type PromptArgument
- type ProxyTool
- type Registry
- func (r *Registry) Clear()
- func (r *Registry) GetAllTools() map[string]Tool
- func (r *Registry) GetPrompt(name string) (Prompt, error)
- func (r *Registry) GetResource(uri string) (Resource, error)
- func (r *Registry) GetTool(name string) (Tool, error)
- func (r *Registry) ImportFrom(other *Registry) error
- func (r *Registry) ListTools() []string
- func (r *Registry) RegisterPrompt(prompt Prompt) error
- func (r *Registry) RegisterResource(resource Resource) error
- func (r *Registry) RegisterTool(tool Tool) error
- func (r *Registry) ToolCount() int
- type Resource
- type ServerBuilder
- func (b *ServerBuilder) AddContainerTool(name string, config ContainerToolConfig) *ServerBuilder
- func (b *ServerBuilder) AddPrompt(prompt Prompt) *ServerBuilder
- func (b *ServerBuilder) AddResource(resource Resource) *ServerBuilder
- func (b *ServerBuilder) AddTool(tool Tool) *ServerBuilder
- func (b *ServerBuilder) AddTools(tools ...Tool) *ServerBuilder
- func (b *ServerBuilder) Build() *MCPServer
- func (b *ServerBuilder) ImportRegistry(registry *Registry) *ServerBuilder
- type Tool
- type ToolExecutor
- type ToolResult
- type ToolRouter
- type Variable
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrExecutorNotSet is returned when a container tool has no executor function ErrExecutorNotSet = errors.New("tool executor function is not set") // ErrToolNotFound is returned when a requested tool is not found in the registry ErrToolNotFound = errors.New("tool not found") // ErrInvalidParameter is returned when a parameter validation fails ErrInvalidParameter = errors.New("invalid parameter") // ErrDaggerEngineNotAvailable is returned when Dagger engine is not available ErrDaggerEngineNotAvailable = errors.New("dagger engine not available") )
var DefaultRegistry = NewRegistry()
Global default registry used by Ship CLI
Functions ¶
This section is empty.
Types ¶
type ContainerTool ¶
type ContainerTool struct {
// contains filtered or unexported fields
}
ContainerTool implements Tool interface for container-based tools
func (*ContainerTool) Description ¶
func (t *ContainerTool) Description() string
Description returns the tool description
func (*ContainerTool) Execute ¶
func (t *ContainerTool) Execute(ctx context.Context, params map[string]interface{}, engine *dagger.Engine) (*ToolResult, error)
Execute runs the container tool
func (*ContainerTool) Parameters ¶
func (t *ContainerTool) Parameters() []Parameter
Parameters returns the tool parameters
type ContainerToolConfig ¶
type ContainerToolConfig struct {
Description string
Image string
Command []string
Parameters []Parameter
Execute ToolExecutor
}
ContainerToolConfig represents configuration for a container-based tool
type MCPAdapter ¶ added in v0.6.2
type MCPAdapter struct {
// contains filtered or unexported fields
}
MCPAdapter allows users to bring their own mcp-go server and add Ship tools to it
Example (AttachToServer) ¶
Integration test pattern for users wanting to test their setup
ctx := context.Background()
// User's existing MCP server
mcpServer := server.NewMCPServer("my-app", "1.0.0")
// Create Ship adapter with infrastructure tools
adapter := NewMCPAdapter()
// In real usage, you'd add actual tools:
// adapter.AddTool(tools.NewTFLintTool())
// adapter.AddTool(tools.NewCheckovTool())
// Attach Ship tools to existing server
if err := adapter.AttachToServer(ctx, mcpServer); err != nil {
panic(err)
}
// Clean up
defer adapter.Close()
// Your server now has both your tools and Ship's containerized tools
// server.ServeStdio(mcpServer)
func NewMCPAdapter ¶ added in v0.6.2
func NewMCPAdapter() *MCPAdapter
NewMCPAdapter creates a new adapter for integrating Ship tools into existing MCP servers
func (*MCPAdapter) AddContainerTool ¶ added in v0.6.2
func (a *MCPAdapter) AddContainerTool(name string, config ContainerToolConfig) *MCPAdapter
AddContainerTool creates and adds a container-based tool to the adapter
func (*MCPAdapter) AddTool ¶ added in v0.6.2
func (a *MCPAdapter) AddTool(tool Tool) *MCPAdapter
AddTool adds a Ship tool to the adapter registry
func (*MCPAdapter) AddTools ¶ added in v0.6.2
func (a *MCPAdapter) AddTools(tools ...Tool) *MCPAdapter
AddTools adds multiple Ship tools to the adapter registry
func (*MCPAdapter) AttachToServer ¶ added in v0.6.2
AttachToServer attaches all Ship tools to an existing mcp-go server
func (*MCPAdapter) Close ¶ added in v0.6.2
func (a *MCPAdapter) Close() error
Close shuts down the adapter and cleans up resources
func (*MCPAdapter) GetEngine ¶ added in v0.6.2
func (a *MCPAdapter) GetEngine() *dagger.Engine
GetEngine returns the adapter's Dagger engine
func (*MCPAdapter) GetRegistry ¶ added in v0.6.2
func (a *MCPAdapter) GetRegistry() *Registry
GetRegistry returns the adapter's registry
func (*MCPAdapter) ImportRegistry ¶ added in v0.6.2
func (a *MCPAdapter) ImportRegistry(registry *Registry) *MCPAdapter
ImportRegistry imports all tools from a Ship registry
func (*MCPAdapter) WithEngine ¶ added in v0.6.2
func (a *MCPAdapter) WithEngine(engine *dagger.Engine) *MCPAdapter
WithEngine sets the Dagger engine for the adapter
type MCPProxy ¶
type MCPProxy struct {
// contains filtered or unexported fields
}
MCPProxy manages connections to external MCP servers and creates proxy tools
func NewMCPProxy ¶
func NewMCPProxy(config MCPServerConfig) *MCPProxy
NewMCPProxy creates a new MCP proxy for an external server
type MCPServer ¶
type MCPServer struct {
// contains filtered or unexported fields
}
MCPServer represents an MCP server with tools, prompts, and resources
func (*MCPServer) GetEngine ¶
GetEngine returns the server's Dagger engine (may be nil if not started)
func (*MCPServer) GetMCPGoServer ¶
GetMCPGoServer returns the underlying mcp-go server instance
func (*MCPServer) GetRegistry ¶
GetRegistry returns the server's registry
func (*MCPServer) ServeStdio ¶
ServeStdio starts the server using stdio transport
type MCPServerConfig ¶
type MCPServerConfig struct {
Name string `json:"name"`
Command string `json:"command,omitempty"`
Args []string `json:"args,omitempty"`
Env map[string]string `json:"env,omitempty"`
BaseURL string `json:"baseUrl,omitempty"`
Transport string `json:"transport"` // "stdio", "http", "sse"
Disabled bool `json:"disabled,omitempty"`
AutoApprove []string `json:"autoApprove,omitempty"`
Variables []Variable `json:"variables,omitempty"` // Framework-defined variables
}
MCPServerConfig represents configuration for connecting to an external MCP server
type Parameter ¶
type Parameter struct {
Name string `json:"name"`
Type string `json:"type"`
Description string `json:"description,omitempty"`
Required bool `json:"required,omitempty"`
Enum []string `json:"enum,omitempty"`
}
Parameter represents a tool parameter
type Prompt ¶
type Prompt interface {
Name() string
Description() string
Arguments() []PromptArgument
}
Prompt represents an MCP prompt
type PromptArgument ¶
type PromptArgument struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Required bool `json:"required,omitempty"`
}
PromptArgument represents a prompt argument
type ProxyTool ¶
type ProxyTool struct {
// contains filtered or unexported fields
}
ProxyTool represents a tool that proxies calls to an external MCP server
func NewProxyTool ¶
func NewProxyTool(name, description string, parameters []Parameter, mcpClient client.MCPClient, externalToolName string) *ProxyTool
NewProxyTool creates a new proxy tool that forwards calls to an external MCP server
func (*ProxyTool) Description ¶
Description returns the tool description
func (*ProxyTool) Execute ¶
func (p *ProxyTool) Execute(ctx context.Context, params map[string]interface{}, engine *dagger.Engine) (*ToolResult, error)
Execute forwards the tool call to the external MCP server
func (*ProxyTool) Parameters ¶
Parameters returns the tool parameters
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages a collection of tools, prompts, and resources
func (*Registry) GetAllTools ¶
GetAllTools returns all registered tools
func (*Registry) GetResource ¶
GetResource retrieves a resource by URI
func (*Registry) ImportFrom ¶
ImportFrom imports all tools from another registry
func (*Registry) RegisterPrompt ¶
RegisterPrompt registers a prompt in the registry
func (*Registry) RegisterResource ¶
RegisterResource registers a resource in the registry
func (*Registry) RegisterTool ¶
RegisterTool registers a tool in the registry
type ServerBuilder ¶
type ServerBuilder struct {
// contains filtered or unexported fields
}
ServerBuilder provides a fluent API for building MCP servers
func NewServer ¶
func NewServer(name, version string) *ServerBuilder
NewServer creates a new server builder
func (*ServerBuilder) AddContainerTool ¶
func (b *ServerBuilder) AddContainerTool(name string, config ContainerToolConfig) *ServerBuilder
AddContainerTool creates and adds a container-based tool
func (*ServerBuilder) AddPrompt ¶
func (b *ServerBuilder) AddPrompt(prompt Prompt) *ServerBuilder
AddPrompt adds a prompt to the server
func (*ServerBuilder) AddResource ¶
func (b *ServerBuilder) AddResource(resource Resource) *ServerBuilder
AddResource adds a resource to the server
func (*ServerBuilder) AddTool ¶
func (b *ServerBuilder) AddTool(tool Tool) *ServerBuilder
AddTool adds a single tool to the server
func (*ServerBuilder) AddTools ¶
func (b *ServerBuilder) AddTools(tools ...Tool) *ServerBuilder
AddTools adds multiple tools to the server
func (*ServerBuilder) Build ¶
func (b *ServerBuilder) Build() *MCPServer
Build creates the MCP server instance
func (*ServerBuilder) ImportRegistry ¶
func (b *ServerBuilder) ImportRegistry(registry *Registry) *ServerBuilder
ImportRegistry imports all items from another registry
type Tool ¶
type Tool interface {
Name() string
Description() string
Parameters() []Parameter
Execute(ctx context.Context, params map[string]interface{}, engine *dagger.Engine) (*ToolResult, error)
}
Tool represents a tool that can be executed via MCP
func NewContainerTool ¶
func NewContainerTool(name string, config ContainerToolConfig) Tool
NewContainerTool creates a new container-based tool
type ToolExecutor ¶
type ToolExecutor func(ctx context.Context, params map[string]interface{}, engine *dagger.Engine) (*ToolResult, error)
ToolExecutor is a function type for executing container-based tools
type ToolResult ¶
type ToolResult struct {
Content string `json:"content"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
Error error `json:"error,omitempty"`
}
ToolResult represents the result of a tool execution
type ToolRouter ¶ added in v0.6.2
type ToolRouter struct {
// contains filtered or unexported fields
}
ToolRouter provides a way to selectively route tools to different MCP servers
func NewToolRouter ¶ added in v0.6.2
func NewToolRouter() *ToolRouter
NewToolRouter creates a new tool router
func (*ToolRouter) AddRoute ¶ added in v0.6.2
func (r *ToolRouter) AddRoute(pattern string, adapter *MCPAdapter) *ToolRouter
AddRoute adds a route for a specific tool or tool pattern to an adapter
func (*ToolRouter) RouteToServer ¶ added in v0.6.2
RouteToServer routes tools based on patterns to different MCP servers
type Variable ¶
type Variable struct {
Name string `json:"name"`
Description string `json:"description"`
Required bool `json:"required"`
Default string `json:"default,omitempty"`
Secret bool `json:"secret,omitempty"` // If true, value should be treated as sensitive
}
Variable represents a configurable environment variable for MCP servers