Skip to content

Commit 567a6e7

Browse files
committed
feat: dual mode should also support mock
Signed-off-by: vsoch <vsoch@users.noreply.github.com>
1 parent 3673ed7 commit 567a6e7

4 files changed

Lines changed: 24 additions & 18 deletions

File tree

mcpserver/cli/args.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,14 @@ def populate_start_args(start):
121121
# const=True is what we get if the flag is present but no value is given
122122
# default=False is what we get if the flag is totally absent
123123
# THe user can also ask for an archetype (hpc, cloud, standalone)
124-
worker_group.add_argument(
125-
"--mock",
126-
nargs="?",
127-
const=True,
128-
default=False,
129-
help="Start a mock worker. Can optionally select hpc, cloud, or standalone",
130-
)
124+
for group in worker_group, hub_group:
125+
group.add_argument(
126+
"--mock",
127+
nargs="?",
128+
const=True,
129+
default=False,
130+
help="Start a mock worker. Can optionally select hpc, cloud, or standalone",
131+
)
131132

132133
# Agent Reasoning Group
133134
agent_group = start.add_argument_group("🧠 Agent Reasoning")

mcpserver/core/base.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
import json
33
import time
44

5+
from resource_secretary.providers import discover_providers
6+
from resource_secretary.providers.mock import discover_mock_providers
7+
58
import mcpserver.utils as utils
9+
from mcpserver.logger import logger
610

711

812
class WorkerBase:
@@ -12,6 +16,17 @@ class WorkerBase:
1216
its dual mode (acting as worker AND hub.)
1317
"""
1418

19+
def init_providers(self, mock=False):
20+
"""
21+
Probe the local system on startup. E.g., "we found spack, flux, etc."
22+
These can be faux (mock) or real discovered providers
23+
"""
24+
logger.info("📡 Probing local system for resource providers...")
25+
if mock:
26+
self.catalog = discover_mock_providers(self.worker_id, choice=mock)
27+
else:
28+
self.catalog = discover_providers()
29+
1530
def register_agent_tools(self):
1631
"""
1732
Registers the core negotiation tools with the FastMCP instance.

mcpserver/core/hub.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ def __init__(self, *args, **kwargs):
397397
# Calls super on the HubManager. WorkerBase has no init
398398
super().__init__(*args, **kwargs)
399399
self.setup_dual()
400+
self.init_providers(kwargs.get("mock", False))
400401

401402
def setup_dual(self):
402403
"""

mcpserver/core/worker.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,6 @@ def __init__(
4747
# Register MCP Tools automatically
4848
self.register_agent_tools()
4949

50-
def init_providers(self, mock=False):
51-
"""
52-
Probe the local system on startup. E.g., "we found spack, flux, etc."
53-
These can be faux (mock) or real discovered providers
54-
"""
55-
logger.info("📡 Probing local system for resource providers...")
56-
if mock:
57-
self.catalog = discover_mock_providers(self.worker_id, choice=mock)
58-
else:
59-
self.catalog = discover_providers()
60-
6150
def show(self):
6251
"""
6352
Show providers installed and verbosity.

0 commit comments

Comments
 (0)