Skip to content

Commit 361b7cf

Browse files
committed
Use pydantic data converter everywhere
1 parent c6c5964 commit 361b7cf

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,17 @@ temporal operator nexus endpoint create \
121121
import asyncio
122122

123123
from temporalio.client import Client
124+
from temporalio.contrib.pydantic import pydantic_data_converter
124125
from temporalio.worker import Worker
125126
from .service_handler import mcp_service_handler, CalculatorHandler
126127

127128
async def main():
128129
# Connect to Temporal (replace host and namespace as needed).
129-
client = await Client.connect("localhost:7233", namespace="my-handler-namespace")
130+
client = await Client.connect(
131+
"localhost:7233",
132+
namespace="my-handler-namespace",
133+
data_converter=pydantic_data_converter,
134+
)
130135

131136
async with Worker(
132137
client,
@@ -144,12 +149,17 @@ import asyncio
144149
from mcp.server.lowlevel import NotificationOptions, Server
145150
from mcp.server.models import InitializationOptions
146151
from temporalio.client import Client
152+
from temporalio.contrib.pydantic import pydantic_data_converter
147153
from nexusmcp import InboundGateway
148154

149155
async def main():
150156
server = Server("nexus-mcp-demo")
151157
# Connect to Temporal (replace host and namespace as needed).
152-
client = await Client.connect("localhost:7233", namespace="my-caller-namespace")
158+
client = await Client.connect(
159+
"localhost:7233",
160+
namespace="my-caller-namespace",
161+
data_converter=pydantic_data_converter,
162+
)
153163

154164
# Create the MCP gateway
155165
gateway = InboundGateway(

tests/test_inbound_gateway.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import asyncio
22

33
import anyio
4-
from mcp.shared.message import SessionMessage
54
import pytest
65
from mcp import ClientSession
76
from mcp.server.lowlevel import NotificationOptions, Server
87
from mcp.server.models import InitializationOptions
8+
from mcp.shared.message import SessionMessage
99
from temporalio.api.nexus.v1 import EndpointSpec, EndpointTarget
1010
from temporalio.api.operatorservice.v1 import CreateNexusEndpointRequest
11+
from temporalio.contrib.pydantic import pydantic_data_converter
1112
from temporalio.testing import WorkflowEnvironment
1213
from temporalio.worker import Worker
1314

@@ -23,7 +24,7 @@ async def test_inbound_gateway() -> None:
2324
endpoint_name = "endpoint"
2425
task_queue = "handler-queue"
2526

26-
async with await WorkflowEnvironment.start_local() as env:
27+
async with await WorkflowEnvironment.start_local(data_converter=pydantic_data_converter) as env:
2728
await env.client.operator_service.create_nexus_endpoint(
2829
CreateNexusEndpointRequest(
2930
spec=EndpointSpec(

0 commit comments

Comments
 (0)