Using Pipedream MCP with OpenAI
Access 2,500+ APIs and 10,000+ tools in OpenAI using Pipedream Connect. MCP makes it easy to extend the capabilities of any LLM or agent, and Pipedream offers drop-in support for calling tools in OpenAI.
Pipedream Connect includes built-in user authentication for every MCP server, which means you don’t need to build any authorization flows or deal with token storage and refresh in order to make authenticated requests on behalf of your users. Learn more here.
Getting started
Set up your environment
To use Pipedream MCP with your own users, you need the following:
- A Pipedream account
- A Pipedream project (accounts connected via MCP will be stored here)
- Pipedream OAuth credentials
These are requirements for you, the developer. Your users do not need to sign up for Pipedream in order to connect their accounts in your app or agent.
Now set the following environment variables (learn more about environments in Pipedream Connect here):
OPENAI_API_KEY=your_openai_api_key
PIPEDREAM_CLIENT_ID=your_client_id
PIPEDREAM_CLIENT_SECRET=your_client_secret
PIPEDREAM_PROJECT_ID=your_project_id # proj_xxxxxxx
PIPEDREAM_ENVIRONMENT=development # development | production
Discover available MCP servers
See here for guidance on discovering the apps Pipedream has available as MCP servers.
Generate a model response in OpenAI with Pipedream MCP
Below is an end to end example showing how to:
- Initialize the Pipedream SDK
- Find the relevant MCP server
- Send a prompt to OpenAI with the MCP server as a tool call
import OpenAI from 'openai';
import { createBackendClient } from "@pipedream/sdk/server";
// Initialize the Pipedream SDK client
const pd = createBackendClient({
environment: PIPEDREAM_ENVIRONMENT,
credentials: {
clientId: PIPEDREAM_CLIENT_ID,
clientSecret: PIPEDREAM_CLIENT_SECRET,
},
projectId: PIPEDREAM_PROJECT_ID
});
// Find the app to use for the MCP server
// For this example, we'll use Notion
const apps = await pd.getApps({ q: "notion" });
const appSlug = apps.data[0].name_slug; // e.g., "notion"
// Get access token for MCP server auth
const accessToken = await pd.rawAccessToken();
// Send the unique ID that you use to identify this user in your system
const externalUserId = 'abc-123'; // Used in MCP URL to identify the user
// Initialize OpenAI client
const client = new OpenAI();
// Make the OpenAI request with the MCP server
const response = await client.responses.create({
model: 'gpt-4.1',
tools: [
{
type: 'mcp',
server_label: 'Notion',
server_url: `https://remote.mcp.pipedream.net/${externalUserId}/${appSlug}`,
headers: {
Authorization: `Bearer ${accessToken}`,
"x-pd-project-id": PIPEDREAM_PROJECT_ID,
"x-pd-environment": PIPEDREAM_ENVIRONMENT
},
require_approval: 'never'
}
],
input: 'Summarize my most recently created Notion doc for me and help draft an email to our customers'
});
console.log(response);