mirror of
https://github.com/EvolutionAPI/adk-python.git
synced 2025-07-14 01:41:25 -06:00
update mcp agent to use latest toolset interface
PiperOrigin-RevId: 756613972
This commit is contained in:
parent
7dffb59096
commit
8c78945ec9
@ -16,29 +16,26 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
from google.adk.agents.llm_agent import LlmAgent
|
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
|
||||||
|
|
||||||
|
root_agent = LlmAgent(
|
||||||
async def create_agent():
|
model='gemini-2.0-flash',
|
||||||
"""Gets tools from MCP Server."""
|
name='enterprise_assistant',
|
||||||
tools, exit_stack = await MCPToolset.from_server(
|
instruction='Help user accessing their file systems',
|
||||||
connection_params=StdioServerParameters(
|
tools=[
|
||||||
command='npx',
|
MCPToolset(
|
||||||
args=[
|
connection_params=StdioServerParameters(
|
||||||
'-y', # Arguments for the command
|
command='npx',
|
||||||
'@modelcontextprotocol/server-filesystem',
|
args=[
|
||||||
os.path.dirname(os.path.abspath(__file__)),
|
'-y', # Arguments for the command
|
||||||
],
|
'@modelcontextprotocol/server-filesystem',
|
||||||
)
|
os.path.dirname(os.path.abspath(__file__)),
|
||||||
)
|
],
|
||||||
|
),
|
||||||
agent = LlmAgent(
|
# don't want agent to do write operation
|
||||||
model='gemini-2.0-flash',
|
tool_predicate=lambda tool, ctx=None: tool.name
|
||||||
name='enterprise_assistant',
|
not in ('write_file', 'edit_file', 'create_directory', 'move_file'),
|
||||||
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