Skip to main content
Cookie preferences

We use analytics cookies to understand usage and improve CleanTextLab. You can accept or decline Privacy policy. Manage preferences.

Back to Docs
Docs

Strands Agents

Use CleanTextLab MCP with Strands Agents for deterministic text tools.

Requirements

  • Python 3.10+
  • CleanTextLab Pro API key
  • Strands Agents installed
python -m venv .venv
source .venv/bin/activate
pip install strands-agents

Option A: Local MCP via npx (recommended for local dev)

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: Hosted MCP (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")

Why MCP for agents?

  • Deterministic output for formatting tasks
  • Lower token usage by offloading heavy text operations
  • Reusable tools across agent workflows

Next steps

  • MCP setup guide: /docs/mcp-setup
  • API reference: /docs/api
  • Automation hub: /automation

© 2026 CleanTextLab Documentation

Report
Strands Agents | CleanTextLab Docs