Skip to main content
Glama

Portainer MCP

Official
by portainer
zlib License
67
  • Linux
  • Apple
token.go1.91 kB
package main import ( "encoding/json" "flag" "os" "github.com/portainer/portainer-mcp/pkg/toolgen" "github.com/rs/zerolog/log" ) // AnthropicTool defines the structure expected by the Anthropic API type AnthropicTool struct { Name string `json:"name"` Description string `json:"description"` InputSchema any `json:"input_schema"` // Annotations any `json:"annotations"` // Annotations are currently not supported by the Anthropic API } func main() { inputYamlPath := flag.String("input", "", "Path to the input tools YAML file (mandatory)") outputPath := flag.String("output", "", "Path to the output JSON file (mandatory)") flag.Parse() if *inputYamlPath == "" { log.Fatal().Msg("Input YAML path is mandatory. Please specify using -input flag.") } if *outputPath == "" { log.Fatal().Msg("Output path is mandatory. Please specify using -output flag.") } tools, err := toolgen.LoadToolsFromYAML(*inputYamlPath, "1.0") if err != nil { log.Fatal().Err(err).Msg("failed to load tools") } // Convert map[string]mcp.Tool to []AnthropicTool for correct JSON structure var anthropicToolList []AnthropicTool for _, tool := range tools { // Only include fields expected by Anthropic anthropicTool := AnthropicTool{ Name: tool.Name, Description: tool.Description, InputSchema: tool.InputSchema, // Assuming mcp.Tool has InputSchema field // Annotations: tool.Annotations, // Removed annotations } anthropicToolList = append(anthropicToolList, anthropicTool) } jsonData, err := json.MarshalIndent(anthropicToolList, "", " ") if err != nil { log.Fatal().Err(err).Msg("failed to marshal tools to JSON") } err = os.WriteFile(*outputPath, jsonData, 0644) if err != nil { log.Fatal().Err(err).Str("path", *outputPath).Msg("failed to write JSON to file") } log.Info().Str("path", *outputPath).Msg("Successfully wrote tools to JSON file") }

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