How to Implement User Authentication for 3rd Party Tools in Connect x OpenAI?

This topic was automatically generated from Slack. You can find the original thread here.

Hi! Trying to implement the new Connect x OpenAI, but confused when running this, if the user needs to authenticate to 3rd party tool (Gmail, Notion, etc). how will this work with that part?

The docs got the frontend part auth generation but then the OpenAI docs seems disconnected in the overall flow

Based on my current understanding, I’m guessing you have to pre-authenticate them via the Quickstart docs… but I saw somewhere the API can also return a link to make users authenticate on the fly?

That’s what the chat.pipedream demo does

Check this out: https://pipedream.com/docs/connect/mcp/developers/#user-account-connections

Thx I’d seen, this part:

But when calling OpenAI, it should return a URL to authenticate that I pass on to the user to login to Notion right?

Yea that’s right. Are you getting that URL back in the tool call response?

Getting this error:

 ResponseOutputMessage(id='msg_684ce7d547648198a39dff5db5287a0d0c6f2505251463fc', content=[ResponseOutputText(annotations=[], text="It looks like I wasn't able to automatically retrieve your most recently created Notion document due to a permissions or connection issue. If you can copy the content of your latest Notion doc here (or share the main points), I can summarize it for you and help draft an email to your customers.\n\nCould you paste the document contents or give me a brief overview of what it's about?", type='output_text')], role='assistant', status='completed', type='message')]
(venv) Demon-Slayer:pipedream tej

I’m using OpenAI directly though, that may be why

But does the MCP server should have logic for defaulting to auth URL return if not granted?

(Here’s the code anyhow)

Hm that’s right. It’s checks if the external user id has a connected account for the relevant app. If it does, we proceed. If not we return a Connect Link URL.

I see, is there a bug report for this beta? Otherwise, I can try spinning up a node server to see if it’s something wrong with the CURL sdk

Is that consistently happening? I actually tested the curl examples end to end just this week, since I had to fix a a couple typos in them.

{
    "mcp_list_tools": {
        "id": "mcpl_684cfad1d4a8819891fbd5d390b9414d06fff254596b6567",
        "server_label": "Notion",
        "type": "mcp_list_tools",
        "error": null,
        "tools": [
            {
                "name": "NOTION-UPDATE-PAGE",
                "description": "Update a page's property values. To append page content, use the **Append Block** action instead. [See the documentation](https://developers.notion.com/reference/patch-page)",
                "input_schema": {
                    "type": "object",
                    "properties": {
                        "instruction": {
                            "type": "string",
                            "description": "Very detailed instructions describing the action to be taken. Include any information that might be useful."
                        }
                    },
                    "required": ["instruction"],
                    "additionalProperties": false,
                    "$schema": "http://json-schema.org/draft-07/schema#"
                }
            },
            {
                "name": "NOTION-SEARCH",
                "description": "Searches for a page or database. [See the documentation](https://developers.notion.com/reference/post-search)"
            },
            {
                "name": "NOTION-RETRIEVE-PAGE",
                "description": "Get details of a page. [See the documentation](https://developers.notion.com/reference/retrieve-a-page)"
            },
            {
                "name": "NOTION-RETRIEVE-PAGE-PROPERTY-ITEM",
                "description": "Get a Property Item object for a selected page and property. [See the documentation](https://developers.notion.com/reference/retrieve-a-page-property)"
            },
            {
                "name": "NOTION-RETRIEVE-DATABASE-SCHEMA",
                "description": "Get the property schema of a database in Notion. [See the documentation](https://developers.notion.com/reference/retrieve-a-database)"
            },
            {
                "name": "NOTION-RETRIEVE-DATABASE-CONTENT",
                "description": "Get all content of a database. [See the documentation](https://developers.notion.com/reference/post-database-query)"
            },
            {
                "name": "NOTION-RETRIEVE-BLOCK",
                "description": "Get page content as block objects or markdown. Blocks can be text, lists, media, a page, among others. [See the documentation](https://developers.notion.com/reference/retrieve-a-block)"
            },
            {
                "name": "NOTION-QUERY-DATABASE",
                "description": "Query a database with a specified filter. [See the documentation](https://developers.notion.com/reference/post-database-query)"
            },
            {
                "name": "NOTION-DUPLICATE-PAGE",
                "description": "Create a new page copied from an existing page block. [See the documentation](https://developers.notion.com/reference/post-page)"
            },
            {
                "name": "NOTION-CREATE-PAGE",
                "description": "Create a page from a parent page. [See the documentation](https://developers.notion.com/reference/post-page)"
            },
            {
                "name": "NOTION-CREATE-PAGE-FROM-DATABASE",
                "description": "Create a page from a database. [See the documentation](https://developers.notion.com/reference/post-page)"
            },
            {
                "name": "NOTION-CREATE-COMMENT",
                "description": "Create a comment in a page or existing discussion thread. [See the documentation](https://developers.notion.com/reference/create-a-comment)"
            },
            {
                "name": "NOTION-APPEND-BLOCK",
                "description": "Append new and/or existing blocks to the specified parent. [See the documentation](https://developers.notion.com/reference/patch-block-children)"
            },
            {
                "name": "NOTION-FIND-PAGE",
                "description": "Searches for a page by its title. [See the docs](https://developers.notion.com/reference/post-search)"
            }
        ]
    },
    "mcp_call": {
        "id": "mcp_684cfad44d488198976db0391ae0f3da06fff254596b6567",
        "name": "NOTION-RETRIEVE-DATABASE-CONTENT",
        "server_label": "Notion",
        "type": "mcp_call",
        "arguments": "{\"instruction\":\"Get the content of the most recently created Notion document.\"}",
        "error": "An error occurred while calling the tool: Error: HTTP error! status: 404, body: {\"error\":\"route not found\"}",
        "output": "An error occurred while calling the tool: Error: HTTP error! status: 404, body: {\"error\":\"route not found\"}",
        "approval_request_id": null
    },
    "response_output_message": {
        "id": "msg_684cfad60714819898c21509d9397a8306fff254596b6567",
        "role": "assistant",
        "status": "completed",
        "type": "message",
        "content": [
            {
                "type": "output_text",
                "annotations": [],
                "text": "It seems I wasn't able to directly retrieve your most recent Notion document due to a permissions or connection issue. However, you can help me by:\n\n1. Providing the text or main points from the document.\n2. Or, sharing a brief outline of its content.\n\nOnce you've done that, I can quickly summarize it and help you draft a customer email! Could you please paste or describe the document here?"
            }
        ]
    },
    "error_summary": {
        "main_error": "HTTP 404 - route not found",
        "failed_operation": "NOTION-RETRIEVE-DATABASE-CONTENT",
        "error_type": "API endpoint not found",
        "status_code": 404,
        "timestamp": "extracted from IDs: 684cfad series",
        "description": "The Notion MCP tool attempted to retrieve database content but encountered a 404 error, indicating the API route was not found. This could be due to incorrect endpoint configuration, permissions issues, or API changes."
    }
}

Yes, it seems the MCP tools are retrieved but there’s a error 404

Hm shoot, sorry about that. Yea if you don’t mind filing a bug, that’ll help us dig in. Something is obviously not working there. You can file a GitHub issue in the pipedreamhq/pipedream repo or pipedream.com/support

No worries, happy to test it out

I tried on a Node server, getting the exact same error

Also another one, if I change the docs “getApps” from “notion” to “google_sheets”, I get this one on the NodeSDK:

Weird, that one looks like an error from OpenAI.

Oh is the server_label set to the app name? Might be a typo in the docs if that’s what we’re telling you to pass.