odysseus/src
LittleLlama 6b660d43a5 Fix NPX MCP server crash (skip if not installed, alternative shape to #242 / #252) (#253)
* Fix NPX MCP server crash by checking install state instead of timing out

When @playwright/mcp (or any future npx-based built-in server) isn't
already cached, npx tries to download and install it on first invoke.
That can take minutes or hang on a fresh install missing Playwright
system deps. The previous code bounded that wait with
asyncio.wait_for(mcp_manager.connect_server(...), timeout=30), but the
cancellation that wait_for fires on timeout propagates into
mcp.client.stdio.stdio_client's internal anyio task group, which
raises:

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

The error fires in a sibling background task (Task exception was never
retrieved) so the surrounding try/except BaseException doesn't catch
it, and the orphaned cancel scope cascades cancellations into other
tasks in the same event loop. Running requests start failing and the
process needs a restart.

Fix: detect whether the package is already cached before invoking
connect_server, instead of trying to bound the connect with a timeout.
A new _is_npx_package_cached helper runs:

    npx --no-install <pkg> --version

The --no-install flag makes npx fail fast on a cache miss instead of
downloading, so the probe returns in <500ms either way. If the package
isn't cached, we log a warning with the exact command the user can run
to install it, and skip the server. If it is cached, we call
connect_server normally with no wait_for wrapper, so there's no
cancellation that could enter stdio_client's task group.

This removes the entire bug class instead of papering over it. No
asyncio.wait_for around stdio_client, no shielded-task leak, no
shutdown-time RuntimeError. Verified against current versions
(mcp library on Python 3.14, anyio 4.13.0) with the existing
@playwright/mcp@latest cached, and with a deliberately uncached
package spec to exercise the skip path.

* Make first-run setup explicit when NPX MCP package isn't cached

Per @pewdiepie-archdaemon review on #253:

- src/builtin_mcp.py: expand the skip-server warning into a multi-line
  block with Reason/Impact/Fix/Notes lines, so the message stands out
  in startup logs and clearly tells the user what to run.

- README.md: add 'Built-in MCP servers (optional setup)' subsection
  under Configuration, with the install command and a brief note that
  it's optional and skipped if not cached.
2026-06-01 14:23:19 +09:00
..
search Odysseus v1.0 2026-05-31 23:58:26 +09:00
agent_loop.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
agent_runs.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
agent_tools.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
ai_interaction.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
api_key_manager.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
app_helpers.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
app_initializer.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
assistant_log.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
auth_helpers.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
bg_jobs.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
bg_monitor.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
builtin_actions.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
builtin_mcp.py Fix NPX MCP server crash (skip if not installed, alternative shape to #242 / #252) (#253) 2026-06-01 14:23:19 +09:00
caldav_sync.py Fix duplicate CalDAV sync UIDs 2026-06-01 02:17:43 +00:00
chat_handler.py Recognize local vision models so their images aren't dropped (#185) 2026-06-01 13:09:21 +09:00
chat_helpers.py Recognize local vision models so their images aren't dropped (#185) 2026-06-01 13:09:21 +09:00
chat_processor.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
chroma_client.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
cleanup_service.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
config.py Align SearXNG fallback URL 2026-06-01 10:50:07 +09:00
constants.py Align SearXNG fallback URL 2026-06-01 10:50:07 +09:00
context_compactor.py Preserve large pasted messages in context 2026-06-01 12:38:35 +09:00
database.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
deep_research.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
document_actions.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
document_processor.py Fix vision attachment timeout and stale cache 2026-06-01 02:04:46 +00:00
email_thread_parser.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
embeddings.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
endpoint_resolver.py Improve OpenRouter and Groq provider requests 2026-06-01 10:32:14 +09:00
event_bus.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
exceptions.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
goal_based_extractor.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
integrations.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
llm_core.py Improve OpenRouter and Groq provider requests 2026-06-01 10:32:14 +09:00
mcp_manager.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
memory.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
memory_vector.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
model_context.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
model_discovery.py Improve Ollama setup and model endpoint handling 2026-06-01 10:00:15 +09:00
pdf_form_doc.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
pdf_forms.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
personal_docs.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
preset_manager.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
prompt_security.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
rag_manager.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
rag_singleton.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
rag_vector.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
rate_limiter.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
request_models.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
research_handler.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
research_utils.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
secret_storage.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
session_actions.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
settings.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
task_endpoint.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
task_scheduler.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
teacher_escalation.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
text_helpers.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
tool_execution.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
tool_implementations.py Fix YEARLY recurring CalDAV events only showing on DTSTART year (#179) 2026-06-01 13:42:44 +09:00
tool_index.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
tool_parsing.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
tool_schemas.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
tool_security.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
topic_analyzer.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
upload_handler.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
visual_report.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
webhook_manager.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
youtube_handler.py Odysseus v1.0 2026-05-31 23:58:26 +09:00