mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 19:24:27 +00:00
change location of MCP client
This commit is contained in:
parent
50ec2bd5c9
commit
039129676c
5 changed files with 8 additions and 3 deletions
30
litellm/mcp_client/tools.py
Normal file
30
litellm/mcp_client/tools.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
from typing import List, Literal, Union
|
||||
|
||||
from mcp import ClientSession
|
||||
from mcp.types import Tool as MCPTool
|
||||
|
||||
from litellm.types.llms.openai import Tool
|
||||
|
||||
|
||||
def transform_mcp_tool_to_openai_tool(tool: MCPTool) -> Tool:
|
||||
"""Convert an MCP tool to an OpenAI tool."""
|
||||
raise NotImplementedError("Not implemented")
|
||||
|
||||
|
||||
async def load_mcp_tools(
|
||||
session: ClientSession, format: Literal["mcp", "openai"] = "mcp"
|
||||
) -> Union[List[MCPTool], List[Tool]]:
|
||||
"""
|
||||
Load all available MCP tools
|
||||
|
||||
Args:
|
||||
session: The MCP session to use
|
||||
format: The format to convert the tools to
|
||||
By default, the tools are returned in MCP format.
|
||||
|
||||
If format is set to "openai", the tools are converted to OpenAI tools.
|
||||
"""
|
||||
tools = await session.list_tools()
|
||||
if format == "openai":
|
||||
return [transform_mcp_tool_to_openai_tool(tool) for tool in tools.tools]
|
||||
return tools.tools
|
Loading…
Add table
Add a link
Reference in a new issue