-
Notifications
You must be signed in to change notification settings - Fork 134
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
I am using python_a2a version 0.5.9, I am trying to use to_langchain_tool from python_a2a.langchain package but I am getting following error while trying to convert a MCP Server to langchain tool
Error:
MCPToolConversionError Traceback (most recent call last)
File ~/Documents/project/venv/lib/python3.12/site-packages/python_a2a/langchain/mcp.py:492, in to_langchain_tool(mcp_url, tool_name)
491 if tools_response.status_code != 200:
--> 492 raise MCPToolConversionError(f"Failed to get tools from MCP server: {tools_response.status_code}")
494 available_tools = tools_response.json()
MCPToolConversionError: Failed to get tools from MCP server: 404
During handling of the above exception, another exception occurred:
MCPToolConversionError Traceback (most recent call last)
Cell In[2], line 2
1 from python_a2a.langchain import to_langchain_tool
----> 2 add = to_langchain_tool("http://localhost:8080/mcp", "add")
3 print(add)
File ~/Documents/project/venv/lib/python3.12/site-packages/python_a2a/langchain/mcp.py:498, in to_langchain_tool(mcp_url, tool_name)
496 except Exception as e:
497 logger.error(f"Error getting tools from MCP server: {e}")
--> 498 raise MCPToolConversionError(f"Failed to get tools from MCP server: {str(e)}")
500 # Filter tools if a specific tool is requested
501 if tool_name is not None:
MCPToolConversionError: Failed to get tools from MCP server: Failed to get tools from MCP server: 404
which basically means that it's unable to find the MCP Server path
Following is my code for MCP Server:
add_mcp.py
from fastmcp import FastMCP
mcp = FastMCP("Demo", stateless_http=True)
@mcp.tool
def add(a: int, b:int) -> int:
print(a + b)
return a + b
if __name__ == "__main__":
mcp.run()
I am able to use fastmcp.client to call the MCP Server, here is the code for that
from fastmcp.client import Client
client = Client("http://localhost:8080/mcp")
async with client:
tools = await client.list_tools()
print(tools)
result = await client.call_tool("add", arguments={"a": 10, "b": 20})
print(result.content)
Am I making any mistake while using the python_a2a package for converting MCP Server to langchain tools ?
Following are the version details:
fastmcp==2.10.5
langchain==0.3.26
langchain-anthropic==0.3.17
langchain-core==0.3.69
langchain-mcp-adapters==0.1.9
langchain-ollama==0.3.5
langchain-tavily==0.2.10
langchain-text-splitters==0.3.8
python-a2a==0.5.9
I also tried using LangChainBridge from python_a2a.langchain as per these docs: https://python-a2a.readthedocs.io/en/latest/guides/langchain.html but it got Import error:
>>> from python_a2a.langchain import LangChainBridge
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'LangChainBridge' from 'python_a2a.langchain' (/home/jayant/Documents/project/venv/lib/python3.12/site-packages/python_a2a/langchain/__init__.py)
>>> exit()
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working