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 workflowBuildFeature__complete_step- Complete a step and move to the nextBuildFeature__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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file artificer_workflows-0.1.0a13.tar.gz.
File metadata
- Download URL: artificer_workflows-0.1.0a13.tar.gz
- Upload date:
- Size: 115.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
897b4e1fa682748818fa8a2944dd2af9c9f5d2d73188e6d48a81a09aa30679f7
|
|
| MD5 |
f1fc3cb896e7439aa6ce71e610cdc549
|
|
| BLAKE2b-256 |
06cba81eac3e434496728b6e077baca42578ca5cba3dfa246709bbe602f6b516
|
File details
Details for the file artificer_workflows-0.1.0a13-py3-none-any.whl.
File metadata
- Download URL: artificer_workflows-0.1.0a13-py3-none-any.whl
- Upload date:
- Size: 15.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a9ed5ceb3e057ee4db54f84946a9c906b238307c5444fe2de629e467fc1c4f6
|
|
| MD5 |
c3d9c51c0c569ffc48673c1e8100caf6
|
|
| BLAKE2b-256 |
ca5ca435bf4bd84b618371b9cf4a95a2f15ecfeecce575ff3d6b76b8d85e3a67
|