Utiliser CleanTextLab avec Strands Agents (MCP)
•2 min read
Utiliser CleanTextLab avec Strands Agents (MCP)
Strands Agents simplifie la création d’agents en Python. CleanTextLab ajoute des outils déterministes (formatage, nettoyage, conversion) via MCP, afin que votre agent délègue des opérations précises sans les réimplémenter.
Ce guide couvre deux options :
- MCP local (stdio) avec
npx cleantextlab-mcp - MCP hébergé (SSE) avec
https://cleantextlab.com/api/mcp/sse
Prérequis
- Python 3.10+
- Une clé API Pro CleanTextLab
- Strands Agents installé
python -m venv .venv
source .venv/bin/activate
pip install strands-agents
Option A : MCP local via npx (recommandé en dev local)
from strands import Agent
from strands.tools.mcp import MCPClient
from mcp import stdio_client, StdioServerParameters
cleantextlab = MCPClient(
lambda: stdio_client(
StdioServerParameters(
command="npx",
args=["-y", "cleantextlab-mcp"],
env={"CLEANTEXTLAB_API_KEY": "ctl_live_YOUR_KEY"},
)
)
)
with cleantextlab:
agent = Agent(tools=cleantextlab.list_tools_sync())
agent("Remove line breaks from: Hello\\nworld")
Option B : MCP hébergé (SSE)
from strands import Agent
from strands.tools.mcp import MCPClient
from mcp import sse_client, SSEServerParameters
cleantextlab = MCPClient(
lambda: sse_client(
SSEServerParameters(
url="https://cleantextlab.com/api/mcp/sse",
headers={"x-api-key": "ctl_live_YOUR_KEY"},
)
)
)
with cleantextlab:
agent = Agent(tools=cleantextlab.list_tools_sync())
agent("Generate an ASCII tree from: src/app/page.tsx")
Pourquoi MCP pour les agents ?
- Sortie déterministe pour les tâches de formatage
- Moins de tokens en déléguant les opérations lourdes
- Outils réutilisables dans les workflows d’agents
Étapes suivantes
Prêt à construire ? Obtenez votre clé API et connectez CleanTextLab à vos agents.
Try the tools mentioned
Jump straight into the most relevant tools for this post.
Share this post