Skip to content

Issue #17031 #17036

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

jeevikasirwani
Copy link

@jeevikasirwani jeevikasirwani commented Jun 7, 2025

WHY

Add “Chat with OpenAI Responses API” action
This PR adds a new action that lets you call the OpenAI Responses API with both built-in tools and tools from MCP servers.

What’s changed

File: pipedream\components\openai\actions\chat-with-opeai-responses-api/chat-with-openai-responses-api.mjs

Props added

builtInTools: pick any of OpenAI’s tools (web search, file search, code interpreter)

mcpServers: enter one or more MCP server URLs (see https://mcp.pipedream.com/)

mcpTools: loads the list of tools from each MCP server URL for you to select

run() logic

Combines builtInTools and mcpTools into one tools array

Sends a single openai.responses.create() request with that array

Keeps existing features : Skip-step flag,JSON-schema output option,Shared methods from common.

Summary by CodeRabbit

  • New Features
    • Introduced a new action to send chat messages via the OpenAI Responses API, supporting model selection, system instructions, multi-turn conversations, and response formatting (text or JSON schema).
    • Enabled integration with built-in OpenAI tools (web search, file search, code interpreter) and external MCP servers, with dynamic tool selection.
    • Added validation and error handling for structured (JSON schema) responses.

Copy link

vercel bot commented Jun 7, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Jun 7, 2025 9:58am

Copy link

vercel bot commented Jun 7, 2025

@jeevikasirwani is attempting to deploy a commit to the Pipedreamers Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Jun 7, 2025

Walkthrough

A new action module, "Chat with OpenAI Responses API," has been introduced. This module allows sending chat messages to the OpenAI Responses API, with configurable options for model selection, chat input, system instructions, tool integrations, response formatting, and support for multi-turn conversations. Dynamic property handling and validation are included.

Changes

File(s) Change Summary
components/openai/actions/chat-with-opeai-responses-api/chat-with-openai-responses-api.mjs Added new action module for interacting with the OpenAI Responses API, supporting tool selection, JSON schema output, and more.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ActionModule
    participant OpenAIResponsesAPI
    participant MCPServer (optional)

    User->>ActionModule: Provide input, model, and options
    ActionModule->>MCPServer: (If MCP tools enabled) Fetch available tools
    ActionModule->>OpenAIResponsesAPI: Send chat request with parameters
    OpenAIResponsesAPI-->>ActionModule: Return response and responseId
    ActionModule-->>User: Export chat output and summary
Loading

Poem

In the warren of code, a new path unfurls,
Chatting with OpenAI, as the message twirls.
Tools at our paws, JSON in the air,
Multi-turn hops handled with flair.
Rabbits rejoice—responses anew,
In structured delight, we chat with you!
🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

components/openai/actions/chat-with-opeai-responses-api/chat-with-openai-responses-api.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at Object.getPackageJSONURL (node:internal/modules/package_json_reader:255:9)
at packageResolve (node:internal/modules/esm/resolve:767:81)
at moduleResolve (node:internal/modules/esm/resolve:853:18)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:799:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:723:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:706:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:307:38)
at #link (node:internal/modules/esm/module_job:170:49)

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@adolfo-pd adolfo-pd added the User submitted Submitted by a user label Jun 7, 2025
@pipedream-component-development
Copy link
Collaborator

Thank you so much for submitting this! We've added it to our backlog to review, and our team has been notified.

@pipedream-component-development
Copy link
Collaborator

Thanks for submitting this PR! When we review PRs, we follow the Pipedream component guidelines. If you're not familiar, here's a quick checklist:

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Nitpick comments (2)
components/openai/actions/chat-with-opeai-responses-api/chat-with-openai-responses-api.mjs (2)

21-24: Consider expanding model options.

The current model selection is limited to only gpt-4o and gpt-4o-mini. Consider including other models that support the Responses API to provide users with more flexibility.


114-125: Optimize MCP server requests for better performance.

The current implementation makes sequential requests to MCP servers. Consider making parallel requests to improve performance when multiple servers are configured.

  async options({ mcpServers }) {
    if (!mcpServers?.length) return [];
-   const all = [];
-   for (let url of mcpServers) {
-     url = url.replace(/\/$/, "");
-     try {
-       const { data } = await axios.get(`${url}/tools`, {
-         timeout: 5000,
-         validateStatus: (status) => status === 200,
-       });
-       if (data?.tools && Array.isArray(data.tools)) {
-         for (const t of data.tools) {
-           if (t?.name && t?.id) {
-             all.push({
-               label: t.name,
-               value: t.id,
-             });
-           }
-         }
-       }
-     } catch (error) {
-       console.warn(`Failed to fetch tools from ${url}:`, error.message);
-     }
-   }
+   
+   const requests = mcpServers.map(async (url) => {
+     url = url.replace(/\/$/, "");
+     try {
+       const { data } = await axios.get(`${url}/tools`, {
+         timeout: 5000,
+         validateStatus: (status) => status === 200,
+       });
+       if (data?.tools && Array.isArray(data.tools)) {
+         return data.tools
+           .filter(t => t?.name && t?.id)
+           .map(t => ({
+             label: t.name,
+             value: t.id,
+           }));
+       }
+     } catch (error) {
+       console.warn(`Failed to fetch tools from ${url}:`, error.message);
+     }
+     return [];
+   });
+   
+   const results = await Promise.all(requests);
+   const all = results.flat();
    return all;
  },
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0184878 and a3765cb.

⛔ Files ignored due to path filters (6)
  • components/quickbooks/package-lock.json is excluded by !**/package-lock.json
  • components/smiirl/package-lock.json is excluded by !**/package-lock.json
  • docs-v2/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
  • helpers/package-lock.json is excluded by !**/package-lock.json
  • packages/connect-react/examples/nextjs/package-lock.json is excluded by !**/package-lock.json
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (1)
  • components/openai/actions/chat-with-opeai-responses-api/chat-with-openai-responses-api.mjs (1 hunks)
🔇 Additional comments (1)
components/openai/actions/chat-with-opeai-responses-api/chat-with-openai-responses-api.mjs (1)

8-8: ⚠️ Potential issue

Fix typo in the action key.

There's a typo in the key: "opeai" should be "openai".

- key: "openai-chat-using-responses-api",
+ key: "openai-chat-with-responses-api",

Likely an incorrect or invalid review comment.

Comment on lines +186 to +189
const response = await this.openai.responses({
$,
data,
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Verify the OpenAI responses method exists.

Ensure that the this.openai.responses() method is available in the OpenAI app module, as this appears to be a newer API endpoint.


🏁 Script executed:

#!/bin/bash
# Description: Verify if the responses method exists in the OpenAI app module
# Expected: Find the responses method implementation

# Search for the responses method in OpenAI related files
ast-grep --pattern 'responses($_) {
  $$$
}'

# Also search for any mention of responses API
rg -A 5 "responses.*api|responses.*method"

Length of output: 6777


Missing responses Method on OpenAI Client

We couldn’t locate a responses method on this.openai. The OpenAI app module does not currently expose this endpoint, so calling this.openai.responses() will fail.

Please update accordingly:

  • Confirm the correct client method name for the new Responses API (e.g., chat.completions, chat.stream, etc.).
  • If responses is intended, implement it in the OpenAI app module (components/openai), wiring through to the actual API endpoint.
  • Otherwise, replace the call in components/openai/actions/chat-with-opeai-responses-api/chat-with-openai-responses-api.mjs (around lines 186–189) with the appropriate existing method.
🤖 Prompt for AI Agents
In
components/openai/actions/chat-with-opeai-responses-api/chat-with-openai-responses-api.mjs
around lines 186 to 189, the call to this.openai.responses() is invalid because
the OpenAI client does not have a responses method. To fix this, verify the
correct existing method name for the intended API call (such as chat.completions
or chat.stream) and replace this.openai.responses() with that method. If the
responses method is required, implement it in the OpenAI app module under
components/openai by adding the appropriate API endpoint wiring before using it
here.

Comment on lines +158 to +162
for (const id of this.mcpTools || []) {
tools.push({
type: id,
});
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add array validation for mcpTools.

The code assumes mcpTools is an array without validation, which could cause runtime errors if the property is undefined or not an array.

- for (const id of this.mcpTools || []) {
+ for (const id of Array.isArray(this.mcpTools) ? this.mcpTools : []) {
    tools.push({
      type: id,
    });
  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
for (const id of this.mcpTools || []) {
tools.push({
type: id,
});
}
for (const id of Array.isArray(this.mcpTools) ? this.mcpTools : []) {
tools.push({
type: id,
});
}
🤖 Prompt for AI Agents
In
components/openai/actions/chat-with-opeai-responses-api/chat-with-openai-responses-api.mjs
around lines 158 to 162, the code iterates over this.mcpTools assuming it is
always an array, which can cause runtime errors if it is undefined or not an
array. Add a validation check to confirm this.mcpTools is an array before the
loop, and only iterate if the check passes. This prevents errors by ensuring the
code handles cases where mcpTools is missing or not an array.

Comment on lines +112 to +126
async options({ mcpServers }) {
if (!mcpServers?.length) return [];
const all = [];
for (let url of mcpServers) {
url = url.replace(/\/$/, "");
const { data } = await axios.get(`${url}/tools`);
for (const t of data.tools) {
all.push({
label: t.name,
value: t.id,
});
}
}
return all;
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add comprehensive error handling for MCP server requests.

The async options method lacks error handling for HTTP requests to MCP servers. If a server is unreachable or returns an error, this will cause the component to fail during property loading.

  async options({ mcpServers }) {
    if (!mcpServers?.length) return [];
    const all = [];
    for (let url of mcpServers) {
      url = url.replace(/\/$/, "");
-     const { data } = await axios.get(`${url}/tools`);
-     for (const t of data.tools) {
-       all.push({
-         label: t.name,
-         value: t.id,
-       });
-     }
+     try {
+       const { data } = await axios.get(`${url}/tools`, {
+         timeout: 5000,
+         validateStatus: (status) => status === 200,
+       });
+       if (data?.tools && Array.isArray(data.tools)) {
+         for (const t of data.tools) {
+           if (t?.name && t?.id) {
+             all.push({
+               label: t.name,
+               value: t.id,
+             });
+           }
+         }
+       }
+     } catch (error) {
+       console.warn(`Failed to fetch tools from ${url}:`, error.message);
+       // Continue with other servers instead of failing completely
+     }
    }
    return all;
  },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
async options({ mcpServers }) {
if (!mcpServers?.length) return [];
const all = [];
for (let url of mcpServers) {
url = url.replace(/\/$/, "");
const { data } = await axios.get(`${url}/tools`);
for (const t of data.tools) {
all.push({
label: t.name,
value: t.id,
});
}
}
return all;
},
async options({ mcpServers }) {
if (!mcpServers?.length) return [];
const all = [];
for (let url of mcpServers) {
url = url.replace(/\/$/, "");
try {
const { data } = await axios.get(`${url}/tools`, {
timeout: 5000,
validateStatus: (status) => status === 200,
});
if (data?.tools && Array.isArray(data.tools)) {
for (const t of data.tools) {
if (t?.name && t?.id) {
all.push({
label: t.name,
value: t.id,
});
}
}
}
} catch (error) {
console.warn(`Failed to fetch tools from ${url}:`, error.message);
// Continue with other servers instead of failing completely
}
}
return all;
},
🤖 Prompt for AI Agents
In
components/openai/actions/chat-with-opeai-responses-api/chat-with-openai-responses-api.mjs
around lines 112 to 126, the async options method does not handle errors from
axios.get calls to MCP servers, which can cause failures if a server is
unreachable or returns an error. Add try-catch blocks around the axios.get
request to catch any errors, log or handle them appropriately, and ensure the
method continues processing other servers without failing entirely. This will
make the property loading more robust against individual server issues.

Comment on lines +175 to +184
try {
data.text = {
format: {
type: this.responseFormat,
...JSON.parse(this.jsonSchema),
},
};
} catch {
throw new Error("Invalid JSON format in the provided JSON Schema");
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Improve JSON schema validation and error handling.

The current error handling for JSON parsing is too generic and doesn't provide helpful feedback to users.

  try {
+   if (!this.jsonSchema || typeof this.jsonSchema !== 'string') {
+     throw new Error("JSON Schema is required when using json_schema response format");
+   }
+   const parsedSchema = JSON.parse(this.jsonSchema);
+   if (typeof parsedSchema !== 'object' || parsedSchema === null) {
+     throw new Error("JSON Schema must be a valid JSON object");
+   }
    data.text = {
      format: {
        type: this.responseFormat,
-       ...JSON.parse(this.jsonSchema),
+       ...parsedSchema,
      },
    };
- } catch {
-   throw new Error("Invalid JSON format in the provided JSON Schema");
+ } catch (error) {
+   if (error instanceof SyntaxError) {
+     throw new Error(`Invalid JSON syntax in schema: ${error.message}`);
+   }
+   throw error;
  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
try {
data.text = {
format: {
type: this.responseFormat,
...JSON.parse(this.jsonSchema),
},
};
} catch {
throw new Error("Invalid JSON format in the provided JSON Schema");
}
try {
if (!this.jsonSchema || typeof this.jsonSchema !== 'string') {
throw new Error("JSON Schema is required when using json_schema response format");
}
const parsedSchema = JSON.parse(this.jsonSchema);
if (typeof parsedSchema !== 'object' || parsedSchema === null) {
throw new Error("JSON Schema must be a valid JSON object");
}
data.text = {
format: {
type: this.responseFormat,
...parsedSchema,
},
};
} catch (error) {
if (error instanceof SyntaxError) {
throw new Error(`Invalid JSON syntax in schema: ${error.message}`);
}
throw error;
}
🤖 Prompt for AI Agents
In
components/openai/actions/chat-with-opeai-responses-api/chat-with-openai-responses-api.mjs
around lines 175 to 184, the catch block for JSON.parse is too generic and does
not provide detailed error feedback. Modify the catch block to capture the
specific error thrown by JSON.parse and include its message in the thrown Error,
so users receive more informative feedback about what went wrong with the JSON
schema parsing.

Comment on lines +99 to +104
mcpServers: {
type: "string[]",
label: "MCP Server URLs",
description:
"Enter your MCP server base URLs. To set one up, visit https://mcp.pipedream.com/ and click “Create new server.",
optional: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider adding URL validation for MCP servers.

User-provided MCP server URLs could potentially be used for SSRF attacks. Consider validating that URLs point to expected domains or implementing allowlists.

  mcpServers: {
    type: "string[]",
    label: "MCP Server URLs",
    description:
      "Enter your MCP server base URLs. To set one up, visit https://mcp.pipedream.com/ and click "Create new server.",
    optional: true,
+   validate: (urls) => {
+     if (!urls?.length) return true;
+     for (const url of urls) {
+       try {
+         const parsed = new URL(url);
+         if (!['http:', 'https:'].includes(parsed.protocol)) {
+           throw new Error(`Invalid protocol: ${parsed.protocol}`);
+         }
+       } catch (error) {
+         throw new Error(`Invalid URL "${url}": ${error.message}`);
+       }
+     }
+     return true;
+   },
  },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
mcpServers: {
type: "string[]",
label: "MCP Server URLs",
description:
"Enter your MCP server base URLs. To set one up, visit https://mcp.pipedream.com/ and click “Create new server.",
optional: true,
mcpServers: {
type: "string[]",
label: "MCP Server URLs",
description:
"Enter your MCP server base URLs. To set one up, visit https://mcp.pipedream.com/ and click “Create new server.",
optional: true,
validate: (urls) => {
if (!urls?.length) return true;
for (const url of urls) {
try {
const parsed = new URL(url);
if (!['http:', 'https:'].includes(parsed.protocol)) {
throw new Error(`Invalid protocol: ${parsed.protocol}`);
}
} catch (error) {
throw new Error(`Invalid URL \"${url}\": ${error.message}`);
}
}
return true;
},
},
🤖 Prompt for AI Agents
In
components/openai/actions/chat-with-opeai-responses-api/chat-with-openai-responses-api.mjs
around lines 99 to 104, the MCP server URLs input lacks validation, which could
lead to SSRF vulnerabilities. Implement validation logic to ensure each URL is
well-formed and restrict URLs to a predefined allowlist of trusted domains or
patterns. This can be done by parsing each URL and checking its hostname against
the allowed domains before accepting them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
User submitted Submitted by a user
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants