-
Notifications
You must be signed in to change notification settings - Fork 923
feat: Tools integrations for others SDKs [WIP] #284
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
base: main
Are you sure you want to change the base?
Conversation
- Move common functions to base adapter - Create initial documentation for OpenAI integration - Develop OpenAIMCPAdapter and related example
|
||
# Create LangChain tools using the adapter with connectors | ||
self._tools = await self.adapter._create_tools_from_connectors(connectors_to_use) | ||
await self.adapter._create_tools_from_connectors(connectors_to_use) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way we can have these be called inside the functions and have adapter.tools always callable and fresh ?
So that there is not implicit ordering of operations, one here might not know that create_tools_from_connectors must be called and try directly .tools, and be disappointed because tools won't be there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pietrozullo you mean when you call adapter.tools you get already the operations done?
@renvins I think here we could also add Langchain, Langgraph even though it is quite obvious if one looks at MCPagent. Got this from here https://github.com/orgs/mcp-use/discussions/139 |
@pietrozullo Don’t we already have the langchain one? We can do the one for langgraph! |
I think it is okay to be redundant and show how to integrate with both, in some sense our agent is not an integration, is a custom integration. It is okay to show how to integrate with langchain more in general as well in other words, like how to use the adapter and not the agent. |
Clear, maybe we can use the existing adapter to build an example. @pietrozullo |
I was looking into this, if I were a user of from mcp_use.adapters import OpenAIAdapter
from openai import OpenAI
adapter = OpenAIAdapter(client)
openai = OpenAI()
messages = [{"role": "user", "content": "Please tell me the cheapest pisci spada for two people in Levanzo."}
response = openai.chat.completions.create(model="gpt-4o", messages=messages, tools=adapter.tools) what do you think? Can we modify the API ? |
@pietrozullo I will have a look into this. I think that if we want apply this to the base adapter we need a refactoring of the MCPAgent. Please have a look at it in the part of the ONLY connectors init of the agent etc. Because we should force to pass a client to the LangChain adapter. Let me know! |
Pull Request Description
This pull request introduces the first of our new integration adapters, allowing
mcp-use
to be used directly with other SDKs. This marks a significant step towards makingmcp-use
a universal tool provider that can plug into various LLM ecosystems beyond LangChain.The initial part of this change is the
OpenAIMCPAdapter
, which handles the conversion of MCP tools into the format expected by OpenAI's tool-calling API. This allows developers to leverage the power of MCP servers while working directly with OpenAI's native tools.Key Changes:
OpenAIMCPAdapter
: Addedmcp_use/adapters/openai.py
to manage the conversion of MCP tools to the OpenAI format.examples/openai_integration_example.py
to demonstrate how to use the new adapter.docs/integration/openai.mdx
.Usage Example (`examples/openai_integration_example.py`)
Future Integrations
This PR establishes a pattern that we will follow to create adapters for other major LLM providers. Work will begin shortly on similar integrations for:
By providing these adapters, we aim to offer developers maximum flexibility in how they build their agents and applications with
mcp-use
.