# Send SMS from the OpenAI Agents SDK

Source: https://jointextkit.com/integrations/openai-agents-sdk
Index: https://jointextkit.com/llms.txt

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](/console) page of the console. It starts
`ssms_sk_test_`, runs everything in the [sandbox](/docs/sandbox), and texts no
real phone except your own verified one. Put it in your environment as
`TEXTKIT_API_KEY`:

```bash
export TEXTKIT_API_KEY=ssms_sk_test_...
```

The SDK reads your OpenAI key from `OPENAI_API_KEY`.

## 2. Connect the MCP server

```bash
pip install openai-agents
```

```python
import 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](/docs/mcp) 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](/docs/numbers) and
[register your use case](/docs/compliance) 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](/docs/authentication) it needs.

## Sources

- [OpenAI Agents SDK: Model context protocol (MCP)](https://openai.github.io/openai-agents-python/mcp/)
- [OpenAI Agents SDK: Quickstart](https://openai.github.io/openai-agents-python/quickstart/)
