This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from langchain_core.tools import StructuredTool | |
| # Convert MCP tools to LangChain tools | |
| langchain_tools = [] | |
| for mcp_tool in tools_list.tools: | |
| async def tool_func(_tool_name=mcp_tool.name, **kwargs): | |
| result = await self.session.call_tool(_tool_name, arguments=kwargs) | |
| return result.content[0].text | |
| lc_tool = StructuredTool.from_function( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from mcp import ClientSession, StdioServerParameters | |
| from mcp.client.stdio import stdio_client | |
| # Define how to spawn the server | |
| server_params = StdioServerParameters( | |
| command=sys.executable, | |
| args=["path/to/mcp_server.py"], | |
| env={**os.environ} | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from mcp.server import Server | |
| from mcp.types import Tool, TextContent | |
| app = Server("cricket-query-server") | |
| @app.list_tools() | |
| async def list_tools() -> list[Tool]: | |
| return [ | |
| Tool( | |
| name="execute_sql", |