Skip to main content
Glama

Optimized Memory MCP Server V2

by AgentWong
analysis.py5.59 kB
""" Analysis tools for the MCP server. This module provides MCP tools for analyzing infrastructure components. Tools support: - Version comparison between provider releases - Breaking change detection - New feature identification - Security update tracking - Deprecation analysis Tools follow MCP patterns for: - Structured analysis results - Proper error handling - Database integration - Version comparison logic """ from typing import Dict, Any, List from sqlalchemy.orm import Session from mcp.server.fastmcp import FastMCP from ..db.connection import get_db from ..db.models.providers import Provider from ..utils.errors import DatabaseError, ValidationError def register_tools(mcp: FastMCP) -> list: """Register analysis tools with the MCP server. This function registers all analysis-related tools with the MCP server instance. Tools include: - analyze_provider: Compare provider versions for changes - analyze_collection: Compare Ansible collection versions - analyze_dependencies: Check for dependency conflicts Each tool is registered with proper type hints, error handling, and database integration. Tools follow MCP protocol patterns for consistent behavior and error reporting. """ @mcp.tool() def analyze_provider( provider_id: int, from_version: str, to_version: str ) -> Dict[str, Any]: """Analyze changes between provider versions. Performs deep analysis comparing two versions of a provider to identify: - Breaking changes (removed/modified resources, fields, etc) - New features and capabilities - Deprecation notices and timelines - Security updates and patches - API compatibility changes - Configuration requirement changes The analysis looks at: - Resource type definitions and schemas - Field specifications and validation rules - Default values and constraints - Required fields and dependencies - Authentication and authorization requirements - Provider-specific configuration options - API version compatibility matrices - Resource lifecycle management - Cross-resource dependencies - State management implications - Resource tagging capabilities - Quota and limit changes - Regional availability updates - Service endpoint modifications - IAM/RBAC policy changes - Encryption requirements - Compliance certifications - Performance characteristics - Cost implications - Integration patterns Args: provider_id: ID of the provider to analyze from_version: Starting version for comparison to_version: Target version for comparison db: Database session Returns: Dict containing categorized changes: { "breaking_changes": [ { "type": "removed_field", "resource": "aws_instance", "field": "region", "details": "Region field removed, now using provider-level config" } ], "new_features": [ { "type": "new_resource", "resource": "aws_lambda_function", "details": "Added Lambda function resource type" } ], "deprecations": [ { "type": "deprecated_field", "resource": "aws_db_instance", "field": "storage_type", "alternative": "storage_config block", "removal_version": "5.0.0" } ], "security_updates": [ { "type": "vulnerability_fix", "cve": "CVE-2023-12345", "severity": "high", "affected_resources": ["aws_iam_role"] } ] } Raises: ValidationError: If provider not found or versions invalid DatabaseError: If analysis fails Example: >>> result = analyze_provider( ... provider_id=1, ... from_version="3.0.0", ... to_version="3.1.0" ... ) >>> print(result["breaking_changes"][0]) { "type": "removed_field", "resource": "aws_instance", "field": "region", "details": "Region field removed, now using provider-level config" } """ try: with next(get_db()) as db: provider = db.query(Provider).filter(Provider.id == provider_id).first() if not provider: raise ValidationError( "Provider not found", {"provider_id": provider_id} ) analysis = { "breaking_changes": [], "new_features": [], "deprecations": [], "security_updates": [], } # Add version analysis logic here # For now returning empty analysis structure return analysis except Exception as e: raise DatabaseError(f"Failed to analyze provider: {str(e)}")

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/AgentWong/optimized-memory-mcp-serverv2'

If you have feedback or need assistance with the MCP directory API, please join our Discord server