-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Labels
enhancementNew feature or requestNew feature or request
Description
overview
add read-only tool to query variables (workspace-level key-value configuration)
what are variables?
variables are workspace-level mutable json storage:
- use cases: configuration values, feature flags, environment-specific settings
- key features: simple name-based access, optional tags, any json-serializable value
- scope: shared across all flows in workspace
proposed tool
@mcp.tool
async def get_variables(
name: str | None = None,
limit: int = 50,
) -> VariablesResult:
"""get variables (workspace-level configuration).
variables are mutable json values shared across flows, often used
for configuration, feature flags, or environment-specific settings.
examples:
- list all: get_variables()
- get specific: get_variables(name="api_url")
"""implementation notes
types to add (types.py):
class VariableDetail(TypedDict):
id: str
name: str
value: Any # json value
tags: list[str]
created: str | None
updated: str | None
class VariablesResult(TypedDict):
success: bool
count: int
variables: list[VariableDetail]
error: str | Noneclient code (_prefect_client/variables.py):
async def get_variables(name: str | None = None, limit: int = 50) -> VariablesResult:
async with get_client() as client:
if name:
variable = await client.read_variable_by_name(name)
variables = [variable] if variable else []
else:
variables = await client.read_variables(limit=limit)
return {
"success": True,
"count": len(variables),
"variables": [...],
"error": None,
}value
enhances observability into workspace configuration - useful for checking current settings, feature flags, and environment-specific values
note on mutations
keeping this read-only consistent with server design. users can mutate via cli/ui when needed.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request