Build a custom agent that uses playwright + filesystem + postgres
Quando usar: You need a repeatable automation (not Claude Desktop) that chains browser + files + DB.
Pré-requisitos
- Python 3.10+, uv or pip — Standard setup
- An LLM API key (OpenAI / Anthropic) — Set as env var your LangChain model expects
Fluxo
-
Define the server configsWrite a mcp-use config that connects to playwright (stdio via npx), postgres (stdio via uvx), and filesystem (local path scoped).✓ Copiado→ JSON/dict config matching the schema
-
Wire the agentCreate an MCPAgent using ChatAnthropic (claude-sonnet-4) and the config above. Max iterations = 15.✓ Copiado→ Agent instance ready to .run()
-
Run a taskRun: 'Crawl docs.example.com, save each page to ./knowledge/, then index titles into the postgres
docstable.' Observe tool calls in logs.✓ Copiado→ Task completes, data lands where expected
Resultado: A scriptable agent you can schedule, deploy, or embed — not tied to a desktop client.
Armadilhas
- Agent loops between servers, burning tokens — Set strict max_iterations and use an LLM that follows instructions well — GPT-4o-mini often loops on complex chains, use a stronger model
- stdio servers zombied after crash — Always use the async context manager pattern — it handles cleanup; don't manage the process yourself