Skip to main content
Glama

Portainer MCP

Official
by portainer
zlib License
67
  • Linux
  • Apple
test_env.go1.54 kB
package helpers import ( "context" "fmt" "testing" "github.com/portainer/client-api-go/v2/client" "github.com/portainer/portainer-mcp/internal/mcp" "github.com/portainer/portainer-mcp/tests/integration/containers" "github.com/stretchr/testify/require" ) const ( ToolsPath = "../../internal/tooldef/tools.yaml" ) // TestEnv holds the test environment configuration and clients type TestEnv struct { Ctx context.Context Portainer *containers.PortainerContainer RawClient *client.PortainerClient MCPServer *mcp.PortainerMCPServer } // NewTestEnv creates a new test environment with Portainer container and clients func NewTestEnv(t *testing.T, opts ...containers.PortainerContainerOption) *TestEnv { ctx := context.Background() portainer, err := containers.NewPortainerContainer(ctx, opts...) require.NoError(t, err, "Failed to start Portainer container") host, port := portainer.GetHostAndPort() serverURL := fmt.Sprintf("%s:%s", host, port) rawCli := client.NewPortainerClient( serverURL, portainer.GetAPIToken(), client.WithSkipTLSVerify(true), ) mcpServer, err := mcp.NewPortainerMCPServer(serverURL, portainer.GetAPIToken(), ToolsPath) require.NoError(t, err, "Failed to create MCP server") return &TestEnv{ Ctx: ctx, Portainer: portainer, RawClient: rawCli, MCPServer: mcpServer, } } // Cleanup terminates the Portainer container func (e *TestEnv) Cleanup(t *testing.T) { if err := e.Portainer.Terminate(e.Ctx); err != nil { t.Logf("Failed to terminate container: %v", err) } }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/portainer/portainer-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server