SurfSense/surfsense_backend/app/routes
CREDO23 704d1bf18f refactor(mcp): per-connector cache refresh on lifecycle events
Collapse the invalidate + warmup pair into a single
refresh_mcp_tools_cache_for_connector(connector_id, search_space_id)
helper and scope live discovery to the one connector that changed
instead of the whole search space.

- new mcp_tool.discover_single_mcp_connector: load one connector,
  refresh OAuth if needed, force live MCP discovery so its cached_tools
  row is rewritten; returned wrappers are discarded since the in-process
  LRU is rebuilt lazily on the next user query
- mcp_tools_cache.refresh_mcp_tools_cache_for_connector: synchronously
  evicts the per-space LRU (LRU keys cannot scope finer) and schedules
  the per-connector prefetch via loop.create_task
- routes (OAuth callback, MCP POST, MCP PUT) collapse their two
  back-to-back calls into a single refresh call; DELETE handlers keep
  using bare invalidate_mcp_tools_cache (nothing to prefetch)

No new automated tests: the new functions are I/O glue (DB + network)
where mocked unit tests would test implementation rather than behavior.
The existing 9 unit tests for the cached_tools data shape are unchanged.
2026-05-20 17:43:27 +02:00
..
__init__.py
agent_action_log_route.py
agent_flags_route.py
agent_permissions_route.py
agent_revert_route.py
airtable_add_connector_route.py
anonymous_chat_routes.py
auth_routes.py
chat_comments_routes.py
circleback_webhook_route.py
clickup_add_connector_route.py
composio_routes.py
confluence_add_connector_route.py
discord_add_connector_route.py
documents_routes.py
dropbox_add_connector_route.py
editor_routes.py
export_routes.py
folders_routes.py
google_calendar_add_connector_route.py
google_drive_add_connector_route.py
google_gmail_add_connector_route.py
image_generation_routes.py
incentive_tasks_routes.py
jira_add_connector_route.py
linear_add_connector_route.py
logs_routes.py
luma_add_connector_route.py
mcp_oauth_route.py refactor(mcp): per-connector cache refresh on lifecycle events 2026-05-20 17:43:27 +02:00
memory_routes.py
model_list_routes.py
new_chat_routes.py
new_llm_config_routes.py
notes_routes.py
notifications_routes.py
notion_add_connector_route.py
oauth_connector_base.py
obsidian_plugin_routes.py
onedrive_add_connector_route.py
podcasts_routes.py
prompts_routes.py
public_chat_routes.py
rbac_routes.py
reports_routes.py
sandbox_routes.py
search_source_connectors_routes.py
search_spaces_routes.py
slack_add_connector_route.py
stripe_routes.py
surfsense_docs_routes.py
teams_add_connector_route.py
video_presentations_routes.py
vision_llm_routes.py
youtube_routes.py