Skip to content

Commit 1654319

Browse files
committed
Update README
1 parent 4eca5c9 commit 1654319

File tree

1 file changed

+51
-1
lines changed

1 file changed

+51
-1
lines changed

README.md

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ if __name__ == "__main__":
166166
asyncio.run(main())
167167
```
168168

169-
### 4. Configure Your MCP Client
169+
### 5. Configure Your MCP Client
170170

171171
Add to your MCP client configuration (e.g., Claude Desktop):
172172

@@ -181,6 +181,56 @@ Add to your MCP client configuration (e.g., Claude Desktop):
181181
}
182182
```
183183

184+
### 6. Make MCP calls from a Temporal workflow
185+
186+
```python
187+
import asyncio
188+
import uuid
189+
190+
from mcp import ClientSession
191+
from nexusmcp import WorkflowNexusTransport
192+
from pydantic import BaseModel
193+
from temporalio import workflow
194+
from temporalio.client import Client
195+
from temporalio.contrib.pydantic import pydantic_data_converter
196+
from temporalio.worker import Worker
197+
198+
199+
class AgentWorkflowInput(BaseModel):
200+
endpoint: str
201+
202+
203+
@workflow.defn(sandboxed=False)
204+
class AgentWorkflow:
205+
@workflow.run
206+
async def run(self, input: AgentWorkflowInput):
207+
transport = WorkflowNexusTransport(input.endpoint)
208+
async with transport.connect() as (read_stream, write_stream):
209+
async with ClientSession(read_stream, write_stream) as session:
210+
await session.initialize()
211+
list_tools_result = await session.list_tools()
212+
print(f"available tools: {list_tools_result}")
213+
214+
215+
async def main():
216+
client = await Client.connect(
217+
"localhost:7233",
218+
data_converter=pydantic_data_converter,
219+
)
220+
221+
async with Worker(
222+
client,
223+
task_queue="agent-workflow",
224+
workflows=[AgentWorkflow],
225+
) as worker:
226+
await client.execute_workflow(
227+
AgentWorkflow.run,
228+
AgentWorkflowInput(endpoint="mcp-gateway"),
229+
id=str(uuid.uuid4()),
230+
task_queue=worker.task_queue,
231+
)
232+
```
233+
184234
## Usage Examples
185235

186236
### Tool Filtering

0 commit comments

Comments
 (0)