Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
34 changes: 34 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: CI

on:
pull_request:
push:
branches: [ main ]

jobs:
lint-test-docs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ['3.13']
os: [ubuntu-latest]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v6
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
uv sync

- name: Lint and type check
run: uv run poe lint

- name: Run tests
run: |
uv run pytest
4 changes: 2 additions & 2 deletions nexusmcp/service_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
- Decorators for controlling which operations are exposed as MCP tools
"""

import logging
import re
from collections.abc import Callable
from dataclasses import dataclass
from typing import Any
import re
import logging

import mcp.types
import nexusrpc
Expand Down
6 changes: 3 additions & 3 deletions nexusmcp/workflow_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ async def connect(
self,
) -> AsyncGenerator[
tuple[
anyio.streams.memory.MemoryObjectReceiveStream[SessionMessage],
anyio.streams.memory.MemoryObjectSendStream[SessionMessage],
anyio.streams.memory.MemoryObjectReceiveStream[SessionMessage], # pyright: ignore[reportAttributeAccessIssue]
anyio.streams.memory.MemoryObjectSendStream[SessionMessage], # pyright: ignore[reportAttributeAccessIssue]
],
None,
]:
Expand Down Expand Up @@ -119,7 +119,7 @@ async def _handle_list_tools(self) -> types.ListToolsResult:
return types.ListToolsResult(tools=tools)

async def _handle_call_tool(self, params: types.CallToolRequestParams) -> types.CallToolResult:
service, _, operation = params.name.partition("/")
service, _, operation = params.name.partition("_")
nexus_client = workflow.create_nexus_client(
endpoint=self.endpoint,
service=service,
Expand Down
18 changes: 16 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ dependencies = [

[dependency-groups]
dev = [
"pytest>=8.4.1",
"mypy>=1.13.0",
"poethepoet>=0.35.0",
"pyright>=1.1",
"pytest-asyncio>=1.1.0",
"pytest>=8.4.1",
"ruff>=0.8.0",
"mypy>=1.13.0",
]

[tool.pytest.ini_options]
Expand All @@ -41,5 +43,17 @@ indent-style = "space"
python_version = "3.13"
strict = true

[tool.poe.tasks]
lint = [
{cmd = "uv run pyright"},
{cmd = "uv run mypy --check-untyped-defs ."},
{cmd = "uv run ruff check --select I"},
{cmd = "uv run ruff format --check"},
]
format = [
{cmd = "uv run ruff check --select I --fix"},
{cmd = "uv run ruff format"},
]

[tool.uv.sources]
temporalio = { git = "https://github.com/temporalio/sdk-python" }
10 changes: 5 additions & 5 deletions tests/test_inbound_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ async def test_inbound_gateway() -> None:


async def call_tool(
read_stream: anyio.streams.memory.MemoryObjectReceiveStream[SessionMessage],
write_stream: anyio.streams.memory.MemoryObjectSendStream[SessionMessage],
read_stream: anyio.streams.memory.MemoryObjectReceiveStream[SessionMessage], # pyright: ignore[reportAttributeAccessIssue]
write_stream: anyio.streams.memory.MemoryObjectSendStream[SessionMessage], # pyright: ignore[reportAttributeAccessIssue]
) -> None:
"""Test MCP client connecting via memory streams and calling tools."""
async with ClientSession(read_stream, write_stream) as session:
Expand All @@ -79,8 +79,8 @@ async def call_tool(
print(f"Available tools: {[tool.name for tool in list_tools_result.tools]}")

assert len(list_tools_result.tools) == 2
assert list_tools_result.tools[0].name == "modified-service-name/modified-op-name"
assert list_tools_result.tools[1].name == "modified-service-name/op2"
assert list_tools_result.tools[0].name == "modified-service-name_modified-op-name"
assert list_tools_result.tools[1].name == "modified-service-name_op2"

call_result = await session.call_tool("modified-service-name/modified-op-name", {"name": "World"})
call_result = await session.call_tool("modified-service-name_modified-op-name", {"name": "World"})
assert call_result.structuredContent == {"message": "Hello, World"}
6 changes: 3 additions & 3 deletions tests/test_service.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from nexusrpc.handler import StartOperationContext

from .service import MyInput, TestServiceHandler, mcp_service


Expand All @@ -27,8 +27,8 @@ async def test_list_tools() -> None:
None,
)
assert len(tools) == 2
assert tools[0].name == "modified-service-name/modified-op-name"
assert tools[1].name == "modified-service-name/op2"
assert tools[0].name == "modified-service-name_modified-op-name"
assert tools[1].name == "modified-service-name_op2"
assert tools[0].description == "This is a test operation."
assert tools[1].description == "This is also a test operation."
assert tools[0].inputSchema == MyInput.model_json_schema()
Expand Down
6 changes: 3 additions & 3 deletions tests/test_workflow_caller.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ async def run(self, input: MCPCallerWorkflowInput) -> None:

list_tools_result = await session.list_tools()
assert len(list_tools_result.tools) == 2
assert list_tools_result.tools[0].name == "modified-service-name/modified-op-name"
assert list_tools_result.tools[1].name == "modified-service-name/op2"
assert list_tools_result.tools[0].name == "modified-service-name_modified-op-name"
assert list_tools_result.tools[1].name == "modified-service-name_op2"

call_result = await session.call_tool("modified-service-name/modified-op-name", {"name": "World"})
call_result = await session.call_tool("modified-service-name_modified-op-name", {"name": "World"})
assert call_result.structuredContent == {"message": "Hello, World"}


Expand Down
65 changes: 65 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.