Hi folks been trying to run a crew using tools from a MCP server with Streamable-Http as a transport. Although works well enough with the same server when i change the transport of server to SSE without giving any transport argument in my ServerParam. Also this code is in crew template using CrewBase. Here’s the code
from crewai import Agent, Crew, Process, Task
from crewai.project import CrewBase, agent, crew, task
from crewai.agents.agent_builder.base_agent import BaseAgent
from typing import List
import os
from crewai import Agent, Crew, Process, Task,LLM
from crewai.project import CrewBase, agent, crew, task
from crewai.agents.agent_builder.base_agent import BaseAgent
from typing import List, Optional,Dict,Any,Literal
from pydantic import BaseModel
from crewai_tools import MCPServerAdapter
from dotenv import load_dotenv
load_dotenv()
token="jfdnksah"
# Initialize the LLM using environment variables
llm = LLM(
model="azure/gpt-4o"
)
@CrewBase
class Crew():
""" crew"""
agents_config="config/agents.yaml"
task_config="config/tasks.yaml"
def __init__(self):
super().__init__()
self._start_mcp()
def _start_mcp(self):
server_params = {
"url": "http://localhost:80o0/mcp/",
"transport": "streamable-http",
"headers": {
"Authorization": f"Bearer {token}"
}
}
self.mcp_adapter = MCPServerAdapter(server_params)
self.mcp_tools = self.mcp_adapter.tools
for tool in self.mcp_tools:
print(f"Loaded tool: {tool.name}")
@agent
def snow_manager(self) -> Agent:
return Agent(
config=self.agents_config['manager'], # type: ignore[index]
verbose=True,
llm=llm,
tools=self.mcp_tools
)
@task
def research_task(self) -> Task:
return Task(
config=self.tasks_config['task'],
)
@crew
def crew(self) -> Crew:
"""Creates the SnowCrew crew"""
# To learn how to add knowledge sources to your crew, check out the documentation:
# https://docs.crewai.com/concepts/knowledge#what-is-knowledge
return Crew(
agents=self.agents, # Automatically created by the @agent decorator
tasks=self.tasks, # Automatically created by the @task decorator
process=Process.sequential,
verbose=True,
chat_llm=llm
)
The error i am recieving is
Exception in thread Thread-3 (_run_loop):
Traceback (most recent call last):
File "C:\Users\850081290\AppData\Local\Programs\Python\Python311\Lib\threading.py", line 1045, in _bootstrap_inner
self.run()
File "C:\Users\850081290\AppData\Local\Programs\Python\Python311\Lib\threading.py", line 982, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\850081290\Documents\New folder\gen1\Lib\site-packages\mcpadapt\core.py", line 216, in _run_loop
self.loop.run_until_complete(self.task)
File "C:\Users\850081290\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 654, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "C:\Users\850081290\Documents\New folder\gen1\Lib\site-packages\mcpadapt\core.py", line 206, in setup
connections = [
^
File "C:\Users\850081290\Documents\New folder\gen1\Lib\site-packages\mcpadapt\core.py", line 207, in <listcomp>
await stack.enter_async_context(mcptools(params))
File "C:\Users\850081290\AppData\Local\Programs\Python\Python311\Lib\contextlib.py", line 650, in enter_async_context
result = await _enter(cm)
^^^^^^^^^^^^^^^^
File "C:\Users\850081290\AppData\Local\Programs\Python\Python311\Lib\contextlib.py", line 210, in __aenter__
return await anext(self.gen)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\850081290\Documents\New folder\gen1\Lib\site-packages\mcpadapt\core.py", line 98, in mcptools
client = sse_client(**serverparams)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\850081290\AppData\Local\Programs\Python\Python311\Lib\contextlib.py", line 334, in helper
return _AsyncGeneratorContextManager(func, args, kwds)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\850081290\AppData\Local\Programs\Python\Python311\Lib\contextlib.py", line 105, in __init__
self.gen = func(*args, **kwds)
^^^^^^^^^^^^^^^^^^^
TypeError: sse_client() got an unexpected keyword argument 'transport'
Everything in this code works fine with sse as transport without giving any transport argument but as soon as the transport is defined as streamable-http in server param its throws an error. Also gives 400 Bad Request if no transport with streamble-http server url given. Please help.