Skip to content

Commit f9c5fec

Browse files
committed
feat: add jsonschema rules
1 parent 4d6a11f commit f9c5fec

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

tools/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
from .orchestrator_creation_workflow_rules import creation_workflow_rules
22
from .orchestrator_get_sample_workflow import orchestrator_get_sample_workflow
33
from .orchestrator_workflow_renderer import orchestrator_preview_workflow
4+
from .orchestrator_get_schema_rules import get_schema_rules
45

56
__all__ = [
67
creation_workflow_rules,
8+
get_schema_rules,
79
orchestrator_get_sample_workflow,
810
orchestrator_preview_workflow,
911
]
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import logging
2+
from pathlib import Path
3+
4+
from .orchestrator_service import orchestrator_mcp
5+
6+
logger = logging.getLogger(__name__)
7+
8+
SERVERLESS_JSON_PATH = "serverless-workflow/consolidated_workflow_schema.json"
9+
10+
# Cache for schema content
11+
_schema_cache = None
12+
13+
14+
@orchestrator_mcp.tool()
15+
def get_schema_rules(session_id: str) -> str:
16+
"""
17+
Retrieve the complete orchestrator workflow schema for orchestrator operations.
18+
19+
This tool returns the full consolidated workflow schema from the orchestrator-workflow
20+
specification. Use this when you need to understand the complete schema structure,
21+
validate workflow definitions, or reference specific schema components.
22+
23+
Args:
24+
session_id (str): Session identifier for logging and tracking purposes
25+
26+
Returns:
27+
str: Complete JSON schema as a string, or error message if schema cannot be loaded
28+
29+
Note:
30+
Only request this when you need schema validation or have specific questions
31+
about the workflow structure, as it returns the entire schema document.
32+
""" # noqa: E501
33+
global _schema_cache
34+
35+
logger.info(f"get_filtered_schema_rules for session_id='{session_id}'")
36+
37+
# Return cached content if available
38+
if _schema_cache is not None:
39+
return _schema_cache
40+
41+
# Load and cache the schema
42+
input_path = Path(SERVERLESS_JSON_PATH)
43+
if not input_path.exists():
44+
return "Error: cannot load the orchestrator-workflow schema"
45+
46+
try:
47+
with open(input_path, "r", encoding="utf-8") as f:
48+
_schema_cache = f.read()
49+
return _schema_cache
50+
except Exception as e:
51+
logger.error(f"Error reading schema file: {e}")
52+
return "Error: cannot read the orchestrator-workflow schema"

0 commit comments

Comments
 (0)