MCP Data Analysis
Relevant source files
The following files were used as context for generating this wiki page:
MCP Data Analysis allows you to analyze and correlate live infrastructure data using the Model Context Protocol (MCP) server. It enables AI agents to answer operational questions, detect configuration drift, and investigate change impacts by querying the Infrahub graph directly. This skill is specifically optimized for interactive, conversational exploration of data models and real-time troubleshooting.
Sources: skills/infrahub-analyzing-data/SKILL.md:1-20, README.md:92-95
This module facilitates on-demand analysis without requiring pre-written Python code or automated pipelines. It serves as the primary tool for one-off audits, blast-radius analysis, and inventory gap identification.
Sources: skills/infrahub-analyzing-data/SKILL.md:22-38, skills/infrahub-analyzing-data/rules/approach-selection.md:37-46
Architecture and Components
The MCP Data Analysis architecture relies on the Infrahub MCP server (v1.1.7+) to expose internal tools to an AI agent. The agent uses these tools to execute GraphQL queries, search for nodes, and manage session branches.
The diagram shows the flow of an analysis request from a user question through the MCP server tools to either read from the graph or write to a session branch.
Sources: skills/infrahub-analyzing-data/SKILL.md:73-77, dev/knowledges/architecture.md:28-40
Core MCP Tools
The following table summarizes the primary tools available for data analysis:
| Tool Category | Tool Name | Description |
|---|---|---|
| Read | mcp__infrahub__get_nodes | Lists nodes of a kind with filtering and pagination. |
| Read | mcp__infrahub__query_graphql | Executes a raw read-only GraphQL query. |
| Read | mcp__infrahub__search_nodes | Finds nodes by partial substring search. |
| Read | mcp__infrahub__get_schema | Discovers available schema kinds and filters. |
| Write | mcp__infrahub__node_upsert | Creates or updates an object on a session branch. |
| Write | mcp__infrahub__propose_changes | Opens a Proposed Change for human review. |
| Session | mcp__infrahub__get_session_info | Reports active session branch and instance address. |
Sources: skills/infrahub-analyzing-data/SKILL.md:80-101, skills/infrahub-analyzing-data/examples.md:330-345
Analysis Workflow
Data analysis follows a structured four-step process to transform a natural language question into actionable findings.
This sequence illustrates the interaction between the user, the AI agent, and the Infrahub backend during an analysis task.
Sources: skills/infrahub-analyzing-data/SKILL.md:108-124, skills/infrahub-analyzing-data/rules/_sections.md:1-25
Correlation Logic
Correlation logic involves matching, diffing, and joining data returned from multiple queries. It identifies findings through set operations, ID-based joins, and attribute lookups to perform design-to-reality comparisons or service impact tracing.
Sources: skills/infrahub-analyzing-data/rules/_sections.md:15-20
Choosing the Right Approach
Infrahub provides multiple analysis methods. The MCP analysis skill is prioritized for exploration and one-off queries.
| Criterion | MCP Analysis | InfrahubCheck | Transform + Artifact |
|---|---|---|---|
| Trigger | On demand, conversational | Every proposed change | Scheduled or on demand |
| Enforcement | None (informational) | Blocks merge on failure | None (output only) |
| Automation | Manual (AI + Human) | Fully automated | Fully automated |
| Best For | Exploration, incident audit | Policy enforcement | Recurring reports, exports |
Sources: skills/infrahub-analyzing-data/rules/approach-selection.md:23-35
Common Escalation Path
Analysis typically starts with MCP to understand the problem before moving to automated enforcement.
- MCP Analysis: Explore and define policy interactively.
- InfrahubCheck: Enforce the policy automatically on proposed changes.
- Transform: Export a recurring report for stakeholders.
Sources: skills/infrahub-analyzing-data/rules/approach-selection.md:73-82
Reporting and Output Standards
To ensure findings are actionable, reports must follow a consistent structure including context, counts, and remediation hints.
Report Structure Pattern
Compliance reports lead with the policy and totals, followed by detailed violations:
- Header: Title, Scope, and Date.
- Summary Table: Checked items, compliant count, and violation count.
- Violation Details: Object IDs, names, and specific policy failures.
- Remediation: Concrete steps to fix the identified issues.
Sources: skills/infrahub-analyzing-data/rules/reporting-output.md:34-51, skills/infrahub-analyzing-data/examples.md:44-59
Severity Markers
Reports use standardized markers to prioritize actions:
✗ CRITICAL: Immediate action required for security or data loss risks.✗ ERROR: Policy violation that must be fixed.⚠WARN: Deviation that should be addressed.ℹ INFO: General observation.
Sources: skills/infrahub-analyzing-data/rules/reporting-output.md:112-120
Remediation and Branching
Any write operations initiated during analysis (such as mcp__infrahub__node_upsert) are branch-isolated. These changes land on an auto-created mcp/session-* branch. They never touch the default branch directly. Users must call propose_changes to open a Proposed Change for human review and eventual merge.
Sources: skills/infrahub-analyzing-data/SKILL.md:88-92, skills/infrahub-analyzing-data/examples.md:347-350
Summary
MCP Data Analysis provides a conversational interface for operational intelligence within Infrahub. By leveraging the MCP server, it allows for deep correlation across disparate infrastructure nodes, such as maintenance windows and service impacts, without the overhead of formal code development. It serves as the exploratory foundation for defining organizational policies that are later codified into automated checks and transforms.