Create a solution, wrap existing tools

Learning objectives:
  • learn what a solution file contains
  • create your own solution from a template
  • test your solution
  • let an LLM draft a solution
  • let an LLM agent find and run solutions

A solution is a single Python file. It is not the tool itself: it describes the environment of the tool and how to install it (see A), how to test it (see B), and how to run it with the arguments from its metadata (see C) - plus what to cite. Album reads the file and runs each part in the environment of the solution.

A solution file defines its environment and installation (A), its test (B), and how it runs with the arguments from its metadata (C)

The example solution on the start page explains every line of such a file.

Task 1 - Start from a template

Copy the Python template that you ran on the previous page into a new folder my-solution:

album clone album:template-python:0.1.1 . my-solution
Task 2 - Make it yours

Open my-solution/solution.py. Give the solution its own identity - change group, name and version, put your name into solution_creators and remove the doi of the template - and change what it does:

def run():
    from album.runner.api import get_args
    args = get_args()
    print("Hello", args.name.upper())

Imports go inside the functions: Album reads the file before the environment of the solution exists. Then install and run your solution:

album install my-solution
album run my-solution --name Album

To wrap your own tool, add it to the environment of the solution and call it from run(). A solution can also reuse the environment of another solution; the solution development guide shows how.

Task 3 - Test it

A test lets everyone check that your solution works on their computer: pre_test() prepares the arguments, test() checks the result. Add both - the example solution has a test you can adapt - and run it:

album test my-solution

More in Testing your solution.

Task 4 - Let an LLM draft a solution

Because every solution has the same structure, an LLM such as Claude or ChatGPT can write one for you. Give it the prompt from the documentation, describe the routine you need, and save the answer as solution.py in a new folder. Then check the draft like your own solution: album install, album run and album test. The test tells you whether the draft does what you asked for.

Task 5 (optional) - Let an LLM agent use your solutions

With Album MCP, an agent works with your Album installation: it lists your catalogs, searches them, reads the arguments of solutions, installs them and runs them. Connect it to an MCP client such as Claude Desktop and ask, for example:

Which of my solutions can segment nuclei? Run the best one on ~/data/nuclei.tif.

The agent can only use solutions that exist in your catalogs, so every step is a solution you can inspect, test and re-run.

Your solution works on your computer. Next, share it with others through a catalog.