OpenAI
jitprompt is a remote MCP server, so OpenAI models can use it two ways:
- Responses API — OpenAI’s servers call jitprompt’s tools for you; your code makes one request.
- Agents SDK — your process connects to jitprompt and runs the agent loop.
Both need an API key for the namespace (namespace → API keys). Keep it in an environment variable, not in code.
Responses API
Section titled “Responses API”Add jitprompt as an mcp tool. Pass the namespace key in authorization;
OpenAI sends it as the bearer token on each call to jitprompt and does not
store it, so send it with every request.
import osfrom openai import OpenAI
client = OpenAI()
resp = client.responses.create( model="gpt-6-astra", instructions=( "You are a support agent. Your operating instructions are in the jitprompt tools: " "call get_toc first, and search_instructions before each new task. Follow what they return." ), tools=[{ "type": "mcp", "server_label": "jitprompt", "server_description": "The company's operating instructions for this agent.", "server_url": "https://app.jitprompt.com/mcp", "authorization": os.environ["JITPROMPT_KEY"], "allowed_tools": ["get_toc", "search_instructions", "get_section"], "require_approval": "never", }], input="Can I get a refund on my annual plan?",)print(resp.output_text)require_approval: "never"lets the model call the tools without a round trip to you; all three are read-only.allowed_toolslimits the import to jitprompt’s three tools.- The same request with curl:
curl https://api.openai.com/v1/responses \ -H "Content-Type: application/json" -H "Authorization: Bearer $OPENAI_API_KEY" \ -d '{ "model": "gpt-6-astra", "tools": [{ "type": "mcp", "server_label": "jitprompt", "server_url": "https://app.jitprompt.com/mcp", "authorization": "'"$JITPROMPT_KEY"'", "require_approval": "never" }], "input": "Can I get a refund on my annual plan?" }'The Authorization header there is your OpenAI key; the jitprompt key goes
in the tool’s authorization field.
Agents SDK
Section titled “Agents SDK”pip install openai-agentsimport asyncioimport os
from agents import Agent, Runnerfrom agents.mcp import MCPServerStreamableHttp
async def main(): async with MCPServerStreamableHttp( name="jitprompt", params={ "url": "https://app.jitprompt.com/mcp", "headers": {"Authorization": f"Bearer {os.environ['JITPROMPT_KEY']}"}, "timeout": 10, }, cache_tools_list=True, # jitprompt's tool list doesn't change between runs max_retry_attempts=3, ) as jitprompt: agent = Agent( name="Support agent", instructions=( "Your operating instructions are in the jitprompt tools: call get_toc first, and " "search_instructions before each new task. Follow what they return." ), mcp_servers=[jitprompt], ) result = await Runner.run(agent, "Can I get a refund on my annual plan?") print(result.final_output)
asyncio.run(main())tool_filter on MCPServerStreamableHttp can narrow the tools further, for
example to search_instructions only.
See MCP tools for what each tool returns, and Writing prompts for agents for the system-prompt line that makes agents search at the right moments.