Skip to content

[BUG] Connect x OpenAI Error #17124

Open
Open
@Tej-Sharma

Description

@Tej-Sharma

Describe the bug

There's a bug on the Notion and Google Sheets. Instead of sending back a connect URL, it just fails. I talked to Danny on the Slack, and he redirected me here. All the tools are gotten from MCP but at the OpenAI end, it's not able to identify a connect URL auth is needed.

Here is the exact code I used from the SDK:

import OpenAI from "openai";
import { createBackendClient } from "@pipedream/sdk/server";

// Initialize the Pipedream SDK client
const pd = createBackendClient({
    environment: process.env.PIPEDREAM_ENVIRONMENT as
        | "production"
        | "development",
    credentials: {
        clientId: process.env.PIPEDREAM_CLIENT_ID!,
        clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
    },
    projectId: process.env.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" });
if (!apps.data || apps.data.length === 0) {
    throw new Error("No Notion app found");
}
const app = apps.data[0];
if (!app || !app.name_slug || !app.name) {
    throw new Error("App data is incomplete");
}
const appSlug = app.name_slug; // e.g., "notion",
const appLabel = app.name; // 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: appLabel,
            server_url: `https://remote.mcp.pipedream.net`,
            headers: {
                Authorization: `Bearer ${accessToken}`,
                "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
                "x-pd-environment": process.env.PIPEDREAM_ENVIRONMENT!,
                "x-pd-external-user-id": externalUserId,
                "x-pd-app-slug": appSlug,
            },
            require_approval: "never",
        },
    ],
    input: "Summarize my most recently created Notion doc for me and help draft an email to our customers",
});

console.log(response);

And the output error was:

{
  id: "resp_684cff5877e0819bbf57d6703e56c056019c83fd739108e0",
  object: "response",
  created_at: 1749876568,
  status: "completed",
  background: false,
  error: null,
  incomplete_details: null,
  instructions: null,
  max_output_tokens: null,
  model: "gpt-4.1-2025-04-14",
  output: [
    {
      id: "mcpl_684cff588334819b9df7881a341b5b45019c83fd739108e0",
      type: "mcp_list_tools",
      server_label: "Notion",
      tools: [
        [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...]
      ],
    }, {
      id: "mcp_684cff5a8f10819b88025025c0759ada019c83fd739108e0",
      type: "mcp_call",
      approval_request_id: null,
      arguments: "{\"instruction\":\"Retrieve the most recently created Notion doc in the workspace. Summarize its content.\"}",
      error: null,
      name: "NOTION-RETRIEVE-DATABASE-CONTENT",
      output: "An error occurred while calling the tool: Error: HTTP error! status: 404, body: {\"error\":\"route not found\"}",
      server_label: "Notion",
    }, {
      id: "msg_684cff5c894c819baaff32ec5666d45d019c83fd739108e0",
      type: "message",
      status: "completed",
      content: [
        [Object ...]
      ],
      role: "assistant",
    }
  ],
  parallel_tool_calls: true,
  previous_response_id: null,
  reasoning: {
    effort: null,
    summary: null,
  },
  service_tier: "default",
  store: true,
  temperature: 1,
  text: {
    format: {
      type: "text",
    },
  },
  tool_choice: "auto",
  tools: [
    {
      type: "mcp",
      allowed_tools: null,
      headers: [Object ...],
      require_approval: "never",
      server_label: "Notion",
      server_url: "https://remote.mcp.pipedream.net",
    }
  ],
  top_p: 1,
  truncation: "disabled",
  usage: {
    input_tokens: 2038,
    input_tokens_details: {
      cached_tokens: 1006,
    },
    output_tokens: 144,
    output_tokens_details: {
      reasoning_tokens: 0,
    },
    total_tokens: 2182,
  },
  user: null,
  metadata: {},
  _request_id: "req_479a6ad736edac939b25c8a866917cae",
  output_text: "It looks like I wasn’t able to directly retrieve your Notion document due to a permissions or connection issue. However, I can still help! Here’s what I need from you:\n\n- Please either paste the content or the key points from your most recently created Notion doc here, or let me know the title/subject.\n- Once I have the content or main points, I’ll provide a sum

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem. Note that the screenshots will be displayed publicly.

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions