iac-memory-mcp-server

iac-memory-mcp-server

1

The project is an MCP Server designed for the management and analysis of Infrastructure-as-Code (IaC) resources. It offers features such as CRUD operations, resource management, and analysis of infrastructure entities and relationships. The server facilitates development with configuration through environment variables and supports debugging with MCP Inspector.

iac-memory-mcp-server

MCP Server for Infrastructure-as-Code (IaC) resource management and analysis.

Components

Resources

The server implements a resource management system with:

  • Custom resource:// URI scheme for accessing internal resources
  • Each resource has a name, content, and configurable MIME type
  • Resources can represent IaC configurations, documentation, and analysis results

Prompts

The server provides IaC-specific prompts for resource discovery and analysis:

search_resources

Search for Infrastructure-as-Code resources across providers:

result = await session.get_prompt("search_resources", {
    "provider": "aws",  # Cloud provider (aws, azure, gcp)
    "resource_type": "s3_bucket"  # Resource type to search
})
# Returns matching resources with schema versions and documentation
analyze_entity

Analyze infrastructure entities and their relationships:

result = await session.get_prompt("analyze_entity", {
    "entity_id": "entity-123",  # ID of entity to analyze
    "include_relationships": "true"  # Optional: include related entities
})
# Returns detailed analysis including:
# - Entity configuration
# - Recorded observations
# - Related entities (if requested)
# - Relationship types and depths

Tools

The server implements comprehensive CRUD operations:

Entity Management and Relationships:

  • create_entity: Create new infrastructure entities
  • read_entity: Retrieve entity details
  • update_entity: Modify existing entities
  • delete_entity: Remove entities and related data
  • view_relationships: Analyze entity relationships and dependencies
    # View all relationships
    result = await session.call_tool("view_relationships", {})
    
    # View relationships for specific entity
    result = await session.call_tool("view_relationships", {
        "entity_id": "entity-123"
    })
    

Resource Management:

  • add_resource: Add new resources
    # Add a new resource with custom MIME type
    result = await session.call_tool("add_resource", {
        "name": "aws-s3-config",
        "content": "bucket_name: my-bucket\nregion: us-east-1",
        "mime_type": "application/yaml"  # Optional
    })
    
    # Add plain text resource
    result = await session.call_tool("add_resource", {
        "name": "deployment-notes",
        "content": "Deployment steps for production..."
    })
    

Configuration

The server can be configured through environment variables:

  • DATABASE_URL: Path to SQLite database file (default: in-memory)
  • CLIENT_PORT: Port for MCP Inspector client UI (default: 5173)
  • SERVER_PORT: Port for MCP Inspector proxy server (default: 3000)

For development, you can also use a .env file:

DATABASE_URL=/path/to/db.sqlite
CLIENT_PORT=5173
SERVER_PORT=3000

Quickstart

Install

Claude Desktop

On MacOS: ~/Library/Application\ Support/Claude/claude_desktop_config.json On Windows: %APPDATA%/Claude/claude_desktop_config.json

Development/Unpublished Servers Configuration ``` "mcpServers": { "iac-memory-mcp-server": { "command": "uv", "args": [ "--directory", "/home/herman/Documents/vscode/iac-memory-mcp-server", "run", "iac-memory-mcp-server" ] } } ```
Published Servers Configuration ``` "mcpServers": { "iac-memory-mcp-server": { "command": "uvx", "args": [ "iac-memory-mcp-server" ] } } ```

Development

Building and Publishing

To prepare the package for distribution:

  1. Sync dependencies and update lockfile:
uv sync
  1. Build package distributions:
uv build

This will create source and wheel distributions in the dist/ directory.

  1. Publish to PyPI:
uv publish

Note: You'll need to set PyPI credentials via environment variables or command flags:

  • Token: --token or UV_PUBLISH_TOKEN
  • Or username/password: --username/UV_PUBLISH_USERNAME and --password/UV_PUBLISH_PASSWORD

Debugging

Since MCP servers run over stdio, debugging can be challenging. For the best debugging experience, we strongly recommend using the MCP Inspector.

You can launch the MCP Inspector via npm with this command:

npx @modelcontextprotocol/inspector uv --directory /home/herman/Documents/vscode/iac-memory-mcp-server run iac-memory-mcp-server

Upon launching, the Inspector will display a URL that you can access in your browser to begin debugging.