Skip to content

bug: jmp mcp serve crashes with cancel scope RuntimeError in asyncio context #896

Description

@dustinblack

Environment

  • Jumpstarter: release-0.9 branch tip (v0.1.dev1+gfe31f664b)
  • Python: 3.13.13
  • OS: Fedora 43
  • jumpstarter-mcp: installed from release-0.9 branch

Problem

jmp mcp serve crashes when launched as a subprocess from an asyncio application (via MCP stdio transport). The error is:

RuntimeError: Attempted to exit cancel scope in a different task than it was entered in

The traceback points to anyio._backends._asyncio.py line 464.

Reproduction

The MCP server is launched via:

await mcp_client.connect_command(
    command="jmp",
    args=["mcp", "serve"],
    name="jumpstarter",
)

This worked with jumpstarter 0.8.1. With the release-0.9 branch packages, the subprocess starts but the parent process receives a CancelledError, triggering an agent hard-stop.

Context

We use jmp mcp serve to give AI agents access to Jumpstarter device tools (jmp_run, jmp_connect, etc.) via the MCP protocol. The MCP server runs as a stdio subprocess managed by the MCP client library.

Additional notes

  • jmp mcp serve is not included in the install.sh package set — the jumpstarter-mcp package must be installed separately
  • The CLI entry point in jumpstarter_cli/jmp.py conditionally imports MCP — this is working correctly
  • The crash appears to be in the anyio cancel scope handling when the gRPC channel is created inside the MCP server's event loop

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions