+32
-3
update-lights
+32
-3
update-lights
···
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
"""
7
Make some change to my phillips hue network of lights via agent + MCP server.
···
25
from pydantic import Field
26
from pydantic_ai.mcp import MCPServerStdio
27
from pydantic_ai.models import KnownModelName
28
29
30
class Settings(BaseSettings):
···
33
hue_bridge_ip: str = Field(default=...)
34
hue_bridge_username: str = Field(default=...)
35
36
-
ai_model: KnownModelName = Field(default="gpt-4o")
37
38
39
settings = Settings()
40
41
hub_mcp = MCPServerStdio(
42
command="uvx",
···
65
model=settings.ai_model,
66
mcp_servers=[hub_mcp],
67
)
68
-
agent.run(str(args.message))
···
1
#!/usr/bin/env -S uv run --script --quiet
2
# /// script
3
# requires-python = ">=3.12"
4
+
# dependencies = ["marvin>=3.1.0"]
5
# ///
6
"""
7
Make some change to my phillips hue network of lights via agent + MCP server.
···
25
from pydantic import Field
26
from pydantic_ai.mcp import MCPServerStdio
27
from pydantic_ai.models import KnownModelName
28
+
from rich.console import Console
29
+
from rich.panel import Panel
30
+
from rich.prompt import Prompt
31
32
33
class Settings(BaseSettings):
···
36
hue_bridge_ip: str = Field(default=...)
37
hue_bridge_username: str = Field(default=...)
38
39
+
ai_model: KnownModelName = Field(default="gpt-4.1-mini")
40
41
42
settings = Settings()
43
+
console = Console()
44
45
hub_mcp = MCPServerStdio(
46
command="uvx",
···
69
model=settings.ai_model,
70
mcp_servers=[hub_mcp],
71
)
72
+
73
+
console.print(
74
+
Panel.fit(
75
+
f"[bold cyan]🏠 lights agent[/bold cyan]\n"
76
+
f"[dim]model: {settings.ai_model}[/dim]",
77
+
border_style="blue",
78
+
)
79
+
)
80
+
81
+
with marvin.Thread():
82
+
first = True
83
+
while True:
84
+
if first:
85
+
console.print(f"\n[bold yellow]→[/bold yellow] {args.message}")
86
+
agent.run(str(args.message))
87
+
first = False
88
+
else:
89
+
try:
90
+
user_input = Prompt.ask(
91
+
"\n[bold green]enter a message[/bold green]"
92
+
)
93
+
console.print(f"[bold yellow]→[/bold yellow] {user_input}")
94
+
agent.run(str(user_input))
95
+
except KeyboardInterrupt:
96
+
console.print("\n[dim red]exiting...[/dim red]")
97
+
break