import os
import asyncio
import base64
from agents import Agent, Runner
from agents.mcp import MCPServerStreamableHttp, MCPServerStreamableHttpParams
STACKONE_ACCOUNT_ID = "<account_id>"
auth_token = base64.b64encode(
f"{os.getenv('STACKONE_API_KEY')}:".encode()
).decode()
async def main():
stackone_mcp = MCPServerStreamableHttp(
params=MCPServerStreamableHttpParams(
url="https://api.stackone.com/mcp",
headers={
"Authorization": f"Basic {auth_token}",
"x-account-id": STACKONE_ACCOUNT_ID
}
)
)
async with stackone_mcp:
agent = Agent(
name="stackone-assistant",
model="gpt-5",
mcp_servers=[stackone_mcp]
)
# First turn
result = await Runner.run(agent, "List Salesforce accounts")
print(result.final_output)
# Continue conversation — pass previous output as context
result = await Runner.run(
agent,
"Show me the most recent account activities",
context=result.context
)
print(result.final_output)
asyncio.run(main())