refactor: canonicalize mcp source id helpers
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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",
|
||||
]
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user