I use mcp as below. But i wanna choose which tools...
# ask-ai
c
I use mcp as below. But i wanna choose which tools can be used in the mcp server. How can achieve it
Copy code
class AppointmentRemainderAssistant(Agent):
    def __init__(self, system_prompt: str, call_tracker: dict) -> None:
        super().__init__(
            instructions=system_prompt,
            mcp_servers=[
                mcp.MCPServerHTTP(
                    url="<http://localhost:8080/sse>"
                )       
            ]    
        )
        self.call_tracker = call_tracker
t
Thanks for reaching out, Yusuf. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Could you please help me understand a bit more about what you mean by "choosing which tools can be used in the MCP server"? Are you thinking about certain features, APIs, or maybe external integrations? I want to make sure I give you the best guidance possible!
c
mcp server server for example 20 tools. But i wanna attach 3 of them to the agent
t
To help you attach specific tools to your agent from an MCP server, you have the option to configure the tools dynamically or selectively register them. Let me walk you through how you can do this: 1. Dynamic Tool Preparation:
Copy code
from mcp_client.agent_tools import MCPToolsIntegration
from mcp_client.server import MCPServerSse

# Create MCP server instance
mcp_server = MCPServerSse(
    params={"url": os.environ.get("MCP_SERVER_URL")},
    name="SSE MCP Server"
)

# Prepare and register tools dynamically
prepared_tools = await MCPToolsIntegration.prepare_dynamic_tools([mcp_server])
2. Register Tools with Agent:
Copy code
await MCPToolsIntegration.register_with_agent(agent, [mcp_server])
3. Create Agent with Selected Tools:
Copy code
agent = await MCPToolsIntegration.create_agent_with_tools(
    agent_class=FunctionAgent,
    mcp_servers=[mcp_server]
)
Using these steps, you can easily pick and attach just the tools you need from the MCP server to your agent. If you have any questions or need a hand with this, please don’t hesitate to ask—I’m here to help! Sources: README.md | Tool definition and use | LiveKit Docs | Tool definition and use | LiveKit Docs | mcp/agent.py