A team of agents with LangGraph
Build a small agent team in Python: a campaign lead turns a briefing into a list of assets, and a designer agent creates each of them in heycreo and exports it. The designer uses heycreo's MCP server, so everything it makes keeps to your workspace's templates and brand.
You need:
- Python 3.11 or later.
- A heycreo API key of a service account, from Settings → Developers → Service accounts, with MCP allowed and the toolsets Lesen, Designs aus Vorlagen and Export, and your workspace's slug, the name in its address:
app.heycreo.io/<slug>/…. - A Claude API key from the Claude Console in
ANTHROPIC_API_KEY. Any model LangChain supports works the same way.
1. Install
pip install "langchain[mcp]" langchain-anthropic
langchain[mcp] brings LangChain's MCP adapter (version 1.4 or later). The older package langchain-mcp-adapters is no longer maintained.
2. Connect to heycreo
team.py
import asyncio
import os
from fastmcp import Client
from fastmcp.client.transports import StreamableHttpTransport
from langchain.agents import create_agent
from langchain.mcp import MCPAdapter
from langchain.tools import tool
# The tools the designer may use: read templates, create and fill a design,
# export it. Nothing that deletes, publishes or changes settings.
DESIGNER_TOOLS = {
"get-templates",
"create-template-design",
"set-template-design-controls",
"get-template-design",
"studio-export",
"get-exports",
}
heycreo = StreamableHttpTransport(
url="https://app.heycreo.io/api/mcp",
headers={
"Authorization": f"Bearer {os.environ['HEYCREO_API_KEY']}",
"X-heycreo-Org": os.environ["HEYCREO_ORG"],
},
)
X-heycreo-Org names the workspace by its slug. The API key works only in its own workspace.
3. Build the team
team.py (continued)
async def run(briefing: str) -> str:
# The session stays open for the whole run, so every tool call reuses it.
async with MCPAdapter(Client(heycreo)) as adapter:
tools = [t for t in await adapter.list_tools() if t.name in DESIGNER_TOOLS]
designer = create_agent(
"claude-sonnet-5-5",
tools,
system_prompt=(
"You create marketing assets in heycreo. Always start from one of "
"the workspace's templates, fill its controls with the text you are "
"given, export it and answer with the file's link."
),
)
@tool(
"designer",
description=(
"Creates and exports one on-brand asset in heycreo. Give it the "
"channel, the format and the text."
),
)
async def call_designer(task: str) -> str:
result = await designer.ainvoke({"messages": [{"role": "user", "content": task}]})
return result["messages"][-1].content
lead = create_agent(
"claude-opus-5-5",
[call_designer],
system_prompt=(
"You lead a campaign. Turn the briefing into a list of assets "
"(channel, format, text), hand each one to the designer, and end "
"with a list of all files."
),
)
result = await lead.ainvoke({"messages": [{"role": "user", "content": briefing}]})
return result["messages"][-1].content
if __name__ == "__main__":
print(asyncio.run(run(
"Summer sale this weekend, 20 % off everything. "
"We need an Instagram post, an Instagram story and a LinkedIn post."
)))
HEYCREO_API_KEY=heycreo_… HEYCREO_ORG=your-workspace python team.py
How it works
- The lead never touches heycreo. It only plans and delegates. The designer is the only agent with heycreo tools, and only with the six listed above. That keeps each agent's prompt and its rights small.
- The designer is called as a tool. LangChain's subagents pattern: the lead calls
designeronce per asset, and each call is a separate run of the designer agent. - The brand is heycreo's job, not the prompt's. The designer fills templates; colors, fonts, logos and layout come from the template and your brand settings, whatever the model writes.
- Exports take time.
studio-exportwaits up to 25 seconds; a longer render comes back as still processing, and the designer checks again withget-exports.
The same in CrewAI
CrewAI connects an agent to an MCP server through its mcps field:
crew.py
import os
from crewai import Agent
from crewai.mcp import MCPServerHTTP
from crewai.mcp.filters import create_static_tool_filter
designer = Agent(
role="Designer",
goal="Create and export on-brand marketing assets in heycreo",
backstory="Works only from the workspace's templates.",
mcps=[
MCPServerHTTP(
url="https://app.heycreo.io/api/mcp",
headers={
"Authorization": f"Bearer {os.environ['HEYCREO_API_KEY']}",
"X-heycreo-Org": os.environ["HEYCREO_ORG"],
},
tool_filter=create_static_tool_filter(
allowed_tool_names=[
"get-templates",
"create-template-design",
"set-template-design-controls",
"studio-export",
"get-exports",
]
),
),
],
)
CrewAI stops a tool call after 30 seconds. Video exports take longer; let the designer start them with studio-export and collect them later with get-exports.