for assorted things
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 5b081cb41e659e0896ddf9d51e07b586121c3234 62 lines 1.6 kB view raw
1#!/usr/bin/env -S uv run --script --quiet 2# /// script 3# requires-python = ">=3.12" 4# dependencies = ["marvin@git+https://github.com/prefecthq/marvin.git"] 5# /// 6""" 7Make some change to my phillips hue network of lights via agent + MCP server. 8 9Usage: 10 11```bash 12./update-lights -m "turn on sahara in the living room and nightlight in the kitchen" 13``` 14""" 15 16import marvin 17import argparse 18from pydantic_settings import BaseSettings, SettingsConfigDict 19from pydantic import Field 20from pydantic_ai.mcp import MCPServerStdio 21from pydantic_ai.models import KnownModelName 22 23 24class Settings(BaseSettings): 25 model_config = SettingsConfigDict(env_file=".env", extra="ignore") 26 27 hue_bridge_ip: str = Field(default=...) 28 hue_bridge_username: str = Field(default=...) 29 30 ai_model: KnownModelName = Field(default="gpt-4o") 31 32 33settings = Settings() 34 35hub_mcp = MCPServerStdio( 36 command="uvx", 37 args=[ 38 "smart-home@git+https://github.com/jlowin/fastmcp.git#subdirectory=examples/smart_home" 39 ], 40 env={ 41 "HUE_BRIDGE_IP": settings.hue_bridge_ip, 42 "HUE_BRIDGE_USERNAME": settings.hue_bridge_username, 43 }, 44) 45 46 47if __name__ == "__main__": 48 parser = argparse.ArgumentParser(description="Send a command to the Marvin agent.") 49 parser.add_argument( 50 "--message", 51 "-m", 52 type=str, 53 default="turn off all the lights", 54 help="The message to send to the agent (defaults to 'turn off all the lights').", 55 ) 56 args = parser.parse_args() 57 58 agent = marvin.Agent( 59 model=settings.ai_model, 60 mcp_servers=[hub_mcp], 61 ) 62 agent.run(str(args.message))