Skip to main content

A library for developing workflow graphs that run as MCP (Model Context Protocol) servers

Project description

artificer-workflows

Build multi-step workflows that guide AI agents through complex tasks exposed as MCP tools.

Alpha Release - APIs may change.

How it works

Define workflows as Python classes with typed steps. The library registers them as tools with your FastMCP server that agents can call to execute the workflow step by step. Each step provides instructions to the agent and validates outputs using Pydantic schemas.

When an agent calls a workflow tool, it receives structured instructions for what to do. After completing the work, the agent calls back with results that are validated against the step's schema. The workflow then transitions to the next step or completes.

Installation

pip install artificer-workflows

Quick example

from pydantic import BaseModel, Field
from fastmcp import FastMCP
from artificer.workflows import Workflow

mcp = FastMCP(name="my-workflows")


class BuildFeature(Workflow):
   ...


class GatherRequirementsStep(BuildFeature.Step, start=True):
    class OutputModel(BaseModel):
        summary: str = Field(description="Summary of requirements")

    def start(self, previous_result=None) -> str:
        # return instructions
        return "Gather requirements from the user and document them."

    def complete(self, output: OutputModel) -> type["PlanStep"]:
        # returns next step
        return PlanStep


class PlanStep(BuildFeature.Step):
    class OutputModel(BaseModel):
        tasks: list[str] = Field(description="List of tasks to implement")

    def start(self, previous_result: GatherRequirementsStep.OutputModel=None) -> str:
        return f"Create an implementation plan based on: {previous_result.summary}"

    def complete(self, output: OutputModel) -> None:
        # return None to complete the workflow
        return None


BuildFeature.register(mcp)


if __name__ == "__main__":
    mcp.run()

Run the server and connect it to your agent. The agent can now call:

  • BuildFeature__start_workflow - Start a new workflow
  • BuildFeature__complete_step - Complete a step and move to the next
  • BuildFeature__generate_diagram - Generate a Mermaid diagram of the workflow

Features

  • Type-safe step outputs - Pydantic schemas validate agent responses
  • Automatic MCP tool generation - Steps become callable tools
  • Workflow state persistence - Workflows can rewound and restarted from any step
  • Error handling and retries - Steps can fail and retry with configurable limits
  • Template support - Use Jinja2 templates for step instructions
  • Branching workflows - Steps can conditionally route to different next steps
  • Mermaid Diagram - Generate a mermaid diagram of your workflow

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

artificer_workflows-0.1.0a18.tar.gz (111.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

artificer_workflows-0.1.0a18-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file artificer_workflows-0.1.0a18.tar.gz.

File metadata

File hashes

Hashes for artificer_workflows-0.1.0a18.tar.gz
Algorithm Hash digest
SHA256 9f95b71b43df51c58bd475bfd682c5d076b0de901dc983d86df53d54e5b59dd1
MD5 e9af67c3c87b5740757aecf1afd71007
BLAKE2b-256 f6d4173306216c93b65a5236039790d57b2535231f8f0d50c1017a0e9f6bf0ea

See more details on using hashes here.

File details

Details for the file artificer_workflows-0.1.0a18-py3-none-any.whl.

File metadata

File hashes

Hashes for artificer_workflows-0.1.0a18-py3-none-any.whl
Algorithm Hash digest
SHA256 99bd08de446f02154931c6d18498d8e5a25ebdde2f5dbed18c7a5d17574a801b
MD5 87d16e6b8b5652ccbfe5d16a7b4f82bd
BLAKE2b-256 3034118800a69f7b3b6e6779a52503411ef3c55204182c5e73a2dcef50bc8780

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page