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)
|
McpPlatformProvider.from_platform_middleware(app, pmw)
|
||||||
McpRuntimeProvider.create(app)
|
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__":
|
if __name__ == "__main__":
|
||||||
app.run()
|
app.run()
|
||||||
|
|||||||
@ -370,9 +370,9 @@ if __name__ == "__main__":
|
|||||||
f.write(flowgraph_code)
|
f.write(flowgraph_code)
|
||||||
script_path = f.name
|
script_path = f.name
|
||||||
|
|
||||||
# Run in Docker
|
# Run in Docker (use local gnuradio-runtime image)
|
||||||
container = self._docker_mw._client.containers.run(
|
container = self._docker_mw._client.containers.run(
|
||||||
image="gnuradio/gnuradio:latest",
|
image="gnuradio-runtime:latest",
|
||||||
command=f"python3 /test/script.py",
|
command=f"python3 /test/script.py",
|
||||||
volumes={script_path: {"bind": "/test/script.py", "mode": "ro"}},
|
volumes={script_path: {"bind": "/test/script.py", "mode": "ro"}},
|
||||||
detach=True,
|
detach=True,
|
||||||
|
|||||||
@ -7,6 +7,7 @@ minimize context usage when block development features aren't needed.
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
from typing import Any, Callable
|
from typing import Any, Callable
|
||||||
|
|
||||||
from fastmcp import FastMCP
|
from fastmcp import FastMCP
|
||||||
@ -37,18 +38,22 @@ class McpBlockDevProvider:
|
|||||||
- When disabled: block dev tools are removed
|
- When disabled: block dev tools are removed
|
||||||
|
|
||||||
This keeps the tool list small when only doing flowgraph design.
|
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__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
mcp_instance: FastMCP,
|
mcp_instance: FastMCP,
|
||||||
block_dev_provider: BlockDevProvider,
|
block_dev_provider: BlockDevProvider,
|
||||||
|
auto_enable: bool = False,
|
||||||
):
|
):
|
||||||
"""Initialize the MCP block development provider.
|
"""Initialize the MCP block development provider.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
mcp_instance: FastMCP app instance
|
mcp_instance: FastMCP app instance
|
||||||
block_dev_provider: Business logic provider
|
block_dev_provider: Business logic provider
|
||||||
|
auto_enable: Register block dev tools at startup
|
||||||
"""
|
"""
|
||||||
self._mcp = mcp_instance
|
self._mcp = mcp_instance
|
||||||
self._provider = block_dev_provider
|
self._provider = block_dev_provider
|
||||||
@ -57,6 +62,16 @@ class McpBlockDevProvider:
|
|||||||
self._init_mode_tools()
|
self._init_mode_tools()
|
||||||
self._init_resources()
|
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):
|
def _init_mode_tools(self):
|
||||||
"""Register mode control tools at startup."""
|
"""Register mode control tools at startup."""
|
||||||
|
|
||||||
@ -488,12 +503,14 @@ class McpBlockDevProvider:
|
|||||||
cls,
|
cls,
|
||||||
mcp_instance: FastMCP,
|
mcp_instance: FastMCP,
|
||||||
flowgraph_mw=None,
|
flowgraph_mw=None,
|
||||||
|
auto_enable: bool = False,
|
||||||
) -> McpBlockDevProvider:
|
) -> McpBlockDevProvider:
|
||||||
"""Factory: create provider with optional Docker support.
|
"""Factory: create provider with optional Docker support.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
mcp_instance: FastMCP app instance
|
mcp_instance: FastMCP app instance
|
||||||
flowgraph_mw: Optional FlowGraphMiddleware for block injection
|
flowgraph_mw: Optional FlowGraphMiddleware for block injection
|
||||||
|
auto_enable: Register block dev tools at startup
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Configured McpBlockDevProvider instance.
|
Configured McpBlockDevProvider instance.
|
||||||
@ -503,4 +520,4 @@ class McpBlockDevProvider:
|
|||||||
flowgraph_mw=flowgraph_mw,
|
flowgraph_mw=flowgraph_mw,
|
||||||
docker_mw=docker_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