MCP
AgentOpera MCP Architecture
Using MCP in AgentOpera
Using StdIO MCP Server
import asyncio
from agentopera.mcp import StdioServerParams, mcp_server_tools
from agentopera.chatflow.agents import AssistantAgent
from agentopera.models.openai import OpenAIChatCompletionClient
from agentopera.core import CancellationToken
async def main():
# Configure file system access
server_params = StdioServerParams(
command="npx",
args=["-y", "@modelcontextprotocol/server-filesystem", "/path/to/files"]
)
# Get all tools from the server
tools = await mcp_server_tools(server_params)
# Create an agent with MCP tools
agent = AssistantAgent(
name="file_manager",
model_client=OpenAIChatCompletionClient(model="gpt-4"),
tools=tools
)
# Use the agent with MCP tools
await agent.run(
task="Create a file called notes.txt with today's date as content",
cancellation_token=CancellationToken()
)
if __name__ == "__main__":
asyncio.run(main())Using SSE MCP Server
Common MCP Servers
Last updated