commit 91cdb1328bb787bcf6b5971a635e8e1ba1352c8b Author: ziabric Date: Fri Jan 23 09:27:23 2026 +0300 init diff --git a/main.py b/main.py new file mode 100644 index 0000000..720c3df --- /dev/null +++ b/main.py @@ -0,0 +1,29 @@ +import asyncio + +from mcp_agent.app import MCPApp +from mcp_agent.agents.agent import Agent +from mcp_agent.workflows.llm.augmented_llm_openai import OpenAIAugmentedLLM + + +app = MCPApp(name="weather_agent") + + +async def main(): + async with app.run(): + agent = Agent( + name="weather", + instruction=( + "Ты ассистент по погоде. " + "Если нужны актуальные данные — используй доступные инструменты." + ), + server_names=["weather"], + ) + + async with agent: + llm = await agent.attach_llm(OpenAIAugmentedLLM) + answer = await llm.generate_str("Какая сейчас точная погода в Берлине?") + print(answer) + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/mcp_agent.config.yaml b/mcp_agent.config.yaml new file mode 100644 index 0000000..3ebbd4f --- /dev/null +++ b/mcp_agent.config.yaml @@ -0,0 +1,11 @@ +execution_engine: asyncio + +mcp: + servers: + weather: + command: "python" + args: ["weather_mcp.py"] + +openai: + base_url: "http://localhost:11434/v1" + default_model: "qwen3:1.7b" diff --git a/mcp_agent.secrets.yaml b/mcp_agent.secrets.yaml new file mode 100644 index 0000000..85e481a --- /dev/null +++ b/mcp_agent.secrets.yaml @@ -0,0 +1,2 @@ +openai: + api_key: "ollama" diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..f998705 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +mcp-agent[openai] +mcp +pydantic diff --git a/weather_mcp.py b/weather_mcp.py new file mode 100644 index 0000000..e72a8db --- /dev/null +++ b/weather_mcp.py @@ -0,0 +1,29 @@ +from mcp.server.fastmcp import FastMCP +from pydantic import BaseModel + + +class WeatherResult(BaseModel): + city: str + temperature: int + units: str + condition: str + + +server = FastMCP(name="weather") + + +@server.tool( + name="get_weather", + description="Возвращает актуальную погоду по городу", +) +async def get_weather(city: str, units: str = "metric") -> WeatherResult: + return WeatherResult( + city=city, + temperature=18, + units=units, + condition="partly cloudy", + ) + + +if __name__ == "__main__": + server.run()