Skip to content

Commit 318853d

Browse files
CopilotMaestroError
andcommitted
Fix review comments: remove unused imports and redundant check_toolset_files method
Co-authored-by: MaestroError <46760939+MaestroError@users.noreply.github.com>
1 parent 45badd4 commit 318853d

File tree

5 files changed

+9
-56
lines changed

5 files changed

+9
-56
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ These are critical issues that prevent the schema from being used. Validation us
372372
- **Required fields**: Presence of `schemaVersion` and `metadata`
373373
- **Data types**: Field values match expected types
374374
- **Tool definitions**: Valid execution types and input schemas
375-
- **Toolset references**: Toolset files exist in the `mci/` directory
375+
- **Toolset references**: Referenced toolsets must exist in the `mci/` directory (validated by MCIClient)
376376
- **MCP server definitions**: Valid server configurations
377377

378378
If any errors are found, validation fails and the schema cannot be used.

src/mci/core/validator.py

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,7 @@ def validate_schema(self) -> ValidationResult:
9090
errors.append(ValidationError(message=f"Failed to load schema data: {str(e)}"))
9191
return ValidationResult(errors=errors, warnings=warnings, is_valid=False)
9292

93-
# Perform additional checks (as warnings)
94-
toolset_warnings = self.check_toolset_files()
95-
warnings.extend(toolset_warnings)
96-
93+
# Perform additional checks for MCP commands (as warnings)
9794
mcp_warnings = self.check_mcp_commands()
9895
warnings.extend(mcp_warnings)
9996

@@ -121,51 +118,6 @@ def _load_schema_data(self) -> None:
121118
else:
122119
raise ValueError(f"Unsupported file format: {file_path.suffix}")
123120

124-
def check_toolset_files(self) -> list[ValidationWarning]:
125-
"""
126-
Check that referenced toolset files exist.
127-
128-
Returns:
129-
List of ValidationWarning for missing toolset files
130-
131-
Example:
132-
>>> validator = MCIValidator("mci.json")
133-
>>> validator._load_schema_data()
134-
>>> warnings = validator.check_toolset_files()
135-
"""
136-
warnings: list[ValidationWarning] = []
137-
138-
if not self.schema_data:
139-
return warnings
140-
141-
toolsets = self.schema_data.get("toolsets", [])
142-
if not toolsets:
143-
return warnings
144-
145-
schema_dir = Path(self.file_path).parent
146-
mci_dir = schema_dir / "mci"
147-
148-
# Type narrowing: toolsets should be a list
149-
if not isinstance(toolsets, list):
150-
return warnings
151-
152-
for toolset in toolsets:
153-
if isinstance(toolset, str):
154-
# Toolset is a string reference (e.g., "weather")
155-
# Should correspond to mci/weather.mci.json or mci/weather.mci.yaml
156-
toolset_json = mci_dir / f"{toolset}.mci.json"
157-
toolset_yaml = mci_dir / f"{toolset}.mci.yaml"
158-
159-
if not toolset_json.exists() and not toolset_yaml.exists():
160-
warnings.append(
161-
ValidationWarning(
162-
message=f"Toolset file not found: {toolset}",
163-
suggestion=f"Create {toolset_json} or {toolset_yaml}, or update the toolset reference",
164-
)
165-
)
166-
167-
return warnings
168-
169121
def check_mcp_commands(self) -> list[ValidationWarning]:
170122
"""
171123
Check that MCP server commands are available in PATH.

tests/test_validate_command.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import tempfile
99
from pathlib import Path
1010

11-
import pytest
1211
from click.testing import CliRunner
1312

1413
from mci.cli.validate import validate

tests/unit/core/test_validator.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@
88
import tempfile
99
from pathlib import Path
1010

11-
import pytest
12-
13-
from mci.core.validator import MCIValidator, ValidationResult
14-
from mci.utils.error_formatter import ValidationError, ValidationWarning
11+
from mci.core.validator import MCIValidator
1512

1613

1714
def test_valid_schema_via_mciclient():

testsManual/test_validate.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,12 @@ def test_invalid_schema():
8484

8585

8686
def test_schema_with_missing_toolsets():
87-
"""Test 3: Schema with missing toolset files (errors in MCIClient)."""
87+
"""
88+
Test 3: Schema with missing toolset files.
89+
90+
MCIClient validates toolset references and treats missing toolsets as errors.
91+
This test demonstrates that validation fails when toolsets don't exist in the mci/ directory.
92+
"""
8893
console = Console()
8994
print_section(console, "Test 3: Schema with Missing Toolset Files (Errors)")
9095

0 commit comments

Comments
 (0)