استخدم CleanTextLab مع Strands Agents (MCP)
•2 min read
استخدم CleanTextLab مع Strands Agents (MCP)
يجعل Strands Agents بناء الوكلاء في بايثون بسيطًا. يضيف CleanTextLab أدوات حتمية (تنسيق، تنظيف، تحويل) عبر MCP حتى يتمكن وكيلك من تنفيذ عمليات دقيقة دون إعادة بنائها.
يعرض هذا الدليل خيارين:
- MCP محلي (stdio) عبر
npx cleantextlab-mcp - MCP مُستضاف (SSE) عبر
https://cleantextlab.com/api/mcp/sse
المتطلبات
- Python 3.10+
- مفتاح API Pro من CleanTextLab
- تثبيت Strands Agents
python -m venv .venv
source .venv/bin/activate
pip install strands-agents
الخيار A: MCP محلي عبر npx (مُوصى به للتطوير المحلي)
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")
الخيار B: 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")
لماذا MCP للوكلاء؟
- نتائج حتمية لمهام التنسيق
- عدد أقل من التوكنز عند تفويض العمليات الثقيلة
- أدوات قابلة لإعادة الاستخدام عبر سير عمل الوكلاء
الخطوات التالية
جاهز للبدء؟ احصل على مفتاح API ووصل CleanTextLab بوكلائك.
جرّب الأدوات المذكورة
انتقل مباشرة إلى الأدوات الأكثر صلة بهذا المقال.
Share this post