Commit f88a815
authored
refactor(mcp): use Pydantic models for structured tool outputs and add AI-powered auto-fix generation (#1603)
* refactor(mcp): use Pydantic models for structured tool outputs
Replace dict-based return values with Pydantic models across all MCP tools
to enable structured output with automatic JSON schema generation and
type validation.
Changes:
- Add models.py with Pydantic models for all tool return types
(DiagnosticResult, FormatContentResult, LintAndFormatResult, etc.)
- Update all tool implementations to return Pydantic models instead of dicts
- Fix SeveritySummary field name from 'I' to 'INFO' with alias for
backward compatibility (resolves ruff E741 ambiguous variable name)
Bug fixes discovered during integration testing:
- Fix dict-style access (result["key"]) to attribute access (result.key)
in registration.py context messages - Pydantic models use attributes
- Remove 'from __future__ import annotations' from registration.py as it
breaks Pydantic's runtime type evaluation for Annotated fields
Testing:
- Update existing unit tests for new Pydantic model structure
* feat(mcp): add LLM-assisted auto-fix tools for Robot Framework issues
Add two new MCP tools that enable AI-powered fixing of linting issues:
- get_fix_context: Provides rich context for LLM fix generation including
the problematic code snippet, issue details with fix_suggestion and
rule_docs, and structured guidance for generating fixes
- apply_fix: Applies line-based replacements and validates fixes by
re-linting. Detects if a fix made things worse and supports both
preview mode and file overwriting
New Pydantic models:
- CodeSnippet, IssueForFix, GetFixContextResult
- FixReplacement, ApplyFixResult
This enables the workflow: get_fix_context → LLM generates fix → apply_fix
with validation, supporting use cases like fixing naming conventions,
adding missing documentation, and restructuring code.
* fix: update docs and remove duplicate line
* fix: replace lambda with attrgetter and replace list comprehension with a simpler approach1 parent d88f9bf commit f88a815
File tree
14 files changed
+2524
-1379
lines changed- docs/integrations
- src/robocop/mcp/tools
- utils
- tests/mcp
14 files changed
+2524
-1379
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
343 | 343 | | |
344 | 344 | | |
345 | 345 | | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
346 | 415 | | |
347 | 416 | | |
348 | 417 | | |
| |||
567 | 636 | | |
568 | 637 | | |
569 | 638 | | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
570 | 648 | | |
571 | 649 | | |
572 | 650 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
| 189 | + | |
189 | 190 | | |
190 | 191 | | |
191 | 192 | | |
192 | 193 | | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
193 | 197 | | |
194 | 198 | | |
195 | 199 | | |
| |||
0 commit comments