Skip to content

Commit 7918c48

Browse files
Danny/mcp hosted servers (#16743)
* Adding info for remote servers * Update pnpm-lock.yaml * Updates
1 parent 005a4c3 commit 7918c48

File tree

3 files changed

+199
-85
lines changed

3 files changed

+199
-85
lines changed
Lines changed: 185 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,190 @@
1-
import { Steps } from 'nextra/components'
1+
import { Callout, Steps, Tabs } from 'nextra/components'
22

3-
# Deploy Pipedream MCP to your agent
4-
Deploy Pipedream's MCP servers to your application or agent and make authenticated request on behalf of your customers. Refer to our reference implementation [here](https://github.com/PipedreamHQ/pipedream/blob/master/modelcontextprotocol/README.md).
3+
# Add Pipedream MCP to your app or agent
54

6-
## Quickstart
5+
Add Pipedream's MCP server to your application or agent to make tool calls on behalf of your users to {process.env.PUBLIC_APPS}+ APIs and 10,000+ tools.
76

8-
<Steps>
7+
## Overview
98

10-
#### Prerequisites
9+
Pipedream's MCP server code is [publicly available on GitHub](https://github.com/PipedreamHQ/pipedream/blob/master/modelcontextprotocol/README.md), and you have two options for using Pipedream's MCP server in your app:
1110

12-
To run your own MCP server, you'll need:
11+
1. [Use Pipedream's remote MCP server](#use-pipedreams-remote-mcp-server)
12+
2. [Self-host Pipedream's MCP server](#self-host-pipedreams-mcp-server)
13+
14+
### Pipedream concepts to understand
15+
16+
The MCP server accepts two route params:
17+
18+
**`external_user_id`**
19+
20+
- This is your user’s ID, in your system: whatever you use to uniquely identify them
21+
- Any requests made to that route are coupled to that end user and uses the connected account tied to that user
22+
- [See here](/connect/api/#external-users) for more detail
23+
24+
**`app`**
25+
26+
- The app's "name slug" (the unique identifier for the app)
27+
- [See below](#discover-available-mcp-servers) for discovering available apps
28+
29+
## Getting started
30+
31+
### Prerequisites
32+
33+
For either option, you'll need:
1334

1435
1. A [Pipedream account](https://pipedream.com/auth/signup)
1536
2. A [Pipedream project](/projects/#creating-projects). Accounts connected via MCP will be stored here.
1637
3. [Pipedream OAuth credentials](/rest-api/auth/#oauth)
1738

18-
#### Set up environment variables
39+
#### Set up your environment
1940

2041
Set the following environment variables:
2142

2243
```bash
2344
PIPEDREAM_CLIENT_ID=your_client_id
2445
PIPEDREAM_CLIENT_SECRET=your_client_secret
25-
PIPEDREAM_PROJECT_ID=your_project_id
26-
PIPEDREAM_ENVIRONMENT=development
46+
PIPEDREAM_PROJECT_ID=your_project_id # proj_xxxxxxx
47+
PIPEDREAM_ENVIRONMENT=development # development | production
48+
```
49+
50+
### Authentication
51+
52+
#### Developer authentication
53+
54+
Your application authenticates with Pipedream using client credential OAuth. [See below](#api-authentication) for details.
55+
56+
#### User account connections
57+
58+
One of the core features of Pipedream Connect and our MCP product is the ability for your users to easily connect their accounts without having to build any of the authorization flow or handle token storage.
59+
60+
You can handle account connections in one of two ways in your app:
61+
62+
##### Add a button in your UI
63+
- Use Pipedream's [frontend SDK](/connect/managed-auth/quickstart/#use-the-pipedream-sdk-in-your-frontend) to let users connect their account directly in your UI
64+
- You can see an example of this when you connect any account in [mcp.pipedream.com](https://mcp.pipedream.com)
65+
66+
##### Return a link
67+
- Use [Connect Link ](/connect/managed-auth/quickstart/#or-use-connect-link) to let your users open a Pipedream hosted page to connect their account
68+
- There is no implementation required for this option since it's already handled in Pipedream's MCP server
69+
- If a user doesn't have a connected account that's required for a given tool call, we'll return a URL in the tool call response. For example:
70+
71+
```
72+
https://pipedream.com/_static/connect.html?token=ctok_xxxxxxx&connectLink=true&app={appSlug}
73+
```
74+
75+
### Discover available MCP servers
76+
77+
Pipedream provides [{process.env.PUBLIC_APPS}+ APIs as MCP servers](https://mcp.pipedream.com). Each server corresponds to an app integration (like Notion, Gmail, or Slack) and has its own specific set of tools that you can expose to OpenAI.
78+
79+
<Tabs items={['List all apps', 'Search for a specific app']}>
80+
<Tabs.Tab>
81+
```javascript
82+
// Get all available apps (paginated)
83+
const apps = await pd.getApps();
84+
85+
// Each app has these key properties:
86+
// - name_slug: Used in the MCP server URL (e.g., "notion", "gmail", "slack")
87+
// - name: Display name (e.g., "Notion", "Gmail", "Slack")
88+
```
89+
</Tabs.Tab>
90+
<Tabs.Tab>
91+
```javascript
92+
// Search by app name
93+
const notionApps = await pd.getApps({ q: "notion" });
94+
const gmailApps = await pd.getApps({ q: "gmail" });
95+
const slackApps = await pd.getApps({ q: "slack" });
2796
```
97+
</Tabs.Tab>
98+
</Tabs>
99+
100+
### Use Pipedream's remote MCP server
101+
102+
<Callout type="info">
103+
Pipedream MCP server supports both SSE and streamable HTTP transport types, with no configuration required by the developer or MCP client.
104+
</Callout>
105+
106+
#### Base URL
107+
108+
```
109+
https://mcp.pipedream.net
110+
```
111+
112+
#### API Authentication
113+
114+
To authenticate requests to Pipedream's MCP server, you need to include an access token with every HTTP request. Here's how to get it:
28115

29-
#### Run the MCP server
116+
<Tabs items={['Node.js', 'cURL']}>
117+
<Tabs.Tab>
118+
```javascript
119+
import { createBackendClient } from "@pipedream/sdk/server";
30120

31-
Pipedream's MCP servers can run in two modes:
121+
// Initialize the Pipedream client with the SDK
122+
const pd = createBackendClient({
123+
environment: PIPEDREAM_ENVIRONMENT,
124+
credentials: {
125+
clientId: PIPEDREAM_CLIENT_ID,
126+
clientSecret: PIPEDREAM_CLIENT_SECRET,
127+
},
128+
projectId: PIPEDREAM_PROJECT_ID
129+
});
32130

33-
##### Stdio (for local testing)
131+
// Get access token for MCP server auth
132+
const accessToken = await pd.rawAccessToken();
34133

134+
console.log(accessToken);
135+
```
136+
</Tabs.Tab>
137+
<Tabs.Tab>
35138
```bash
36-
npx @pipedream/mcp stdio --app slack --external-user-id user123
139+
curl -s -X POST https://api.pipedream.com/v1/oauth/token \
140+
-H "Content-Type: application/json" \
141+
-d '{
142+
"grant_type": "client_credentials",
143+
"client_id": "'$PIPEDREAM_CLIENT_ID'",
144+
"client_secret": "'$PIPEDREAM_CLIENT_SECRET'"
145+
}'
146+
```
147+
</Tabs.Tab>
148+
</Tabs>
149+
150+
#### Required headers
151+
152+
Include these headers in every HTTP request:
153+
154+
```javascript
155+
{
156+
Authorization: `Bearer ${PIPEDREAM_ACCESS_TOKEN}`,
157+
"x-pd-project-id": PIPEDREAM_PROJECT_ID, // proj_xxxxxxx
158+
"x-pd-environment": PIPEDREAM_ENVIRONMENT // development | production
159+
}
37160
```
38161

39-
##### SSE (for hosting)
162+
### Self-host Pipedream's MCP server
163+
164+
#### Using the `Dockerfile`
165+
166+
If you have Docker installed locally, you can build and run the container from the [reference implementation](https://github.com/PipedreamHQ/pipedream/blob/master/modelcontextprotocol/Dockerfile):
167+
168+
```console
169+
> docker build -t pipedream-connect .
170+
> docker run -d --name pd-mcp -p 3010:3010 --env-file .env pipedream-connect:latest
171+
```
172+
173+
This exposes a generic MCP server at [http://localhost:3010/:external_user_id/:app](http://localhost:3010/:external_user_id/:app).
174+
175+
#### Start the server with Streamable HTTP Transport
176+
177+
```bash
178+
pnpm dev:http
179+
```
180+
181+
You can use the optional env var `PD_SDK_DEBUG` to print out all the requests and responses going to the Connect API:
182+
183+
```bash
184+
PD_SDK_DEBUG=true pnpm dev:http
185+
```
186+
187+
#### Start the server with SSE
40188

41189
```bash
42190
npx @pipedream/mcp sse
@@ -46,13 +194,9 @@ This exposes routes at:
46194
- `GET /:external_user_id/:app` - App-specific SSE connection endpoint
47195
- `POST /:external_user_id/:app/messages` - App-specific message handler
48196

49-
Where:
50-
- `:external_user_id` is your user's unique identifier in your system
51-
- `:app` is the app slug (e.g., "slack", "github")
52-
53197
#### Customize for your needs
54198

55-
You can host and customize the MCP server for your specific requirements:
199+
You can also host and customize the MCP server for your specific requirements:
56200

57201
```bash
58202
# Clone the repo
@@ -71,4 +215,24 @@ npm run start:sse:prod
71215

72216
See the [MCP server README](https://github.com/PipedreamHQ/pipedream/blob/master/modelcontextprotocol/README.md) for detailed instructions on customization options.
73217

74-
</Steps>
218+
### Use the MCP inspector
219+
220+
The [MCP inspector](https://modelcontextprotocol.io/docs/tools/inspector) can be helpful when debugging tool calls.
221+
222+
```bash
223+
npx @modelcontextprotocol/inspector
224+
```
225+
226+
Enter the server URL:
227+
228+
If using Pipedream's remote server:
229+
230+
```
231+
https://mcp.pipedream.net/{external_user_id}/{app_slug}
232+
```
233+
234+
If running locally:
235+
236+
```
237+
http://localhost:3010/{external_user_id}/{app_slug}
238+
```

docs-v2/pages/connect/mcp/openai.mdx

Lines changed: 6 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import { Callout, Tabs, Steps } from 'nextra/components'
55
Access {process.env.PUBLIC_APPS}+ 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](https://platform.openai.com/docs/guides/tools?api-mode=responses) .
66

77
<Callout type="info">
8-
Pipedream Connect includes built-in user authentication for [every MCP server](https://mcp.pipedream.com), 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 below](#account-connection).
8+
Pipedream Connect includes built-in user authentication for [every MCP server](https://mcp.pipedream.com), 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](/connect/mcp/developers/#user-account-connections).
99
</Callout>
1010

11-
### Getting started
11+
## Getting started
1212

1313
<Steps>
1414

@@ -30,34 +30,13 @@ Now set the following environment variables (learn more about environments in Pi
3030
OPENAI_API_KEY=your_openai_api_key
3131
PIPEDREAM_CLIENT_ID=your_client_id
3232
PIPEDREAM_CLIENT_SECRET=your_client_secret
33-
PIPEDREAM_PROJECT_ID=your_project_id
34-
PIPEDREAM_ENVIRONMENT=development
33+
PIPEDREAM_PROJECT_ID=your_project_id # proj_xxxxxxx
34+
PIPEDREAM_ENVIRONMENT=development # development | production
3535
```
3636

3737
### Discover available MCP servers
3838

39-
Pipedream provides [{process.env.PUBLIC_APPS}+ APIs as MCP servers](https://mcp.pipedream.com) that can be used with OpenAI's tool calls. Each server corresponds to an app integration (like Notion, Gmail, or Slack) and has its own specific set of tools that you can expose to OpenAI.
40-
41-
<Tabs items={['List all apps', 'Search for a specific app']}>
42-
<Tabs.Tab>
43-
```javascript
44-
// Get all available apps (paginated)
45-
const apps = await pd.getApps();
46-
47-
// Each app has these key properties:
48-
// - name_slug: Used in the MCP server URL (e.g., "notion", "gmail", "slack")
49-
// - name: Display name (e.g., "Notion", "Gmail", "Slack")
50-
```
51-
</Tabs.Tab>
52-
<Tabs.Tab>
53-
```javascript
54-
// Search by app name
55-
const notionApps = await pd.getApps({ q: "notion" });
56-
const gmailApps = await pd.getApps({ q: "gmail" });
57-
const slackApps = await pd.getApps({ q: "slack" });
58-
```
59-
</Tabs.Tab>
60-
</Tabs>
39+
[See here](/connect/mcp/developers/#discover-available-mcp-servers) for guidance on discovering the apps Pipedream has available as MCP servers.
6140

6241
### Generate a model response in OpenAI with Pipedream MCP
6342

@@ -120,8 +99,6 @@ console.log(response);
12099
</Tabs.Tab>
121100
<Tabs.Tab>
122101
```bash
123-
# Complete example from start to finish
124-
125102
# Step 1: Get access token from Pipedream
126103
ACCESS_TOKEN=$(curl -s -X POST https://api.pipedream.com/v1/oauth/token \
127104
-H "Content-Type: application/json" \
@@ -164,24 +141,5 @@ curl -X POST https://api.openai.com/v1/chat/completions \
164141
}'
165142
```
166143
</Tabs.Tab>
167-
</Tabs>
144+
</Tabs>
168145
</Steps>
169-
170-
## Account Connection
171-
172-
One of the core features of Pipedream Connect and our MCP product is the ability for your users to easily connect their accounts without having to build any of the authorization flow or handle token storage.
173-
174-
You can handle account connections in one of two ways in your app:
175-
176-
### Add a button in your UI
177-
- Use Pipedream's [frontend SDK](/connect/managed-auth/quickstart/#use-the-pipedream-sdk-in-your-frontend) to let users connect their account directly in your UI
178-
- You can see an example of this when you connect any account in [mcp.pipedream.com](https://mcp.pipedream.com)
179-
180-
### Return a link
181-
- Use [Connect Link ](/connect/managed-auth/quickstart/#or-use-connect-link) to let your users open a Pipedream hosted page to connect their account
182-
- There is no implementation required for this option since it's already handled in Pipedream's MCP server
183-
- If a user doesn't have a connected account that's required for a given tool call, we'll return a URL in the tool call response. For example:
184-
185-
```
186-
https://pipedream.com/_static/connect.html?token=ctok_xxxxxxx&connectLink=true&app=notion
187-
```

0 commit comments

Comments
 (0)