Skip to content

Instantly share code, notes, and snippets.

View ramendrasingla's full-sized avatar
🎯
Focusing

Ramendra Singla ramendrasingla

🎯
Focusing
View GitHub Profile
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(
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}
)
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",