Use this file to discover all available pages before exploring further.
Give your OpenAI Agents SDK agents intelligent access to 200+ integrations using Pica’s MCP Server. The Model Context Protocol (MCP) integration provides seamless tool access with built-in authentication, error handling, and Pica’s knowledge base.
For complete MCP Server documentation including all tools and configuration options, see the MCP Server guide. This page focuses on OpenAI Agents SDK-specific usage patterns.
from agents import Agent, Runnerfrom agents.extensions.mcp import MCPServerManagerimport os# Initialize MCP manager and add Pica servermcp = MCPServerManager()mcp.add_server( name="pica", command="npx", args=["@picahq/mcp"], env={"PICA_SECRET": os.getenv("PICA_SECRET")})# Create agent with MCP toolsagent = Agent( name="integration-agent", instructions="""You are an AI assistant with access to integrations through Pica. You can list available integrations, search for actions, get detailed action knowledge, and execute actions on behalf of the user.""", mcp_servers=[mcp])# Run the agentresult = Runner.run_sync( agent, "What integrations do I have connected?")print(result.final_output)
The simplest setup - an agent with access to all MCP tools:
Example
from agents import Agent, Runnerfrom agents.extensions.mcp import MCPServerManagerimport os# Setup MCP servermcp = MCPServerManager()mcp.add_server( name="pica", command="npx", args=["@picahq/mcp"], env={"PICA_SECRET": os.getenv("PICA_SECRET")})# Create agentagent = Agent( name="automation-agent", instructions="""You help users automate tasks across their integrated tools. Use Pica's tools to discover available integrations, search for actions, understand action requirements, and execute actions.""", model="gpt-5", mcp_servers=[mcp])# Execute tasksresult = Runner.run_sync( agent, "Send an email via Gmail to team@company.com with the subject 'Weekly Update'")print(result.final_output)
Use multiple specialized agents with handoff capabilities. This example combines a Pica-powered integration agent with a text analysis agent:
Example
from agents import Agent, Runner, Handofffrom agents.extensions.mcp import MCPServerManagerimport os# Setup MCP servermcp = MCPServerManager()mcp.add_server( name="pica", command="npx", args=["@picahq/mcp"], env={"PICA_SECRET": os.getenv("PICA_SECRET")})# Integration specialist (with Pica MCP)integration_agent = Agent( name="integration-agent", instructions="""You specialize in working with third-party integrations. You can list integrations, search for actions, and execute operations through Gmail, Slack, Salesforce, and other platforms.""", model="gpt-5", mcp_servers=[mcp])# Text analysis specialist (no Pica tools)analyst_agent = Agent( name="analyst-agent", instructions="""You specialize in analyzing and summarizing text content. You don't have access to integrations, but you're excellent at understanding patterns, extracting insights, and creating summaries.""", model="gpt-5" # Note: No mcp_servers - this agent doesn't use Pica)# Coordinator agentcoordinator = Agent( name="coordinator", instructions="""You coordinate between integration operations and text analysis. Hand off to: - integration-agent: For fetching data from or sending data to integrations - analyst-agent: For analyzing, summarizing, or processing text content Example workflow: Have integration-agent fetch emails, then have analyst-agent summarize them, then have integration-agent send the summary.""", model="gpt-5", handoffs=[ Handoff(agent=integration_agent, description="Work with integrations"), Handoff(agent=analyst_agent, description="Analyze and summarize text") ])# Run with handoffsresult = Runner.run_sync( coordinator, """Get my last 5 Gmail emails, analyze their sentiment and key topics, then send a summary to team@company.com""")print(result.final_output)
from agents import Agent, Runnerfrom agents.extensions.mcp import MCPServerManagerimport os# Setup MCP servermcp = MCPServerManager()mcp.add_server( name="pica", command="npx", args=["@picahq/mcp"], env={"PICA_SECRET": os.getenv("PICA_SECRET")})# Create agentagent = Agent( name="streaming-agent", instructions="""You help users discover and work with their Pica integrations. Explain what you're doing as you work through the process.""", model="gpt-5", mcp_servers=[mcp])# Stream the responseasync def stream_agent(): async with Runner.run_stream( agent, "What integrations do I have connected in Pica?" ) as stream: async for event in stream: if event.type == "agent_response": print(event.data.content, end="", flush=True) elif event.type == "tool_call": print(f"\n[Using tool: {event.data.name}]") elif event.type == "tool_result": print(f"[Tool completed]")# Run asyncimport asyncioasyncio.run(stream_agent())
Provide clear instructions about when and how to use Pica tools:
instructions = """You are an integration assistant with access to Pica tools.Always follow this workflow:1. Use list_pica_integrations to see available platforms2. Use get_pica_platform_actions to find relevant actions3. Use get_pica_action_knowledge to understand requirements4. Use execute_pica_action to perform the operationAsk for clarification if you're unsure about any parameters."""
Implement guardrails
Always add guardrails for production agents to prevent:
Destructive operations without confirmation
Exposure of sensitive information
Invalid or malicious requests
Use handoffs for complex workflows
Split complex tasks across specialized agents:
Data retrieval agent (read-only)
Action execution agent (write operations)
Coordinator agent (orchestrates handoffs)
Leverage sessions
Use sessions to maintain context across multiple interactions, making your agent feel more natural and contextual.
Enable tracing
Use OpenAI Agents SDK’s built-in tracing to debug and monitor your agent:
from agents import trace# Enable tracingtrace.configure(enabled=True)# Run agent with tracesresult = Runner.run_sync(agent, "task")