Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Separate Temporal MCP starter from workflow definition
  • Loading branch information
brianstrauch committed Oct 2, 2026
commit e4378e83b32ae94c15e66c8e8d9b3cb4bbc28e14
6 changes: 3 additions & 3 deletions temporal_mcp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,23 @@ For the in-process transport, start the Worker and Workflow in separate shells:

```bash
uv run worker.py in-process
uv run workflow.py in-process
uv run starter.py in-process
```

The stdio transport uses the same commands. The Worker launches `server.py`
automatically with the current Python interpreter:

```bash
uv run worker.py stdio
uv run workflow.py stdio
uv run starter.py stdio
```

Streamable HTTP needs a third shell for the MCP server:

```bash
uv run server.py streamable-http
uv run worker.py streamable-http
uv run workflow.py streamable-http
uv run starter.py streamable-http
```

The HTTP server defaults to `http://127.0.0.1:8000/mcp`. Use `--host` and
Expand Down
32 changes: 32 additions & 0 deletions temporal_mcp/starter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""Start the durable MCP workflow for a selected transport."""

import argparse
import asyncio
from typing import cast
from uuid import uuid4

from temporalio.client import Client
from temporalio.envconfig import ClientConfig

from workflow import TRANSPORTS, MCPDemoWorkflow, Transport, task_queue


async def main(transport: Transport) -> None:
config = ClientConfig.load_client_connect_config()
config.setdefault("target_host", "localhost:7233")
client = await Client.connect(**config)

result = await client.execute_workflow(
MCPDemoWorkflow.run,
transport,
id=f"temporal-mcp-{transport}-{uuid4()}",
task_queue=task_queue(transport),
)
print(result)


if __name__ == "__main__":
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("transport", choices=TRANSPORTS)
args = parser.parse_args()
asyncio.run(main(cast(Transport, args.transport)))
28 changes: 1 addition & 27 deletions temporal_mcp/workflow.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
"""Run a workflow that uses every durable MCP operation."""
"""Workflow that uses every durable MCP operation."""

import argparse
import asyncio
from dataclasses import dataclass
from datetime import timedelta
from typing import Literal, cast
from uuid import uuid4

from mcp.types import TextContent, TextResourceContents
from temporalio import workflow
from temporalio.client import Client
from temporalio.common import RetryPolicy
from temporalio.envconfig import ClientConfig
from temporalio.mcp import TemporalMCPClient

Transport = Literal["in-process", "stdio", "streamable-http"]
Expand Down Expand Up @@ -76,24 +71,3 @@ async def run(self, transport: Transport) -> MCPDemoResult:
TextResourceContents, template_resource.contents[0]
).text,
)


async def main(transport: Transport) -> None:
config = ClientConfig.load_client_connect_config()
config.setdefault("target_host", "localhost:7233")
client = await Client.connect(**config)

result = await client.execute_workflow(
MCPDemoWorkflow.run,
transport,
id=f"temporal-mcp-{transport}-{uuid4()}",
task_queue=task_queue(transport),
)
print(result)


if __name__ == "__main__":
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("transport", choices=TRANSPORTS)
args = parser.parse_args()
asyncio.run(main(cast(Transport, args.transport)))
Loading