Send SMS from the OpenAI Agents SDK
Connect an OpenAI Agents SDK agent to TextKit's MCP server over Streamable HTTP, with a tool filter that gives it only the tools it needs.
1. Get a test key
Create a test key on the API keys page of the console. It starts
ssms_sk_test_, runs everything in the sandbox, and texts no
real phone except your own verified one. Put it in your environment as
TEXTKIT_API_KEY:
export TEXTKIT_API_KEY=ssms_sk_test_...The SDK reads your OpenAI key from OPENAI_API_KEY.
2. Connect the MCP server
pip install openai-agentsimport asyncio
import os
from agents import Agent, Runner
from agents.mcp import MCPServerStreamableHttp, create_static_tool_filter
async def main():
async with MCPServerStreamableHttp(
name="TextKit",
params={
"url": "https://mcp.jointextkit.com",
"headers": {"Authorization": f"Bearer {os.environ['TEXTKIT_API_KEY']}"},
"timeout": 30,
},
cache_tools_list=True,
tool_filter=create_static_tool_filter(
allowed_tool_names=["send_message", "get_message"]
),
) as textkit:
agent = Agent(
name="Notifier",
instructions="You send SMS with TextKit. Confirm the number and wording first.",
mcp_servers=[textkit],
)
result = await Runner.run(agent, 'Text +15005550006 "Your order shipped."')
print(result.final_output)
asyncio.run(main())The SDK runs the MCP calls from your process, so the key never leaves your
server. Drop tool_filter to give the agent every tool, or add names to the
list as the agent's job grows. The server exposes 142 tools: messages, verification, numbers, contacts,
segments, broadcasts, automations and account reads. Each one is a single API
call with your key, so the key's scopes, rate limits and send checks apply
unchanged. The full list is on the MCP server page.
3. Check the sandbox run
+15005550006 is a sandbox number that always ends delivered, so the
agent's tool call returns a message with an id starting msg_ and nothing
reaches a phone. The message also shows in the console's message log, tagged
Test. Ask for a text to your own number instead and, once that number is
verified under Settings, it really arrives (up to 10 a day, ending
"- via TextKit sandbox").
Go live
Swap the test key for a live one (ssms_sk_live_). A live text needs a
number on your account: buy one and
register your use case with the carriers. When the
account has one number, from is optional and the text goes out from it.
To limit what an agent can do with a live key, give it one with only the
scopes it needs.