Skip to content

Commit 22b8bf0

Browse files
committed
feat: schema default flip, repair tickets, and hallucination reduction
- Flip include_schemas default to true in list_tools handler - Add structured repair_ticket in data on ARG_VALIDATION_FAILED - Add fuzzy matching (normalization + Levenshtein) for did_you_mean - Add circuit breaker (3-tier escalation) for repeated failures - Parse Ajv errors into categories: missing_required, type_errors, enum_violations, format_errors, unknown_fields from strippedArgs - Update stale guidance text in getHelp, useTool, server, docs - 11 new repair ticket tests (60 total passing)
1 parent 15b9828 commit 22b8bf0

File tree

8 files changed

+752
-116
lines changed

8 files changed

+752
-116
lines changed

docs/ERROR_CODES_REFERENCE.md

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,41 @@ The arguments provided to a tool don't match its expected JSON schema.
115115
- Fields exceeding length limits
116116

117117
**Solutions:**
118-
1. Run `list_tools(package_id: "...", include_schemas: true)` to see full schema
119-
2. Ensure all required fields are present
120-
3. Check that types match exactly (strings, numbers, booleans)
121-
4. Use `dry_run: true` with `use_tool` to validate before executing
118+
1. Inspect `data.repair_ticket` in the error response for surgical fix guidance:
119+
- `missing_required`
120+
- `type_errors`
121+
- `enum_violations`
122+
- `format_errors`
123+
- `unknown_fields` + `did_you_mean`
124+
- `schema_fragments` (field-level snippets; escalates to full schema on repeated failures)
125+
2. Fix only the fields listed in the repair ticket and retry
126+
3. Use `dry_run: true` with `use_tool` to validate arguments before execution
127+
4. If `repair_ticket.attempt >= 3`, ask the user for clarification before retrying
122128

123129
**Related get_help:** `get_help(error_code: -32003)`
124130

125131
**Example log message:**
126132
```
127-
Argument validation failed for tool 'write_file': missing required property 'content'
133+
Argument validation failed for tool 'write_file'. Missing required: content. Type errors: overwrite (expected boolean, got string).
134+
```
135+
136+
**Example error data payload:**
137+
```json
138+
{
139+
"repair_ticket": {
140+
"missing_required": ["content"],
141+
"type_errors": [{"field": "overwrite", "expected": "boolean", "got": "string", "value": "yes"}],
142+
"enum_violations": [],
143+
"format_errors": [],
144+
"unknown_fields": ["filePath"],
145+
"did_you_mean": {"filePath": "path"},
146+
"schema_fragments": {
147+
"content": {"type": "string"},
148+
"path": {"type": "string"}
149+
},
150+
"attempt": 1
151+
}
152+
}
128153
```
129154

130155
---

src/handlers/getHelp.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ Returns:
135135
136136
## Tips
137137
- Start with summarize: true for readable format
138-
- Use include_schemas: true only when debugging
138+
- Schemas are included by default; set include_schemas: false for lighter responses
139139
- Page through results if a package has many tools`,
140140

141141
error_handling: `# Error Handling in Super-MCP
@@ -285,7 +285,7 @@ The tool_id doesn't exist in the specified package.
285285
The arguments provided don't match the tool's expected schema.
286286
287287
## How to Fix
288-
1. Run \`list_tools(package_id: "...", include_schemas: true)\`
288+
1. Run \`list_tools(package_id: "...")\`
289289
2. Review the exact schema requirements
290290
3. Ensure all required fields are present
291291
4. Check that types match exactly (string vs number)
@@ -437,7 +437,7 @@ use_tool(
437437
438438
## Troubleshooting
439439
- If tools aren't working, check \`health_check_all()\`
440-
- For detailed schemas: \`list_tools(package_id: "${packageId}", include_schemas: true)\`
440+
- Schemas are included by default: \`list_tools(package_id: "${packageId}")\`
441441
- Test arguments: Add \`dry_run: true\` to use_tool`;
442442

443443
} catch (error) {

src/handlers/listTools.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export async function handleListTools(
1111
package_id,
1212
name_pattern,
1313
summarize = true,
14-
include_schemas = false,
14+
include_schemas = true,
1515
page_size = 20,
1616
page_token,
1717
} = input;

0 commit comments

Comments
 (0)