oas2mcp.viewers.classification ============================== .. py:module:: oas2mcp.viewers.classification .. autoapi-nested-parse:: Rich viewers for MCP classification results. Purpose: Render :class:`~oas2mcp.models.mcp.McpBundle`, :class:`~oas2mcp.models.mcp.McpCandidate`, and compact agent-context previews in a readable terminal format using Rich. Design: - Keep classification output separate from raw OpenAPI catalog viewers. - Provide both a compact bundle summary and a detailed candidate view. - Optimize for readability when names and URIs are long. - Surface key agent-prep metadata such as auth, safety, prompts, notes, request refs, response refs, and resolved security details. .. rubric:: Examples .. code-block:: python from rich.console import Console from oas2mcp.viewers.classification import render_mcp_bundle_summary render_mcp_bundle_summary(bundle, console=Console()) Functions --------- .. autoapisummary:: oas2mcp.viewers.classification.build_agent_context_overview_panel oas2mcp.viewers.classification.build_agent_context_rationale_panel oas2mcp.viewers.classification.build_agent_context_refs_table oas2mcp.viewers.classification.build_agent_context_security_table oas2mcp.viewers.classification.build_bundle_counts_table oas2mcp.viewers.classification.build_bundle_overview_panel oas2mcp.viewers.classification.build_candidate_metadata_table oas2mcp.viewers.classification.build_candidate_notes_panel oas2mcp.viewers.classification.build_candidate_overview_panel oas2mcp.viewers.classification.build_candidate_prompts_table oas2mcp.viewers.classification.build_candidate_summary_table oas2mcp.viewers.classification.render_mcp_bundle_summary oas2mcp.viewers.classification.render_mcp_candidate_detail oas2mcp.viewers.classification.render_operation_agent_context_preview Module Contents --------------- .. py:function:: build_agent_context_overview_panel(*, catalog: oas2mcp.models.normalized.ApiCatalog, operation: oas2mcp.models.normalized.ApiOperation, candidate: oas2mcp.models.mcp.McpCandidate) -> rich.panel.Panel Build an overview panel for the agent-facing operation context. :param catalog: The normalized API catalog. :param operation: The normalized API operation. :param candidate: The MCP candidate derived from the operation. :returns: A Rich panel. :raises None.: .. rubric:: Examples .. code-block:: python panel = build_agent_context_overview_panel( catalog=catalog, operation=operation, candidate=candidate, ) .. py:function:: build_agent_context_rationale_panel(*, operation: oas2mcp.models.normalized.ApiOperation, candidate: oas2mcp.models.mcp.McpCandidate) -> rich.panel.Panel Build a small deterministic rationale panel for one classification. :param operation: The normalized API operation. :param candidate: The MCP candidate derived from the operation. :returns: A Rich panel. :raises None.: .. rubric:: Examples .. code-block:: python panel = build_agent_context_rationale_panel( operation=operation, candidate=candidate, ) .. py:function:: build_agent_context_refs_table(*, operation: oas2mcp.models.normalized.ApiOperation) -> rich.table.Table Build a request-vs-response schema ref table for an operation. :param operation: The normalized API operation. :returns: A Rich table. :raises None.: .. rubric:: Examples .. code-block:: python table = build_agent_context_refs_table(operation=operation) .. py:function:: build_agent_context_security_table(*, catalog: oas2mcp.models.normalized.ApiCatalog, candidate: oas2mcp.models.mcp.McpCandidate) -> rich.table.Table Build a table of resolved security scheme details for a candidate. :param catalog: The normalized API catalog. :param candidate: The MCP candidate. :returns: A Rich table. :raises None.: .. rubric:: Examples .. code-block:: python table = build_agent_context_security_table( catalog=catalog, candidate=candidate, ) .. py:function:: build_bundle_counts_table(bundle: oas2mcp.models.mcp.McpBundle) -> rich.table.Table Build a Rich table of candidate counts by kind and safety level. :param bundle: The MCP bundle. :returns: A Rich table. :raises None.: .. rubric:: Examples .. code-block:: python table = build_bundle_counts_table(bundle) .. py:function:: build_bundle_overview_panel(bundle: oas2mcp.models.mcp.McpBundle) -> rich.panel.Panel Build a Rich overview panel for an MCP bundle. :param bundle: The MCP bundle. :returns: A Rich panel. :raises None.: .. rubric:: Examples .. code-block:: python panel = build_bundle_overview_panel(bundle) .. py:function:: build_candidate_metadata_table(candidate: oas2mcp.models.mcp.McpCandidate) -> rich.table.Table Build a metadata table for one MCP candidate. :param candidate: The MCP candidate. :returns: A Rich table. :raises None.: .. rubric:: Examples .. code-block:: python table = build_candidate_metadata_table(candidate) .. py:function:: build_candidate_notes_panel(candidate: oas2mcp.models.mcp.McpCandidate) -> rich.panel.Panel Build a notes panel for one MCP candidate. :param candidate: The MCP candidate. :returns: A Rich panel. :raises None.: .. rubric:: Examples .. code-block:: python panel = build_candidate_notes_panel(candidate) .. py:function:: build_candidate_overview_panel(candidate: oas2mcp.models.mcp.McpCandidate) -> rich.panel.Panel Build an overview panel for one MCP candidate. :param candidate: The MCP candidate. :returns: A Rich panel. :raises None.: .. rubric:: Examples .. code-block:: python panel = build_candidate_overview_panel(candidate) .. py:function:: build_candidate_prompts_table(candidate: oas2mcp.models.mcp.McpCandidate) -> rich.table.Table Build a table of suggested prompt templates for a candidate. :param candidate: The MCP candidate. :returns: A Rich table. :raises None.: .. rubric:: Examples .. code-block:: python table = build_candidate_prompts_table(candidate) .. py:function:: build_candidate_summary_table(bundle: oas2mcp.models.mcp.McpBundle, *, max_candidates: int) -> rich.table.Table Build a compact candidate summary table. :param bundle: The MCP bundle. :param max_candidates: Maximum number of candidates to display. :returns: A Rich table. :raises None.: .. rubric:: Examples .. code-block:: python table = build_candidate_summary_table(bundle, max_candidates=10) .. py:function:: render_mcp_bundle_summary(bundle: oas2mcp.models.mcp.McpBundle, *, console: rich.console.Console | None = None, max_candidates: int = 15) -> None Render a Rich summary for an MCP candidate bundle. :param bundle: The MCP candidate bundle to display. :param console: Optional Rich console instance. :param max_candidates: Maximum number of candidates to display in the compact summary table. :returns: None. :raises None.: .. rubric:: Examples .. code-block:: python from rich.console import Console render_mcp_bundle_summary( bundle, console=Console(), ) .. py:function:: render_mcp_candidate_detail(candidate: oas2mcp.models.mcp.McpCandidate, *, console: rich.console.Console | None = None) -> None Render a detailed Rich view for one MCP candidate. :param candidate: The MCP candidate to display. :param console: Optional Rich console instance. :returns: None. :raises None.: .. rubric:: Examples .. code-block:: python from rich.console import Console render_mcp_candidate_detail( bundle.candidates[0], console=Console(), ) .. py:function:: render_operation_agent_context_preview(*, catalog: oas2mcp.models.normalized.ApiCatalog, operation: oas2mcp.models.normalized.ApiOperation, candidate: oas2mcp.models.mcp.McpCandidate, console: rich.console.Console | None = None) -> None Render a compact preview of the agent-facing operation context. :param catalog: The normalized API catalog. :param operation: The normalized API operation. :param candidate: The first-pass MCP candidate derived from the operation. :param console: Optional Rich console instance. :returns: None. :raises None.: .. rubric:: Examples .. code-block:: python render_operation_agent_context_preview( catalog=catalog, operation=operation, candidate=candidate, console=Console(), )