refactor: canonicalize mcp source id helpers

This commit is contained in:
lda
2026-06-08 11:39:11 +07:00 Verified
parent 8cab3bcf10
commit 4d9b785fbd
10 changed files with 510 additions and 16 deletions
+2
View File
@@ -6,6 +6,8 @@ from wf_sources_mcp.ids import CONNECTION_ID_PATTERN, parse_connection_id
from .models import ConnectionConfig
__all__ = ["CONNECTION_ID_PATTERN", "parse_connection_id"]
def qualify_node_name(connection_id: str, local_name: str) -> str:
parse_connection_id(connection_id)
+2
View File
@@ -25,6 +25,8 @@ from wf_sources_mcp.ids import RESERVED_CONNECTION_IDS
ADMIN_NAMESPACE = "wf.admin"
__all__ = ["RESERVED_CONNECTION_IDS"]
@dataclass(frozen=True, slots=True)
class ProxyToolName:
+12
View File
@@ -28,8 +28,20 @@ def parse_connection_id(connection_id: str) -> tuple[str, str]:
return server, account
def validate_connection_id(connection_id: str) -> str:
"""Validate one MCP source id and return it unchanged.
Use this when callers need path-safety and shape validation but do not need
provider/account pieces. `parse_connection_id()` remains the splitter.
"""
parse_connection_id(connection_id)
return connection_id
__all__ = [
"CONNECTION_ID_PATTERN",
"RESERVED_CONNECTION_IDS",
"parse_connection_id",
"validate_connection_id",
]
+2 -2
View File
@@ -129,9 +129,9 @@ class FileCatalogStore(CatalogStore):
@staticmethod
def _connection_path(directory: Path, connection_id: str) -> Path:
from wf_mcp.connections import parse_connection_id
from wf_sources_mcp.ids import validate_connection_id
parse_connection_id(connection_id)
validate_connection_id(connection_id)
root = directory.resolve()
path = (directory / f"{connection_id}.json").resolve()
if path.parent != root: