mirror of
https://github.com/EvolutionAPI/adk-python.git
synced 2025-07-13 23:17:35 -06:00
update mcp agent to use latest toolset interface
PiperOrigin-RevId: 756613972
This commit is contained in:
parent
7dffb59096
commit
8c78945ec9
@ -16,12 +16,15 @@
|
||||
import os
|
||||
|
||||
from google.adk.agents.llm_agent import LlmAgent
|
||||
from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset, StdioServerParameters
|
||||
from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset
|
||||
from google.adk.tools.mcp_tool.mcp_toolset import StdioServerParameters
|
||||
|
||||
|
||||
async def create_agent():
|
||||
"""Gets tools from MCP Server."""
|
||||
tools, exit_stack = await MCPToolset.from_server(
|
||||
root_agent = LlmAgent(
|
||||
model='gemini-2.0-flash',
|
||||
name='enterprise_assistant',
|
||||
instruction='Help user accessing their file systems',
|
||||
tools=[
|
||||
MCPToolset(
|
||||
connection_params=StdioServerParameters(
|
||||
command='npx',
|
||||
args=[
|
||||
@ -29,16 +32,10 @@ async def create_agent():
|
||||
'@modelcontextprotocol/server-filesystem',
|
||||
os.path.dirname(os.path.abspath(__file__)),
|
||||
],
|
||||
),
|
||||
# don't want agent to do write operation
|
||||
tool_predicate=lambda tool, ctx=None: tool.name
|
||||
not in ('write_file', 'edit_file', 'create_directory', 'move_file'),
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
agent = LlmAgent(
|
||||
model='gemini-2.0-flash',
|
||||
name='enterprise_assistant',
|
||||
instruction='Help user accessing their file systems',
|
||||
tools=tools,
|
||||
)
|
||||
return agent, exit_stack
|
||||
|
||||
|
||||
root_agent = create_agent()
|
||||
|
Loading…
Reference in New Issue
Block a user