Skip to content

Commit 95ec11f

Browse files
committed
Update examples
1 parent 001db85 commit 95ec11f

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

examples/mcp/agent.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import asyncio
22

33
from coagent.agents import MCPAgent
4+
from coagent.agents.mcp_agent import Prompt
45
from coagent.core import AgentSpec, idle_loop, new, set_stderr_logger
56
from coagent.runtimes import NATSRuntime
67

@@ -9,7 +10,7 @@
910
"mcp",
1011
new(
1112
MCPAgent,
12-
system="""You are an agent who can use tools.""",
13+
system=Prompt(name="system_prompt", arguments={"role": "Weather Reporter"}),
1314
mcp_server_base_url="http://localhost:8080",
1415
),
1516
)

examples/mcp/server.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
mcp = FastMCP("Weather", port=8080)
44

55

6+
@mcp.prompt()
7+
def system_prompt(role: str) -> str:
8+
"""Create a system prompt."""
9+
return f"You are a helpful {role}."
10+
11+
612
@mcp.tool()
713
def query_weather(city: str) -> str:
814
"""Query the weather in the given city."""

0 commit comments

Comments
 (0)