refactor(agents): group MCP tools into shared/tools/mcp/ subpackage

The three MCP siblings (mcp_client/mcp_tool/mcp_tools_cache) served one
objective but sat loose at the top of shared/tools. Grouped them into an
mcp/ package and dropped the redundant prefix: client.py, tool.py, cache.py.
Updated all importers (routes, mcp_tools subagent, e2e fake patch targets,
unit test) to the new paths.
This commit is contained in:
CREDO23 2026-06-04 20:35:38 +02:00
parent 8d0090c6a1
commit c51aca6ccc
9 changed files with 23 additions and 16 deletions

View file

@ -0,0 +1,7 @@
"""MCP (Model Context Protocol) integration: client, tool loading, and cache.
Split by responsibility:
- ``client``: the low-level :class:`MCPClient` connection wrapper.
- ``tool``: discovery + LangChain tool construction and cache invalidation.
- ``cache``: the connector tool-cache refresh helpers.
"""

View file

@ -112,7 +112,7 @@ def refresh_mcp_tools_cache_for_connector(
when an event loop is available. Neither path raises.
"""
try:
from app.agents.shared.tools.mcp_tool import invalidate_mcp_tools_cache
from app.agents.shared.tools.mcp.tool import invalidate_mcp_tools_cache
invalidate_mcp_tools_cache(search_space_id)
except Exception:
@ -133,7 +133,7 @@ def refresh_mcp_tools_cache_for_connector(
async def _run_connector_prefetch(connector_id: int) -> None:
from app.agents.shared.tools.mcp_tool import discover_single_mcp_connector
from app.agents.shared.tools.mcp.tool import discover_single_mcp_connector
try:
await discover_single_mcp_connector(connector_id)

View file

@ -35,8 +35,8 @@ from sqlalchemy.ext.asyncio import AsyncSession
from app.agents.shared.middleware.dedup_tool_calls import dedup_key_full_args
from app.agents.shared.tools.hitl import request_approval
from app.agents.shared.tools.mcp_client import MCPClient
from app.agents.shared.tools.mcp_tools_cache import (
from app.agents.shared.tools.mcp.client import MCPClient
from app.agents.shared.tools.mcp.cache import (
CachedMCPTools,
read_cached_tools,
write_cached_tools,