fix: use local gnuradio-runtime image for Docker testing
- Change test_block_in_docker to use gnuradio-runtime:latest instead of non-existent gnuradio/gnuradio:latest - Add auto_enable option to McpBlockDevProvider to register block dev tools at startup (avoids MCP reconnect dance) - Support GR_MCP_BLOCK_DEV=1 env var for auto-enabling
This commit is contained in:
parent
5db7d71d2b
commit
84db5a9000
2
main.py
2
main.py
@ -45,7 +45,7 @@ for path in oot_candidates:
|
||||
|
||||
McpPlatformProvider.from_platform_middleware(app, pmw)
|
||||
McpRuntimeProvider.create(app)
|
||||
McpBlockDevProvider.create(app) # flowgraph_mw set when flowgraph is loaded
|
||||
McpBlockDevProvider.create(app, auto_enable=True) # Tools always available
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run()
|
||||
|
||||
@ -370,9 +370,9 @@ if __name__ == "__main__":
|
||||
f.write(flowgraph_code)
|
||||
script_path = f.name
|
||||
|
||||
# Run in Docker
|
||||
# Run in Docker (use local gnuradio-runtime image)
|
||||
container = self._docker_mw._client.containers.run(
|
||||
image="gnuradio/gnuradio:latest",
|
||||
image="gnuradio-runtime:latest",
|
||||
command=f"python3 /test/script.py",
|
||||
volumes={script_path: {"bind": "/test/script.py", "mode": "ro"}},
|
||||
detach=True,
|
||||
|
||||
@ -7,6 +7,7 @@ minimize context usage when block development features aren't needed.
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import os
|
||||
from typing import Any, Callable
|
||||
|
||||
from fastmcp import FastMCP
|
||||
@ -37,18 +38,22 @@ class McpBlockDevProvider:
|
||||
- When disabled: block dev tools are removed
|
||||
|
||||
This keeps the tool list small when only doing flowgraph design.
|
||||
|
||||
Set GR_MCP_BLOCK_DEV=1 to auto-enable block dev tools at startup.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
mcp_instance: FastMCP,
|
||||
block_dev_provider: BlockDevProvider,
|
||||
auto_enable: bool = False,
|
||||
):
|
||||
"""Initialize the MCP block development provider.
|
||||
|
||||
Args:
|
||||
mcp_instance: FastMCP app instance
|
||||
block_dev_provider: Business logic provider
|
||||
auto_enable: Register block dev tools at startup
|
||||
"""
|
||||
self._mcp = mcp_instance
|
||||
self._provider = block_dev_provider
|
||||
@ -57,6 +62,16 @@ class McpBlockDevProvider:
|
||||
self._init_mode_tools()
|
||||
self._init_resources()
|
||||
|
||||
# Auto-enable via parameter or environment variable
|
||||
if auto_enable or os.environ.get("GR_MCP_BLOCK_DEV", "").lower() in (
|
||||
"1",
|
||||
"true",
|
||||
"yes",
|
||||
):
|
||||
self._register_block_dev_tools()
|
||||
self._block_dev_enabled = True
|
||||
logger.info("Block dev mode auto-enabled at startup")
|
||||
|
||||
def _init_mode_tools(self):
|
||||
"""Register mode control tools at startup."""
|
||||
|
||||
@ -488,12 +503,14 @@ class McpBlockDevProvider:
|
||||
cls,
|
||||
mcp_instance: FastMCP,
|
||||
flowgraph_mw=None,
|
||||
auto_enable: bool = False,
|
||||
) -> McpBlockDevProvider:
|
||||
"""Factory: create provider with optional Docker support.
|
||||
|
||||
Args:
|
||||
mcp_instance: FastMCP app instance
|
||||
flowgraph_mw: Optional FlowGraphMiddleware for block injection
|
||||
auto_enable: Register block dev tools at startup
|
||||
|
||||
Returns:
|
||||
Configured McpBlockDevProvider instance.
|
||||
@ -503,4 +520,4 @@ class McpBlockDevProvider:
|
||||
flowgraph_mw=flowgraph_mw,
|
||||
docker_mw=docker_mw,
|
||||
)
|
||||
return cls(mcp_instance, provider)
|
||||
return cls(mcp_instance, provider, auto_enable=auto_enable)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user