Skip to content

MCP server refinement#168

Merged
pebenito merged 5 commits into
SELinuxProject:mainfrom
pebenito:mcp-refinement
Jun 5, 2026
Merged

MCP server refinement#168
pebenito merged 5 commits into
SELinuxProject:mainfrom
pebenito:mcp-refinement

Conversation

@pebenito
Copy link
Copy Markdown
Member

@pebenito pebenito commented Jun 5, 2026

This pull request refactors several parts of the setools codebase, primarily to improve enum handling, standardize JSON serialization, and simplify component selection logic for policy difference analysis. It also updates tests to align with these changes. The main themes are improved enum usage, serialization consistency, and code simplification.

Enum and Component Handling Improvements:

  • Replaced usage of the standard enum.Enum with a custom policyrep.PolicyEnum for Mode inner classes in both DomainTransitionAnalysis and InfoFlowAnalysis, improving consistency and enabling custom lookup methods.
  • Introduced a new DiffComponent enum to replace the previous frozenset of string constants for policy component selection in difference analysis, resulting in more robust and type-safe component handling throughout setools/mcp/server.py.

JSON Serialization and API Response Standardization:

  • Centralized JSON serialization logic for API responses into a new static method _serialize_results, which is now used throughout the server for consistent formatting and reduced code duplication.

Analysis Method Simplification:

  • Simplified mode lookup and error handling in setools_analyze_dta and setools_analyze_info_flow by leveraging the new enum lookup method, and adjusted references to analysis mode to use the new enum instances.
  • Updated policy difference analysis to use the new DiffComponent enum for component selection and improved the logic for default and user-specified components.

Test Updates:

  • Refactored test utilities and test cases in tests/library/mcp/test_server.py to match the new standardized API response format and removed now-unnecessary argument for top-level key count.

Other Minor Cleanups:

  • Removed unused imports and updated imports to reflect new enum usage.

pebenito added 4 commits June 5, 2026 16:27
This is an enum.Enum subclass. There should be no downstream impact.

Signed-off-by: Chris PeBenito <pebenito@ieee.org>
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
@pebenito pebenito merged commit 7078cab into SELinuxProject:main Jun 5, 2026
12 checks passed
@pebenito pebenito deleted the mcp-refinement branch June 5, 2026 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant