Skip to main content

A Model Context Protocol server for Finch to build and push container images

Project description

Finch MCP Server

A Model Context Protocol (MCP) server for Finch that enables generative AI models to build and push container images through finch cli leveraged MCP tools.

Features

This MCP server acts as a bridge between MCP clients and Finch, allowing generative AI models to build and push container images to repositories, and create ECR repositories as needed. The server provides a secure way to interact with Finch, ensuring that the Finch VM is properly initialized and running before performing operations.

Key Capabilities

  • Build container images using Finch
  • Push container images to repositories, including Amazon ECR
  • Check if ECR repositories exist and create them if needed
  • Automatic management of the Finch VM on macos and windows (initialization, starting, etc.)
  • Automatic configuration of ECR credential helpers when needed (only modifies finch.yaml as config.json is automatically handled)

Prerequisites

  1. Install uv from Astral or the GitHub README
  2. Install Python using uv python install 3.10
  3. Install Finch on your system
  4. For ECR operations, AWS credentials with permissions to push to ECR repositories and create/describe ECR repositories

Setup

Installation

Configure the MCP server in your MCP client configuration:

Default Mode (Read-only AWS Resources)

By default, the server runs in a mode that prevents the creation of new AWS resources. This is useful for environments where you want to limit resource creation or for users who should only be able to build and push to existing repositories.

{
  "mcpServers": {
    "awslabs.finch-mcp-server": {
      "command": "uvx",
      "args": ["awslabs.finch-mcp-server@latest"],
      "env": {
        "AWS_PROFILE": "default",
        "AWS_REGION": "us-west-2",
        "FASTMCP_LOG_LEVEL": "INFO"
      },
      "transportType": "stdio",
      "disabled": false,
      "autoApprove": []
    }
  }
}

In this default mode:

  • The finch_build_container_image tools will work normally
  • The finch_create_ecr_repo and finch_push_image tool will return an error and will not create or modify AWS resources.

AWS Resource Write Mode

The server can also be set to enable AWS resource creation and modification by using the --enable-aws-resource-write flag.

{
  "mcpServers": {
    "awslabs.finch-mcp-server": {
      "command": "uvx",
      "args": [
        "awslabs.finch-mcp-server@latest",
        "--enable-aws-resource-write"
      ],
      "env": {
        "AWS_PROFILE": "default",
        "AWS_REGION": "us-west-2",
        "FASTMCP_LOG_LEVEL": "INFO"
      },
      "transportType": "stdio",
      "disabled": false,
      "autoApprove": []
    }
  }
}

Available Tools

finch_build_container_image

Build a container image using Finch.

The tool builds a Docker image using the specified Dockerfile and context directory. It supports a range of build options including tags, platforms, and more.

Arguments:

  • dockerfile_path (str): Absolute path to the Dockerfile
  • context_path (str): Absolute path to the build context directory
  • tags (List[str], optional): List of tags to apply to the image (e.g., ["myimage:latest", "myimage:v1"])
  • platforms (List[str], optional): List of target platforms (e.g., ["linux/amd64", "linux/arm64"])
  • target (str, optional): Target build stage to build
  • no_cache (bool, optional): Whether to disable cache. Defaults to False.
  • pull (bool, optional): Whether to always pull base images. Defaults to False.
  • build_contexts (List[str], optional): List of additional build contexts
  • outputs (str, optional): Output destination
  • cache_from (List[str], optional): List of external cache sources
  • quiet (bool, optional): Whether to suppress build output. Defaults to False.
  • progress (str, optional): Type of progress output. Defaults to "auto".

finch_push_image

Push a container image to a repository using Finch, replacing the tag with the image hash.

If the image URL is an ECR repository, it verifies that ECR login credential helper is configured. This tool gets the image hash, creates a new tag using the hash, and pushes the image with the hash tag to the repository.

The workflow is:

  1. Get the image hash using finch image inspect
  2. Create a new tag for the image using the short form of the hash (first 12 characters)
  3. Push the hash-tagged image to the repository

Arguments:

  • image (str): The full image name to push, including the repository URL and tag. For ECR repositories, it must follow the format: <aws_account_id>.dkr.ecr.<region>.amazonaws.com/<repository_name>:<tag>

Example:

# Original image: myrepo/myimage:latest
# After processing: myrepo/myimage:1a2b3c4d5e6f (where 1a2b3c4d5e6f is the short hash)

finch_create_ecr_repo

Check if an ECR repository exists and create it if it doesn't.

This tool checks if the specified ECR repository exists using boto3. If the repository doesn't exist, it creates a new one with the given name with scan on push enabled and immutable tags for enhanced security. The tool requires appropriate AWS credentials configured.

Note: When the server is running in readonly mode, this tool will return an error and will not create any AWS resources.

Arguments:

  • app_name (str): The name of the application/repository to check or create in ECR
  • region (str, optional): AWS region for the ECR repository. If not provided, uses the default region from AWS configuration

Example:

# Check if 'my-app' repository exists in us-west-2 region, create it if it doesn't
{
  "app_name": "my-app",
  "region": "us-west-2"
}

# Response if repository already exists:
{
  "status": "success",
  "message": "ECR repository 'my-app' already exists.",
}

# Response if repository was created:
{
  "status": "success",
  "message": "Successfully created ECR repository 'my-app'.",
}

# Response if server is in readonly mode:
{
  "status": "error",
  "message": "Server running in read-only mode, unable to perform the action"
}

Best Practices

  • Development and Prototyping Only: The tools provided by this MCP server are intended for development and prototyping purposes only. They are not meant for production use cases.
  • Security Considerations: Always review the Dockerfiles and container configurations before building and pushing images.
  • Resource Management: Regularly clean up unused images and containers to free up disk space.
  • Version Control: Keep track of image versions and tags to ensure reproducibility.
  • Error Handling: Implement proper error handling in your applications when using these tools.

Troubleshooting

  • If you encounter permission errors with ECR, verify your AWS credentials and boto3 configuration are properly set up
  • For Finch VM issues, try running finch vm stop and then finch vm start manually
  • If the build fails with errors about missing files, check that your context path is correct
  • For general Finch issues, consult the Finch documentation

Version

Current MCP server version: 0.1.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

awslabs_finch_mcp_server-0.1.2.tar.gz (85.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

awslabs_finch_mcp_server-0.1.2-py3-none-any.whl (29.8 kB view details)

Uploaded Python 3

File details

Details for the file awslabs_finch_mcp_server-0.1.2.tar.gz.

File metadata

  • Download URL: awslabs_finch_mcp_server-0.1.2.tar.gz
  • Upload date:
  • Size: 85.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for awslabs_finch_mcp_server-0.1.2.tar.gz
Algorithm Hash digest
SHA256 a410fa4db01429202c89262a6f94e13dc2dfdb621306dbcce3d5d5b52a105188
MD5 40ef71d6ea01f5d30da2e2aff1c5683f
BLAKE2b-256 b0b46a8f816aa02bc3e60c96b20a0636e523b2b06a8486235433d49b98a755b7

See more details on using hashes here.

Provenance

The following attestation bundles were made for awslabs_finch_mcp_server-0.1.2.tar.gz:

Publisher: release.yml on awslabs/mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file awslabs_finch_mcp_server-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for awslabs_finch_mcp_server-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f530d62d7ee3bdb82b008dead643b0576021bc04bf2b1ad0441cc06291ce916d
MD5 c2e2f8484f5900cc6d199f79d56ec8cb
BLAKE2b-256 4041730d452271d742a444a5b19015b38d0a68f38a4a08db20858153de4b13a4

See more details on using hashes here.

Provenance

The following attestation bundles were made for awslabs_finch_mcp_server-0.1.2-py3-none-any.whl:

Publisher: release.yml on awslabs/mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page