-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from StreetLamb/mcp-dev
- Loading branch information
Showing
19 changed files
with
743 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# MCP Weather Example | ||
|
||
Demostrate how a weather agent can call tools from a MCP server. | ||
|
||
Make sure temporal is running: | ||
```shell | ||
temporal server start-dev | ||
``` | ||
|
||
Run the script: | ||
```shell | ||
python main.py | ||
``` |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import asyncio | ||
import uuid | ||
from temporalio.client import Client | ||
from rojak.agents import OpenAIAgent, OpenAIAgentActivities | ||
from rojak.client import Rojak | ||
from rojak.types import MCPServerConfig, RetryOptions, RetryPolicy | ||
|
||
|
||
async def main(): | ||
client = await Client.connect("localhost:7233") | ||
rojak = Rojak(client=client, task_queue="tasks") | ||
|
||
agent = OpenAIAgent( | ||
name="Weather Agent", | ||
retry_options=RetryOptions(retry_policy=RetryPolicy(maximum_attempts=5)), | ||
) | ||
openai_activities = OpenAIAgentActivities() | ||
worker = await rojak.create_worker( | ||
[openai_activities], | ||
mcp_servers={ | ||
"weather": MCPServerConfig("stdio", "python", ["mcp_weather_server.py"]) | ||
}, | ||
) | ||
try: | ||
async with worker: | ||
response = await rojak.run( | ||
id=str(uuid.uuid4()), | ||
agent=agent, | ||
messages=[ | ||
{ | ||
"role": "user", | ||
"content": "Weather like in San Francisco?", | ||
} | ||
], | ||
debug=True, | ||
) | ||
print(response.messages[-1].content) | ||
finally: | ||
await rojak.cleanup_mcp() | ||
|
||
|
||
if __name__ == "__main__": | ||
asyncio.run(main()) |
Oops, something went wrong.