Skip to main content
Glama

Multi-Agent Tools Platform

agents.py1.61 kB
import asyncio from fastmcp import FastMCP from langchain import Wikipedia from langchain_openai.chat_models.azure import AzureChatOpenAI from langchain_core.tools import tool from langgraph.prebuilt import create_react_agent from mcp.client.fastmcp import FastMCPClient import os llm = AzureChatOpenAI( azure_deployment=os.getenv("AZURE_DEPLOYMENT"), openai_api_version=os.getenv("OPENAI_API_VERSION"), temperature=0.2 ) async def build_client(): return await FastMCPClient({ "tools": { "command": "python", "args": ["tools_server.py"], "transport": "stdio" } }) async def init_research_agent(): client = await build_client() tools = await client.get_tools() return create_react_agent(llm, [tools["search"], tools["wiki"], tools["summarize"]]) async def init_math_agent(): client = await build_client() tools = await client.get_tools() return create_react_agent(llm, [tools["calc"]]) async def init_meteo_agent(): client = await build_client() tools = await client.get_tools() return create_react_agent(llm, [tools["weather"], tools["calc"], tools["search"]]) if __name__ == "__main__": async def demo(): for name, init in [("Research", init_research_agent), ("Math", init_math_agent), ("Meteo", init_meteo_agent)]: agent = await init() resp = await agent.ainvoke({"messages":[{"role":"user","content":f"Example task for {name}"}]}) print(name, "Agent Answer:", resp["messages"][-1].content) asyncio.run(demo())

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kingrishabdugar/MCP_Demo'

If you have feedback or need assistance with the MCP directory API, please join our Discord server