fix(app): MCP discovery never blocks a turn; secrets masked as lines are written; TTS child gets no MCP secrets
- Discovery runs outside the MCP tool cache's lock (one at a time), so a turn reading the cached tools never waits for a slow server; a new conversation refreshes in the background. - The log hub masks secrets before a line is kept or written, so a key replaced or removed later stays hidden on the screen, in copies, files and exports, also after a restart. - The worker takes JARVIS_MCP_ENV out of its environment at start, before MeloTTS runs, and hands it to the brain. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -37,6 +37,11 @@ def main() -> int:
|
||||
print("JARVIS_VOICE_TOKEN is not set", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
# The MCP servers' secrets leave the environment before any child process (MeloTTS) starts;
|
||||
# only the brain gets them (voice_worker.spec.md, "Tools").
|
||||
from .brain import take_mcp_env
|
||||
mcp_env = take_mcp_env()
|
||||
|
||||
from .server import VoiceWorker, is_loopback
|
||||
from .stt_whisper import WhisperTranscriber
|
||||
from .vad import SileroVad
|
||||
@@ -59,7 +64,8 @@ def main() -> int:
|
||||
history = HistoryStore(args.history)
|
||||
if args.brain:
|
||||
from .brain import JarvisBrain
|
||||
brain = JarvisBrain(language=args.tool_language or None, reply_language=args.reply_language or None)
|
||||
brain = JarvisBrain(language=args.tool_language or None, reply_language=args.reply_language or None,
|
||||
mcp_env=mcp_env)
|
||||
|
||||
async def run() -> None:
|
||||
worker = VoiceWorker(token, transcriber, vad.stream, tts, history=history, brain=brain)
|
||||
|
||||
@@ -152,7 +152,7 @@ MCP_ENV_VAR = "JARVIS_MCP_ENV"
|
||||
V2_HOST_TOOLS = ("localFiles", "screenshot")
|
||||
|
||||
|
||||
def _take_mcp_env() -> dict:
|
||||
def take_mcp_env() -> dict:
|
||||
"""The app's MCP environment, removed from this process's environment so no child process
|
||||
(MCP servers included) inherits another server's secrets."""
|
||||
import json
|
||||
@@ -209,7 +209,8 @@ class JarvisBrain:
|
||||
tool carry-over follows the person who asked.
|
||||
"""
|
||||
|
||||
def __init__(self, language: Optional[str] = "ko", reply_language: Optional[str] = "Korean"):
|
||||
def __init__(self, language: Optional[str] = "ko", reply_language: Optional[str] = "Korean",
|
||||
mcp_env: Optional[dict] = None):
|
||||
from jarvis.config import load_settings
|
||||
from jarvis.memory.db import Database
|
||||
|
||||
@@ -223,7 +224,7 @@ class JarvisBrain:
|
||||
self.cfg = dataclasses.replace(
|
||||
base, tts_engine="melo", stream_browser=False,
|
||||
disabled_tools=tuple(dict.fromkeys((*base.disabled_tools, *V2_HOST_TOOLS))),
|
||||
mcps=_with_mcp_env(base.mcps, _take_mcp_env()))
|
||||
mcps=_with_mcp_env(base.mcps, take_mcp_env() if mcp_env is None else mcp_env))
|
||||
self.db = Database(self.cfg.db_path, self.cfg.sqlite_vss_path)
|
||||
# ``language``: the ISO code tools get (e.g. the Wikipedia host); ``reply_language``: replies
|
||||
# come in it unless the asker explicitly asks for another language (None: the asker's).
|
||||
|
||||
@@ -257,10 +257,13 @@ which carry Discord's own time.
|
||||
registered chat channel asks, so they stay off until M7 brings screen viewing with its own
|
||||
permissions. The jarvis settings' `mcps` are connected on a thread of their own when the brain
|
||||
starts, so a slow server does not hold up the voice; their tools are offered once discovered.
|
||||
Discovery starts the servers, so it runs outside the tool cache's lock: a turn reading the cached
|
||||
tools never waits for a slow server, and a new conversation refreshes the MCP tools in the
|
||||
background (the turn uses the tools already cached; one refresh at a time).
|
||||
The app passes the servers' environment values (secrets) in `JARVIS_MCP_ENV`, JSON `{server:
|
||||
{NAME: value}}`, never in the settings file; the brain removes that variable from its own
|
||||
environment, so no child process inherits it, and adds each server's values to that server's
|
||||
environment only. Each server's outcome is printed without debug logging (category `llm`):
|
||||
{NAME: value}}`, never in the settings file; the worker removes that variable from its
|
||||
environment at start, before any child process (MeloTTS) runs, hands it to the brain, and the
|
||||
brain adds each server's values to that server's environment only. Each server's outcome is printed without debug logging (category `llm`):
|
||||
`MCP server <name>: <n> tool(s)`, or `Warning: MCP server <name> failed: <reason>`.
|
||||
- `prepare` tells the brain that `user` is saying a call whose partial transcript is `text` (the app
|
||||
sends it while the speaker is still talking, `app/src/conversation.spec.md`). The brain runs the
|
||||
|
||||
Reference in New Issue
Block a user