IntegrationsAgent frameworks
LangGraph
Give LangGraph and LangChain agents Artiwright's tools, with one Artiwright session per thread.
The artiwright Python package gives LangGraph agents Artiwright’s tools as LangChain tools, through LangChain’s MCP
adapters. Each LangGraph thread gets its own Artiwright session, so follow-up messages edit the same deck.
Prerequisites
Section titled “Prerequisites”- Python 3.10 or newer (prerequisites). Node.js isn’t needed: the package brings its own.
- A chat model for LangChain, with its API key (for example
OPENAI_API_KEYorGOOGLE_API_KEY).
Install
Section titled “Install”pip install "artiwright[langgraph]"Add the LangChain package for your model, for example langchain-openai or langchain-google-genai. On first use
Artiwright downloads its JavaScript dependencies into ~/.cache/artiwright; run artiwright-setup to do it ahead of
time.
Minimal example
Section titled “Minimal example”-
Create the agent with Artiwright’s tools:
agent.py import asynciofrom langgraph.prebuilt import create_react_agentfrom artiwright.langgraph import INSTRUCTION, agent_tools, compact_messages, get_toolsasync def main():tools = agent_tools(await get_tools(root="./artiwright-sessions", session="demo"))agent = create_react_agent("openai:gpt-6-luna", # or "google_genai:gemini-3.8-flash"tools,prompt=INSTRUCTION,pre_model_hook=compact_messages,)result = await agent.ainvoke({"messages": [("user", "Make a three-slide summary of Q3: revenue up 18% to $4.2M, and a plan for Q4.")]},{"recursion_limit": 150},)print(result["messages"][-1].content)asyncio.run(main()) -
Run it:
python agent.py -
Find the file under
./artiwright-sessions/demo/outputs/. The agent’s last message names it.
How it fits together
Section titled “How it fits together”get_tools(root, session=...)starts Artiwright’s MCP server over stdio and returns its tools. Use the thread id assessionso every turn in a thread works on the same documents.agent_tools(tools)keeps the tools an agent that writes code needs, and leaves outartiwright_apply(for clients that can’t run code), so its schema isn’t sent with every request.INSTRUCTIONteaches the working loop: plan, build, render, lint, fix, finalize.compact_messagesis apre_model_hook: it sends older tool calls and results in short form, a few at a time so the model provider’s prompt cache keeps working. Every model call resends the conversation, so this keeps a long deck’s cost down; the graph state still keeps every message.recursion_limit: a deck can take a few dozen tool calls, and LangGraph counts about three steps per call. Allow enough (150 is a good start); “need more steps” means the limit was hit.
In a multi-agent graph
Section titled “In a multi-agent graph”Make the Artiwright agent one node of your graph and give it facts from your other agents, for example by passing a retrieval tool alongside Artiwright’s:
documents = create_react_agent( model, [*agent_tools(await get_tools(root="/srv/artiwright-sessions", session=thread_id)), search_knowledge_base], prompt=INSTRUCTION + "\nUse search_knowledge_base for every number you put on a slide.", pre_model_hook=compact_messages, name="artiwright_agent",)Add to INSTRUCTION rather than replacing it, and add what the agent can’t know (audience, house style, where the
facts are), not rules that shorten its build, look, check, fix loop: see
instructions that help, and ones that hurt.
Options
Section titled “Options”get_tools(...) takes:
| Option | Default | What it does |
|---|---|---|
root |
required | Folder for sessions and finished files |
session |
None ("default") |
The Artiwright session; use the thread id |
theme |
None |
Theme for new files: preset name, template path, or {"brand": "#…"} |
sandbox |
True |
Run the agent’s code in Artiwright’s sandbox |
connection(...) takes the same options and returns the stdio connection, for your own MultiServerMCPClient.
Troubleshooting
Section titled “Troubleshooting”pip says it can’t find a version of mcp
Your Python is older than 3.10, often macOS’s built-in 3.9. Create the virtual environment with a newer Python (prerequisites).
Dependency conflict on mcp
LangChain’s MCP adapters 0.3 need mcp below 2.0. Artiwright works with either, so let pip pick a version that
satisfies the adapters.