Compare commits

...

2 Commits

Author SHA1 Message Date
13c9b97073 Merge branch 'master' of https://git.kurbet.ru/ziabric/hestia 2026-01-23 09:32:26 +03:00
91cdb1328b init 2026-01-23 09:27:23 +03:00
5 changed files with 74 additions and 0 deletions

29
main.py Normal file
View File

@@ -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())

11
mcp_agent.config.yaml Normal file
View File

@@ -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"

2
mcp_agent.secrets.yaml Normal file
View File

@@ -0,0 +1,2 @@
openai:
api_key: "ollama"

3
requirements.txt Normal file
View File

@@ -0,0 +1,3 @@
mcp-agent[openai]
mcp
pydantic

29
weather_mcp.py Normal file
View File

@@ -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()