### Initialize a New Connect Project Source: https://pipedream.com/docs/cli/reference Use `pd init connect` to start a new Pipedream Connect project. This command guides you through project setup, OAuth client creation, and selecting a demo app. ```bash pd init connect ``` -------------------------------- ### SQL Prop Configuration Example Source: https://pipedream.com/docs/connect/components/actions Example of configuring the `sql` prop for database actions, including authentication details and the SQL query to execute. This setup is used for actions like `postgresql-execute-custom-query`. ```javascript const configuredProps = { postgresql: { authProvisionId: "apn_xxxxxxx" }, sql: { auth: { app: "postgresql" // Database type -- must match the app prop name }, query: "select * from products limit 1", params: [] // Optional array of parameters for prepared statements } } ``` -------------------------------- ### Install and Import Multiple Packages with Magic Comments Source: https://pipedream.com/docs/workflows/building-workflows/code/python/import-mappings When using multiple packages that require `add-package` comments, ensure all comments are placed at the beginning of the code block. This example shows installing `google-auth` and `google-cloud-compute`. ```python # pipedream add-package google-auth # pipedream add-package google-cloud-compute from google.oauth2 import service_account from google.cloud import compute_v1 ``` -------------------------------- ### Search Response Example Source: https://pipedream.com/docs/rest-api/api-reference/components/search-for-registry-components This is an example of a successful response when searching for components. It lists the matching component sources and actions. ```json { "sources": [ "hubspot-new-contact" ], "actions": [ "twilio-send-sms" ] } ``` -------------------------------- ### Create Token Example (HTTP) Source: https://pipedream.com/docs/connect/api-reference Example of creating a token using the Pipedream Connect API with environment specified via header. ```APIDOC ## Environment Most API endpoints require an environment parameter. This lets you specify the environment (`production` or `development`) where resources will live in your project. Always set the environment when you create the SDK client: ```bash curl -X POST https://api.pipedream.com/v1/connect/{project_id}/tokens \ -H "Content-Type: application/json" \ -H "X-PD-Environment: development" \ -H "Authorization: Bearer {access_token}" \ -d '{ "external_user_id": "your-external-user-id" }' ``` ``` -------------------------------- ### Install Pipedream CLI using install script with sudo Source: https://pipedream.com/docs/llms-full.txt If the standard install script returns a permissions error, try running it with sudo. ```bash curl https://cli.pipedream.com/install | sudo sh ``` -------------------------------- ### List Components (Python SDK) Source: https://pipedream.com/docs/connect/api-reference/list-components This example demonstrates how to list components using the Pipedream Python SDK. You can filter components by various parameters like `after`, `before`, `limit`, `q`, `app`, `registry`, and `component_type`. The response can be iterated over to get individual items or paginated pages. ```APIDOC ## List Components ### Description Retrieves a list of components available in the Pipedream registry. Supports filtering by various parameters and pagination. ### Method GET ### Endpoint `/v1/components` ### Parameters #### Query Parameters - **after** (string) - Optional - Used to paginate results, fetching components after a specific cursor. - **before** (string) - Optional - Used to paginate results, fetching components before a specific cursor. - **limit** (integer) - Optional - The maximum number of components to return per page. - **q** (string) - Optional - A query string to filter components by name or description. - **app** (string) - Optional - Filters components associated with a specific app. - **registry** (string) - Optional - Specifies the component registry to query (e.g., "public"). - **component_type** (string) - Optional - Filters components by type (e.g., "trigger", "action"). ### Response #### Success Response (200) - **data** (array) - An array of component objects. - **page_info** (object) - Information about the pagination state. ### Response Example ```json { "data": [ { "key": "example_component_key", "name": "Example Component Name", "version": "1.0.0", "configurable_props": [], "description": "A brief description of the component.", "component_type": "trigger", "stash": {}, "annotations": {} } ], "page_info": { "count": 10, "total_count": 120, "end_cursor": "next_cursor_string", "start_cursor": "previous_cursor_string" } } ``` ``` -------------------------------- ### Basic Event Emission Example Source: https://pipedream.com/docs/llms-full.txt A simple example demonstrating how to emit a basic event with a message on each component execution. ```javascript export default { name: "this.$emit() example", description: "Deploy and run this component manually via the Pipedream UI", async run() { this.$emit({ message: "hello world!" }); }, }; ``` -------------------------------- ### Install JavaScript Dependencies Source: https://pipedream.com/docs/connect/mcp/ai-frameworks/gemini Install the necessary Node.js packages for using Gemini with Pipedream MCP. ```bash npm install @google/generativeai @modelcontextprotocol/sdk @pipedream/sdk ``` -------------------------------- ### Install Anthropic and Pipedream SDKs Source: https://pipedream.com/docs/connect/mcp/ai-frameworks/anthropic Install the necessary SDKs for Anthropic and Pipedream. Use npm for TypeScript/JavaScript and pip for Python. ```bash npm install @anthropic-ai/sdk @pipedream/sdk ``` ```bash pip install anthropic pipedream ``` -------------------------------- ### Install Project Dependencies with pnpm Source: https://pipedream.com/docs/components/contributing/guidelines Installs all project dependencies using pnpm. This command is typically run once. ```bash pnpm install ``` -------------------------------- ### Example SSE Event Stream URL Source: https://pipedream.com/docs/llms-full.txt An example of a fully constructed SSE event stream URL using a sample workflow ID. ```text http://sdk.m.pipedream.net/pipelines/p_aBcDeF/sse ``` -------------------------------- ### Start Demo App Development Server Source: https://pipedream.com/docs/llms-full.txt Navigate to your project directory and start the development server for your chosen demo app. Open http://localhost:3000 to view the running application. ```bash cd your-project-name npm run dev ``` -------------------------------- ### Install Required Dependencies with pnpm Source: https://pipedream.com/docs/components/contributing/guidelines Installs all required dependencies for the project, often used for development setups. ```bash npx pnpm install -r ``` -------------------------------- ### Deploy and Run Hello World Source Source: https://pipedream.com/docs/components/contributing/sources-quickstart Deploy the 'Hello World!' component using the `pd dev` command and observe the output in the CLI. ```bash pd dev source.js ``` -------------------------------- ### Install Pipedream CLI using install script on macOS Source: https://pipedream.com/docs/cli/install Download and execute the install script to get the latest `pd` CLI on your Mac. This is the recommended method for macOS. ```bash curl https://cli.pipedream.com/install | sh ``` -------------------------------- ### Run Demo App Locally Source: https://pipedream.com/docs/connect/quickstart Navigate to your project directory and start the demo application using npm. ```bash cd your-project-name npm run dev ``` -------------------------------- ### Log 'Hello World!' in Go Source: https://pipedream.com/docs/workflows/building-workflows/code/go Use `fmt.Println` to log output in Go. Ensure the `fmt` package is imported. Logs appear in the Results section. ```go package main import "fmt" func main() { fmt.Println("Hello World!") } ``` -------------------------------- ### Example Event Source ID URL Source: https://pipedream.com/docs/troubleshooting This is an example URL format for an event source. The source ID is the value starting with 'dc_'. ```text https://pipedream.com/sources/dc_abc123 ``` -------------------------------- ### Example Workflow ID Extraction Source: https://pipedream.com/docs/llms-full.txt This example demonstrates how to identify a workflow ID from a Pipedream workflow URL. The ID typically starts with 'p_'. ```text https://pipedream.com/@yourworkspace/projects/proj_abc123/test-workflow-p_abc123/inspect Your workflow’s ID is the value that starts with `p_`. In this example: `p_abc123`. ``` -------------------------------- ### Get Workflow Response Example Source: https://pipedream.com/docs/rest-api/examples/workflows This JSON shows the structure of a Get Workflow API response, detailing triggers and steps, including their configurable properties. ```json { "triggers": [ { "id": "dc_abc123", "configurable_props": [ { "name": "url", "type": "string" } ], "configured_props": {}, "active": true, "created_at": 1707170044, "updated_at": 1707170044, "name": "New Item in Feed", "name_slug": "new-item-in-feed" } ], "steps": [ { "namespace": "send_message", "lang": "nodejs20.x", "component": true, "savedComponent": { "id": "sc_abc123", "configurableProps": [ { "name": "slack", "type": "app", "app": "slack" }, { "name": "channelId", "type": "string" }, { "name": "message", "type": "string" } ] } } ] } ``` -------------------------------- ### Example Component List Source: https://pipedream.com/docs/connect/components This snippet shows a list of available components, each with a name, version, and key. This is typically found when exploring or defining component sets. ```json { "components": [ { "name": "Update Epic", "version": "0.0.1", "key": "gitlab_developer_app-update-epic" }, { "name": "Search Issues", "version": "0.0.1", "key": "gitlab_developer_app-search-issues" }, { "name": "List Repo Branches", "version": "0.0.1", "key": "gitlab_developer_app-list-repo-branches" }, { "name": "Get Repo Branch", "version": "0.0.1", "key": "gitlab_developer_app-get-repo-branch" }, { "name": "Get Issue", "version": "0.0.1", "key": "gitlab_developer_app-get-issue" }, { "name": "Create issue", "version": "0.0.1", "key": "gitlab_developer_app-create-issue" }, { "name": "Create Epic", "version": "0.0.1", "key": "gitlab_developer_app-create-epic" }, { "name": "Create Branch", "version": "0.0.1", "key": "gitlab_developer_app-create-branch" } ] } ``` -------------------------------- ### Async Options Example Source: https://pipedream.com/docs/llms-full.txt Illustrates how to use async options for user selections, supporting label/value definitions and pagination. This is useful when dealing with external services that use IDs but should display user-friendly labels. ```javascript async options(event) { return { label: "My Project", value: 12345 } } ``` -------------------------------- ### Send a GET HTTP Request in Component Action Source: https://pipedream.com/docs/llms-full.txt Example of using $.send.http to send a GET request from a component action. It functions identically to its use in workflow code steps. ```javascript export default defineComponent({ async run({ steps, $ }) { $.send.http({ method: "GET", url: "https://example.com" }) } }); ``` -------------------------------- ### Async Options Example Implementation Source: https://pipedream.com/docs/components/api An example of implementing async options to provide a list of strings as selectable options for a prop. This is useful for dynamic dropdowns or selections. ```javascript export default { name: "Async Options Example", version: "0.1", props: { msg: { type: "string", label: "Message", description: "Select a message to `console.log()`", async options() { // write any node code that returns a string[] or object[] (with label/value keys) return ["This is option 1", "This is option 2"]; }, }, }, async run() { this.$emit(this.msg); }, }; ``` -------------------------------- ### Send GET Request with Query Parameters using Axios Source: https://pipedream.com/docs/workflows/building-workflows/code/nodejs/http-requests Use this snippet to send a GET request with query string parameters to fetch specific data using axios. Ensure axios is installed. ```javascript import axios from "axios"; export default defineComponent({ async run({ steps, $ }) { // Make an HTTP GET request using axios const resp = await axios({ method: "GET", url: `https://jsonplaceholder.typicode.com/comments`, params: { postId: 1, }, }); // Retrieve just the data from the response const { data } = resp; } }); ``` -------------------------------- ### Install and Import Google Cloud BigQuery Source: https://pipedream.com/docs/workflows/building-workflows/code/python/import-mappings Use the `add-package` comment to install `google-cloud-bigquery` and then import `bigquery` from `google.cloud`. This is useful when the PyPI name differs from the import name. ```python # pipedream add-package google-cloud-bigquery from google.cloud import bigquery ``` -------------------------------- ### Making a GET Request in Go Source: https://pipedream.com/docs/workflows/building-workflows/code/go Demonstrates how to perform a GET request to retrieve data from a specified URL. Includes reading and logging the response status and body. ```go package main import ( "net/http" // HTTP client "io/ioutil" // Reads the body of the response "log" // Logger ) func main() { resp, err := http.Get("https://swapi.dev/api/people/1") if err != nil { log.Fatalln(err) } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { log.Fatalln(err) } // The response status code is logged in your Pipedream step results: log.Println(resp.Status) // The response is logged in your Pipedream step results: sb := string(body) log.Println(sb) } ``` -------------------------------- ### Send GET Request to Star Wars API Source: https://pipedream.com/docs/llms-full.txt Example of making a GET request to the Star Wars API using axios and extracting data. Also shows an equivalent using Pipedream's http-request component. ```javascript import axios from "axios"; export default defineComponent({ async run({ steps, $ }) { // Make an HTTP GET request using axios const res = await axios({ method: "GET", url: `https://swapi.dev/api/films/`, }); // Retrieve just the data from the response const { data } = res; } }); ``` ```javascript export default defineComponent({ props: { httpRequest: { type: "http_request", label: "Star Wars API request", default: { method: "GET", url: "https://swapi.dev/api/films/" } }, }, async run({ steps, $ }) { // Make an HTTP GET request using the http-request const res = await this.httpRequest.execute(); // Retrieve just the data from the response const { data } = res; }, }) ``` -------------------------------- ### Get Workspace Response Example Source: https://pipedream.com/docs/rest-api/api-reference/workspaces/get-a-workspace This JSON object shows the structure of the response when fetching workspace details, including credit usage. ```json { "data": { "id": "o_Qa8I1Z", "orgname": "asdf", "name": "asdf", "email": "dev@pipedream.com", "daily_credits_quota": 100, "daily_credits_used": 0 } } ``` -------------------------------- ### Making a Simple HTTP GET Request with @pipedream/platform axios Source: https://pipedream.com/docs/workflows/building-workflows/http This example demonstrates how to make a basic HTTP GET request to `https://httpstat.us/200` using the `@pipedream/platform` axios client within a Pipedream component action. The `$` object is passed as the first argument to `axios`. ```javascript import { axios } from "@pipedream/platform" export default { key: "my-test-component", name: "My Test component", version: "0.0.1", type: "action", async run({ $ }) { return await axios($, { url: "https://httpstat.us/200", }) } } ``` -------------------------------- ### List Connected Accounts by Type Source: https://pipedream.com/docs/llms-full.txt Example GET request to list connected accounts, filtered by 'slack' to find Slack accounts within a workspace. ```http GET /workflows/workspaces//accounts?query=slack ``` -------------------------------- ### List Components with Python SDK Source: https://pipedream.com/docs/connect/api-reference/list-components Use the Pipedream Python SDK to list components. This example shows how to initialize the client and iterate through component results. ```python from pipedream import PipedreamClient client = PipedreamClient(client_secret="YOUR_CLIENT_SECRET") response = client.components.list( after="after", before="before", limit=1, q="q", app="app", registry="public", component_type="trigger", ) for item in response: yield item # alternatively, you can paginate page-by-page for page in response.iter_pages(): yield page ``` -------------------------------- ### Find Pipedream Apps via REST API Source: https://pipedream.com/docs/llms-full.txt Find Pipedream apps by making a GET request to the /connect/apps endpoint with a query parameter. This example searches for 'gitlab'. ```sh curl 'https://api.pipedream.com/v1/connect/apps?q=gitlab' \ -H "Content-Type: application/json" \ -H "Authorization: Bearer {access_token}" # Parse and return the data you need ``` -------------------------------- ### Initialize Pipedream Client with Environment Source: https://pipedream.com/docs/llms-full.txt Demonstrates how to initialize the Pipedream client with a specific project environment (development or production) using the SDK. ```javascript import { PipedreamClient } from "@pipedream/sdk"; const client = new PipedreamClient({ clientId: "your-oauth-client-id", clientSecret: "your-oauth-client-secret", projectId: "your-project-id", projectEnvironment: "development" // change to "production" for production environment }); ``` -------------------------------- ### HTTP Request Prop Example Source: https://pipedream.com/docs/components/contributing/api Demonstrates how to configure and execute an HTTP request using the http_request prop. The request method and URL are set as defaults. ```javascript export default { name: "HTTP Request Example", version: "0.0.1", props: { httpRequest: { type: "http_request", label: "API Request", default: { method: "GET", url: "https://jsonplaceholder.typicode.com/posts", } }, }, async run() { const { data } = await this.httpRequest.execute(); return data; }, }; ``` -------------------------------- ### cURL Request to Get Workflow Errors Source: https://pipedream.com/docs/rest-api/api-reference/workflows/get-workflows-errors Example cURL command to fetch error event summaries for a workflow, including expanded event data and a limit of 1. ```bash curl 'https://api.pipedream.com/v1/workflows/p_abc123/$errors/event_summaries?expand=event&limit=1' \ -H 'Authorization: Bearer ' ``` -------------------------------- ### Deploy Source via UI from Any URL Source: https://pipedream.com/docs/components/api Deploy a source from any URL using a specific URL pattern in the UI. The URL must be URL-encoded. ```bash https://pipedream.com/sources?action=create&url= ``` ```bash https://pipedream.com/sources?action=create&url=https%3A%2F%2Fraw.githubusercontent.com%2FPipedreamHQ%2Fpipedream%2Fmaster%2Fcomponents%2Fhttp%2Fhttp.js ``` -------------------------------- ### Full Source with Unique Deduplication Source: https://pipedream.com/docs/components/contributing/sources-quickstart This source code example integrates the 'unique' deduplication strategy, emitting only new RSS feed items by using their GUID as the event ID. ```javascript import Parser from "rss-parser"; let parser = new Parser(); export default { name: "Source Demo", description: "This is a demo source", dedupe: "unique", async run() { let feed = await parser.parseURL("https://lorem-rss.herokuapp.com/feed"); feed.items.forEach((item) => { this.$emit(item, { summary: item.title, id: item.guid, }); }); }, }; ``` -------------------------------- ### Update Trigger Webhooks with TypeScript SDK Source: https://pipedream.com/docs/connect/api-reference/update-trigger-webhooks Use this TypeScript example to update trigger webhooks. Ensure the `@pipedream/sdk` package is installed and your client is configured with the necessary environment and project details. ```typescript import { PipedreamClient } from "@pipedream/sdk"; const client = new PipedreamClient({ clientId: "YOUR_CLIENT_ID", clientSecret: "YOUR_CLIENT_SECRET", projectEnvironment: "YOUR_PROJECT_ENVIRONMENT", projectId: "YOUR_PROJECT_ID" }); await client.deployedTriggers.updateWebhooks("trigger_id", { externalUserId: "external_user_id", webhookUrls: ["webhook_urls"] }); ``` -------------------------------- ### Deploy Component from Local File Source: https://pipedream.com/docs/llms-full.txt Deploy a component by providing the path to its local JavaScript file. ```bash pd deploy http.js ``` -------------------------------- ### Start Local Development with pd dev Source: https://pipedream.com/docs/components/api Use `pd dev` to deploy a local file and attach it to a component for automatic updates on save. This is ideal for developing and testing sources. ```bash pd dev ``` ```bash pd dev --dc ``` -------------------------------- ### Get Access Token for MCP Server Auth (TypeScript) Source: https://pipedream.com/docs/connect/mcp/developers Initializes the Pipedream SDK client and retrieves an access token for authenticating requests to the MCP server. Requires Pipedream SDK to be installed. ```typescript import { PipedreamClient } from "@pipedream/sdk"; // Initialize the Pipedream SDK client const client = new PipedreamClient({ projectEnvironment: PIPEDREAM_ENVIRONMENT, clientId: PIPEDREAM_CLIENT_ID, clientSecret: PIPEDREAM_CLIENT_SECRET, projectId: PIPEDREAM_PROJECT_ID }); // Get access token for MCP server auth const accessToken = await client.rawAccessToken; console.log(accessToken); ``` -------------------------------- ### Initialize a New Pipedream App Source: https://pipedream.com/docs/llms-full.txt Create a new app directory and its associated file from a template. ```bash # Creates google_calendar/ directory and google_calendar.mjs file pd init app google_calendar ``` -------------------------------- ### List Components for a Pipedream App (REST API) Source: https://pipedream.com/docs/llms-full.txt List the available components for a Pipedream app by making a GET request to the /connect/{project_id}/actions endpoint. This example lists components for the 'gitlab' app. ```bash curl -X 'https://api.pipedream.com/v1/connect/{project_id}/actions?app=gitlab' \ -H "Content-Type: application/json" \ -H "X-PD-Environment: {environment}" \ -H "Authorization: Bearer {access_token}" # Parse and return the data you need ``` -------------------------------- ### GitLab Proxy Request Example Source: https://pipedream.com/docs/llms-full.txt Shows making a GET request to the GitLab API using a relative path with the client.proxy.get method. This is required for apps with dynamic domains where Pipedream resolves the URL at runtime. ```typescript // Must use relative path await client.proxy.get({ accountId: "apn_1234567", externalUserId: "user-123", url: "/api/v4/projects", // Pipedream resolves to the end user's GitLab instance }) ``` -------------------------------- ### Create Project with Python SDK Source: https://pipedream.com/docs/connect/api-reference/create-project Create a new project using the Python SDK. Initialize the Pipedream client with your project and authentication details. ```python from pipedream import Pipedream client = Pipedream( project_id="YOUR_PROJECT_ID", client_id="YOUR_CLIENT_ID", client_secret="YOUR_CLIENT_SECRET", ) client.projects.create( name="name", ) ``` -------------------------------- ### Initialize Pipedream SDK, Find App, and Send OpenAI Request (Python) Source: https://pipedream.com/docs/connect/mcp/ai-frameworks/openai This Python snippet demonstrates initializing the Pipedream SDK, locating an app (like Notion) for the MCP server, and then executing an OpenAI request with the MCP server as a tool. Ensure all required Pipedream environment variables and API keys are configured. ```python import openai from pipedream import Pipedream # Initialize the Pipedream SDK client pd = Pipedream( project_id=PIPEDREAM_PROJECT_ID, project_environment=PIPEDREAM_ENVIRONMENT, client_id=PIPEDREAM_CLIENT_ID, client_secret=PIPEDREAM_CLIENT_SECRET, ) # Find the app to use for the MCP server # For this example, we'll use Notion apps = pd.apps.list(q="notion") app_slug = apps.data[0].name_slug # e.g., "notion" # Get access token for MCP server auth access_token = await pd.raw_access_token # Send the unique ID that you use to identify this user in your system external_user_id = 'abc-123' # Used in MCP URL to identify the user # Initialize OpenAI client openai_client = openai.OpenAI() # Make the OpenAI request with the MCP server response = openai_client.responses.create( model='gpt-4.1', tools=[ { "type": "mcp", "server_label": app_slug, "server_url": "https://remote.mcp.pipedream.net/v3", "headers": { "Authorization": f"Bearer {access_token}", "x-pd-project-id": PIPEDREAM_PROJECT_ID, "x-pd-environment": PIPEDREAM_ENVIRONMENT, "x-pd-external-user-id": external_user_id, "x-pd-app-slug": app_slug, }, "require_approval": "never" } ], input='Summarize my most recently created Notion doc for me and help draft an email to our customers' ) print(response); ``` -------------------------------- ### Get Workflow API Response Example Source: https://pipedream.com/docs/llms-full.txt This JSON structure shows the details of a workflow, including its triggers and steps, and their configurable properties. It's used to identify the names and types of props needed for creating a new workflow. ```json { "triggers": [ { "id": "dc_abc123", "configurable_props": [ { "name": "url", "type": "string" } ], "configured_props": {}, "active": true, "created_at": 1707170044, "updated_at": 1707170044, "name": "New Item in Feed", "name_slug": "new-item-in-feed" } ], "steps": [ { "namespace": "send_message", "lang": "nodejs20.x", "component": true, "savedComponent": { "id": "sc_abc123", "configurableProps": [ { "name": "slack", "type": "app", "app": "slack" }, { "name": "channelId", "type": "string" }, { "name": "message", "type": "string" } ] } } ] } ``` -------------------------------- ### Async Options Example Implementation Source: https://pipedream.com/docs/llms-full.txt Example demonstrating how to implement async options in a Pipedream component. The `options()` method returns an array of strings to be used as selectable values for the 'msg' prop. ```javascript export default { name: "Async Options Example", version: "0.1", props: { msg: { type: "string", label: "Message", description: "Select a message to `console.log()`", async options() { // write any node code that returns a string[] or object[] (with label/value keys) return ["This is option 1", "This is option 2"]; }, }, }, async run() { this.$emit(this.msg); }, }; ``` -------------------------------- ### Example S3 Object Path Source: https://pipedream.com/docs/workflows/data-management/destinations/s3 An example of how an object might appear in an S3 bucket with a 'test/' prefix, demonstrating the date-based folder structure and filename format. ```txt test/2019/05/25/16/2019-05-25-16-14-58-8f25b54462bf6eeac3ee8bde512b6c59654c454356e808167a01c43ebe4ee919.gz ``` -------------------------------- ### Basic Usage: AI with Pipedream MCP Source: https://pipedream.com/docs/connect/mcp/ai-frameworks/vercel-ai-sdk Demonstrates a complete example of using the Vercel AI SDK with Pipedream MCP. It shows how to initialize clients, authenticate, define messages, and generate text using AI models with access to Pipedream tools. Includes setup for environment variables and authentication. ```typescript import { openai } from '@ai-sdk/openai'; import { UIMessage, convertToModelMessages, experimental_createMCPClient, generateText, stepCountIs } from 'ai'; import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp'; import { PipedreamClient } from '@pipedream/sdk'; // Environment variables const PIPEDREAM_CLIENT_ID = process.env.PIPEDREAM_CLIENT_ID!; const PIPEDREAM_CLIENT_SECRET = process.env.PIPEDREAM_CLIENT_SECRET!; const PIPEDREAM_PROJECT_ID = process.env.PIPEDREAM_PROJECT_ID!; const PIPEDREAM_ENVIRONMENT = process.env.PIPEDREAM_ENVIRONMENT as 'development' | 'production'; async function runAIWithMCP() { // Initialize Pipedream SDK client const pd = new PipedreamClient({ projectEnvironment: PIPEDREAM_ENVIRONMENT, clientId: PIPEDREAM_CLIENT_ID, clientSecret: PIPEDREAM_CLIENT_SECRET, projectId: PIPEDREAM_PROJECT_ID }); // Get access token for MCP authentication const accessToken = await pd.rawAccessToken; const externalUserId = 'user-123'; // Your user's unique ID const appSlug = 'notion'; // The app you want to use // Create MCP transport with authentication headers const transport = new StreamableHTTPClientTransport( new URL('https://remote.mcp.pipedream.net/v3'), { requestInit: { headers: { 'Authorization': `Bearer ${accessToken}`, 'x-pd-project-id': PIPEDREAM_PROJECT_ID, 'x-pd-environment': PIPEDREAM_ENVIRONMENT, 'x-pd-external-user-id': externalUserId, 'x-pd-app-slug': appSlug, } } } ); // Create MCP client using AI SDK const mcpClient = await experimental_createMCPClient({ transport, }); const messages: UIMessage[] = [ { id: 'system-1', role: 'system', parts: [ { type: 'text', text: 'You are a helpful assistant that can use Pipedream tools to help users with their tasks.' }, ], }, { id: 'user-1', role: 'user', parts: [ { type: 'text', text: 'Find my most recent Notion page and summarize it for me' }, ], }, ]; try { // Generate response with tools available from MCP const result = await generateText({ model: openai('gpt-4'), // Convert UI messages (with parts) into model messages required by generateText messages: convertToModelMessages(messages), tools: await mcpClient.tools(), // Automatically loads all available tools stopWhen: stepCountIs(5), // Equivalent to allowing up to 5 tool-call steps }); console.log('AI Response:', result.text); // Log any tool calls that were made if (result.toolCalls.length > 0) { console.log('\nTool calls made:'); result.toolCalls.forEach((toolCall, index) => { console.log(`${index + 1}. ${toolCall.toolName}`); console.log(` Input: ${JSON.stringify(toolCall.input, null, 2)}`); }); console.log('\nTool results:'); result.toolResults.forEach((toolResult, index) => { console.log(`${index + 1}. ${JSON.stringify(toolResult.output, null, 2)}`); }); } } finally { // Clean up MCP client await mcpClient.close(); } } // Run the example runAIWithMCP().catch(console.error); ``` -------------------------------- ### Install Required Dependencies with pnpm Source: https://pipedream.com/docs/llms-full.txt Install all required dependencies for the project using pnpm. This command is used for recursive installation across the project. ```bash npx pnpm install -r ``` -------------------------------- ### Run Hello World Component with Pipedream CLI Source: https://pipedream.com/docs/llms-full.txt Deploy and run the 'Hello World' Pipedream component using the CLI. The CLI will watch for file changes and update the deployed component automatically. ```bash pd dev source.js ``` -------------------------------- ### Install Pipedream CLI using install script with sudo on macOS Source: https://pipedream.com/docs/cli/install If the standard install script returns a permissions error, try running it with `sudo`. ```bash curl https://cli.pipedream.com/install | sudo sh ``` -------------------------------- ### Initialize Gemini and MCP Client Source: https://pipedream.com/docs/connect/mcp/ai-frameworks/gemini This snippet shows how to initialize the Pipedream client, obtain an access token, and set up the MCP client with specific server configurations and headers for authentication and app integration. ```python pd = Pipedream( project_id=os.environ.get('PIPEDREAM_PROJECT_ID'), project_environment=os.environ.get('PIPEDREAM_ENVIRONMENT'), client_id=os.environ.get('PIPEDREAM_CLIENT_ID'), client_secret=os.environ.get('PIPEDREAM_CLIENT_SECRET'), ) access_token = await pd.raw_access_token # Initialize Gemini client client = genai.Client(api_key=os.environ.get('GOOGLE_API_KEY')) # Initialize MCP client with Pipedream mcp_client = Client({ "mcpServers": { "pipedream": { "transport": "http", "url": "https://remote.mcp.pipedream.net/v3", "headers": { "Authorization": f"Bearer {access_token}", "x-pd-project-id": os.environ.get('PIPEDREAM_PROJECT_ID'), "x-pd-environment": os.environ.get('PIPEDREAM_ENVIRONMENT'), "x-pd-external-user-id": "user-123", # Your user's unique ID "x-pd-app-slug": "gmail, google_calendar", # Apps to use }, } } }) ``` -------------------------------- ### Get Pre-signed GET URL for a File Source: https://pipedream.com/docs/workflows/data-management/file-stores/reference Retrieves the pre-signed GET URL for a specified file. Note that these URLs are short-lived and expire after 30 minutes. ```javascript export default defineComponent({ async run({ steps, $ }) { // Retrieve the pre-signed GET URL for logo.png const url = await $.files.open('logo.png').toUrl() return url }, }) ``` -------------------------------- ### Example Pipedream Endpoint URL Source: https://pipedream.com/docs/workflows/domains This is an example of a standard Pipedream endpoint URL. ```text https://[endpoint_id].m.pipedream.net ```