Skip to main content

MCP Integration

Enable AI tools and agents to access your data through Model Context Protocol (MCP), a standardized protocol for AI-data interactions.

What is MCP?

Model Context Protocol (MCP) is an open protocol that enables AI assistants to securely access and interact with data sources. Autonify implements MCP to expose your database information to AI tools while maintaining security and governance.

MCP Services in Autonify

Autonify provides four specialized MCP services, each designed for specific AI use cases:

1. Schema Discovery Service

  • Purpose: Explore database structures and relationships
  • Endpoint: /schema-sse/sse
  • Capabilities:
    • List databases, schemas, and tables
    • View column definitions and data types
    • Understand foreign key relationships
    • Access table and column documentation

2. Data Access Service

  • Purpose: Execute queries and retrieve actual data
  • Endpoint: /data-sse/sse
  • Protocol: GraphQL via Hasura
  • Capabilities:
    • Run GraphQL queries
    • Access real-time data
    • Support for complex queries and joins
    • Respects row-level security

3. Data Quality Service

  • Purpose: Monitor and report data quality metrics
  • Endpoint: /quality-sse/sse
  • Capabilities:
    • View quality scores and trends
    • Access validation rule results
    • Identify data quality issues
    • Track quality improvements over time

4. Sensitivity Classification Service

  • Purpose: Understand data privacy and compliance requirements
  • Endpoint: /sensitivity-sse/sse
  • Capabilities:
    • Identify PII, PHI, PCI data
    • View sensitivity classifications
    • Understand compliance requirements
    • Guide appropriate data handling

Enabling MCP Services

Prerequisites

  • Admin or Owner role in Autonify
  • Network connectivity between AI tools and Autonify
  • MCP-compatible AI tool or framework

Configuration Steps

  1. Access MCP Settings

    • Navigate to Settings in the main navigation
    • Select the MCP tab (visible for Admin/Owner roles only)
  2. Enable Services

    • Review available services in the table
    • Toggle the switch to enable/disable each service
    • Note the endpoint URLs for configuration
  3. Copy Endpoint URLs

    • Click the copy button next to each endpoint
    • URLs include your Autonify instance address
    • Save these for AI tool configuration

Integration Methods

Direct MCP Integration

For tools with native MCP support:

{
"mcpServers": {
"autonify-schema": {
"command": "sse",
"args": ["https://your-instance.com/schema-sse/sse"]
}
}
}

Server-Sent Events (SSE)

MCP services use SSE for real-time streaming:

const eventSource = new EventSource('https://your-instance.com/schema-sse/sse');

eventSource.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log('Received:', data);
};

eventSource.onerror = (error) => {
console.error('SSE Error:', error);
};

GraphQL for Data Access

The data access service exposes GraphQL:

query GetCustomers {
customers(limit: 10) {
id
name
email
created_at
}
}

Security & Governance

Authentication

  • MCP services require valid Autonify authentication
  • Bearer tokens passed in Authorization headers
  • Sessions managed by Autonify security

Authorization

  • Services respect Autonify's permission model
  • Team-level data isolation maintained
  • Row-level security (RLS) enforced

Audit Trail

  • All MCP access is logged
  • Usage statistics tracked per service
  • Available in Settings → MCP tab

Use Cases

Development & Engineering

  • Code Generation: Generate SQL queries with schema context
  • Data Exploration: Understand database structure while coding
  • API Development: Build GraphQL queries with AI assistance
  • Documentation: Generate documentation from schema

Data Analysis

  • Natural Language Queries: Ask questions in plain English
  • Data Quality Review: Identify issues through conversation
  • Sensitivity Checks: Understand compliance requirements
  • Cross-Source Analysis: Query relationships across databases

Automation & Workflows

  • Agent Integration: Add data context to AI agents
  • Workflow Automation: Chain MCP calls in pipelines
  • Monitoring Systems: Integrate quality checks
  • Alert Generation: Trigger based on data conditions

Best Practices

Service Selection

  • Enable only necessary services
  • Start with schema discovery for exploration
  • Add data access when queries are needed
  • Use quality/sensitivity for governance

Performance Considerations

  • MCP uses streaming for efficiency
  • Responses are cached where appropriate
  • Large queries may require pagination
  • Monitor usage in Settings → MCP

Security Guidelines

  • Regularly review enabled services
  • Monitor usage statistics
  • Rotate authentication tokens periodically
  • Audit MCP access logs

Troubleshooting

Common Issues

IssueCauseSolution
Connection refusedService disabledEnable in Settings → MCP
Authentication failedInvalid/expired tokenRefresh authentication
No data returnedPermission deniedCheck team/data access
Timeout errorsLarge queryOptimize query or paginate

Testing Services

  1. Use browser EventSource to test SSE endpoints
  2. Check service status in Settings → MCP
  3. Review usage counters for activity
  4. Verify network connectivity

API Reference

SSE Event Format

interface MCPEvent {
id: string;
type: 'message' | 'error' | 'complete';
data: {
content: any;
metadata?: Record<string, any>;
};
}

Authentication Header

Authorization: Bearer <your-token>

Error Responses

{
"error": "Service disabled",
"code": "MCP_SERVICE_DISABLED",
"status": 403
}