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 Blog

Use CleanTextLab with Strands Agents (MCP)

2 min read

Use CleanTextLab with Strands Agents (MCP)

Strands Agents makes it easy to compose agentic workflows in Python. CleanTextLab adds deterministic text tools (formatters, cleaners, converters) through MCP, so your agent can offload the exact operations instead of re-implementing them.

This guide shows two options:

  1. Local MCP (stdio) with npx cleantextlab-mcp
  2. Hosted MCP (SSE) with https://cleantextlab.com/api/mcp/sse

Prerequisites

  • Python 3.10+
  • A 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

Ready to build? Get your API key and wire CleanTextLab into your agents.

Try the tools mentioned

Fast, deterministic processing as discussed in this post.

Share this post
Use CleanTextLab with Strands Agents (MCP) | CleanTextLab Blog