Use StitchDB as a remote MCP tool from the OpenAI Responses API and the Agents SDK.
#Responses API
import OpenAI from 'openai'
const openai = new OpenAI()
const response = await openai.responses.create({
model: 'gpt-5',
tools: [{
type: 'mcp',
server_label: 'stitchdb',
server_url: 'https://stitchdb.com/platform/mcp',
headers: { Authorization: 'Bearer ' + process.env.STITCHDB_TOKEN },
require_approval: 'always',
}],
input: 'Which tables in my project have Row Level Security disabled?',
})
console.log(response.output_text)from openai import OpenAI
import os
client = OpenAI()
response = client.responses.create(
model="gpt-5",
tools=[{
"type": "mcp",
"server_label": "stitchdb",
"server_url": "https://stitchdb.com/platform/mcp",
"headers": {"Authorization": "Bearer " + os.environ["STITCHDB_TOKEN"]},
"require_approval": "always",
}],
input="List my StitchDB tables and their row counts.",
)
print(response.output_text)With require_approval: "always" the response contains mcp_approval_request items that you approve in a follow-up request. Use allowed_tools to offer only some tools, for example ["list_tables", "execute_sql"] with a read-only token.
#Agents SDK
Python
from agents import Agent, Runner
from agents.mcp import MCPServerStreamableHttp
async with MCPServerStreamableHttp(
name="stitchdb",
params={"url": "https://stitchdb.com/platform/mcp",
"headers": {"Authorization": "Bearer sdb_pat_..."}},
) as stitchdb:
agent = Agent(name="DB assistant", mcp_servers=[stitchdb])
result = await Runner.run(agent, "Show the schema of my todos table")
print(result.final_output)