Providers
OpenAI
OpenAI
Configure an OpenAI Playground tool to use Rapid MCP
Steps
- Open the OpenAI Playground → Prompts
- Create a new MCP tool
- Enter the URL and headers
Configuration JSON
{
"mcpServers": {
"RapidMCP": {
"url": "https://rapid-mcp.com/mcp/<serverId>/stream",
"headers": {
"Authorization": "Bearer XXXXX"
}
}
}
}Using Rapid MCP with the OpenAI Agents SDK (hostedMcpTool)
You can also connect Rapid MCP to the OpenAI Agents SDK using the hostedMcpTool helper.
When you pass headers or a JSON body here, each key becomes available for templating inside your Rapid MCP tools.
For example:
- Header
x-tenant-id→{{x-tenant-id}}in a tool template - Body key
subdomain→{{subdomain}}in a tool template
import { assistant, hostedMcpTool } from "@openai/agents";
const rapidMcpTool = hostedMcpTool({
serverLabel: "RapidMCP",
serverUrl: "https://rapid-mcp.com/mcp/<serverId>/stream",
headers: {
// Becomes available as {{authorization}} or {{x-tenant-id}} in Rapid MCP templates
Authorization: `Bearer ${process.env.RAPID_MCP_API_KEY!}`,
"x-tenant-id": "acme-corp",
},
body: {
// Becomes available as {{subdomain}} and {{environment}} in Rapid MCP templates
subdomain: "acme", // e.g. used in a tool as https://{{subdomain}}.example.com
environment: "staging", // e.g. used as a query param or header
},
});
const agent = assistant({
model: "gpt-4.1-mini",
tools: {
rapidMcp: rapidMcpTool,
},
});
const result = await agent.run(
"Use the RapidMCP tools to fetch staging data for the 'acme' tenant.",
);
console.log(result.output_text);Using toolMetaResolver with MCPServerStreamableHttp
If you need to pass dynamic metadata to every tool call (for example tenant or org context), use toolMetaResolver.
import { Agent, MCPServerStreamableHttp, Runner } from "@openai/agents";
import type { MCPToolMetaContext } from "@openai/agents";
const mcpHeaders = { Authorization: `Bearer TOKEN_GOES_HERE` };
const mcpUrl = "https://rapid-mcp.com/mcp/<serverId>/stream";
const mcpServer = new MCPServerStreamableHttp({
url: mcpUrl,
name: "Rapid MCP Server",
requestInit: Object.keys(mcpHeaders).length ? { headers: mcpHeaders } : undefined,
toolMetaResolver: (ctx: MCPToolMetaContext) => {
const contextData = ctx.runContext.context as { orgId?: string } | undefined;
return {
orgId: contextData?.orgId,
data: "yes",
};
},
});
await mcpServer.connect();
const agent = new Agent({
name: "Rapid MCP Agent",
mcpServers: [mcpServer],
});
const runner = new Runner();
const result = await runner.run(agent, "Run a tool call", {
context: { orgId: "org_123" },
});
console.log(result.finalOutput);In this pattern, anything returned from toolMetaResolver is attached to tool calls as _meta.
That lets you keep request-specific metadata in one place and reuse it across all Rapid MCP tools.