Class GooseExtensionLoader

java.lang.Object
com.tnsai.mcp.goose.GooseExtensionLoader

public class GooseExtensionLoader extends Object
Loads Goose extensions and converts them to MCP-compatible format.

Goose extensions are typically JSON configuration files that reference MCP servers. This loader reads those files and converts them to McpServerEntry objects for registry integration.

Supported file formats:

  • JSON (.json) - Full support

Example usage:


 GooseExtensionLoader loader = new GooseExtensionLoader();
 List<GooseExtension> extensions = loader.loadFromDirectory(Path.of("~/.goose/extensions"));
 Optional<McpServerEntry> entry = loader.toServerEntry(extensions.get(0));
 
See Also:
  • Constructor Details

    • GooseExtensionLoader

      public GooseExtensionLoader()
  • Method Details

    • loadFromDirectory

      public List<GooseExtensionLoader.GooseExtension> loadFromDirectory(Path dir) throws IOException
      Loads all extensions from a directory.

      Scans the directory for JSON files and attempts to parse each one as a Goose extension configuration.

      Parameters:
      dir - the directory to scan
      Returns:
      list of loaded extensions
      Throws:
      IOException - if the directory cannot be read
    • loadExtension

      public GooseExtensionLoader.GooseExtension loadExtension(Path file) throws IOException
      Loads a single Goose extension from a file.
      Parameters:
      file - the file to load
      Returns:
      the parsed extension
      Throws:
      IOException - if the file cannot be read or parsed
    • toServerEntry

      public Optional<McpServerEntry> toServerEntry(GooseExtensionLoader.GooseExtension extension)
      Converts a Goose extension to an MCP server entry.

      Only extensions of type "mcp" can be converted. Other types return an empty optional.

      Parameters:
      extension - the Goose extension
      Returns:
      the server entry, or empty if the extension is not MCP-compatible