Skip to main content

A Python class that generates MCP server for any AWS service which has boto3 client

Project description

AWS Service MCP Generator

A Python library that automatically generates MCP servers for any AWS service that has a boto3 client.

Installation

You can install the package using either pip or uv:

Using pip

pip install aws_service_mcp_generator

Using uv

uv add aws_service_mcp_generator

For development installation:

# Clone the repository
git clone https://github.com/kenliao94/aws_service_mcp_generator.git
cd aws_service_mcp_generator

# Create and activate a virtual environment (optional but recommended)
uv venv --python 3.10
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install the package in development mode
uv pip install -e .

Usage

The AWS Service MCP Generator allows you to quickly create MCP servers for any AWS service. Here's how to use it:

Basic Usage

from mcp.server.fastmcp import FastMCP
from aws_service_mcp_generator.generator import AWSToolGenerator


# Initialize FastMCP server
mcp = FastMCP()

# Create a generator for an AWS service
sns_generator = AWSToolGenerator(
    service_name="sns",
    service_display_name="Simple Notification Service",
    mcp=mcp
)

# Generate MCP tools for all operations
sns_generator.generate()

# Start the MCP server
mcp.run()

Advanced Configuration

You can customize the behavior of specific operations:

from mcp.server.fastmcp import FastMCP
from aws_service_mcp_generator.generator import AWSToolGenerator

mcp = FastMCP()

# Configure specific operations
tool_configuration = {
    "list_topics": {
        "documentation_override": "List all SNS topics in the specified region"
    },
    "create_topic": {
        "validator": lambda mcp, client, kwargs: (
            True if kwargs.get("Name") else (False, "Topic name is required")
        )
    },
    "delete_topic": {
        "ignore": True  # Skip this operation
    },
    "publish": {
        # Complete override of the function behavior
        "func_override": lambda mcp, boto3_client_getter, operation: mcp.tool(description="Enhanced SNS publish with additional logging")(
            async def publish_with_logging(message: str, topic_arn: str, region: str = "us-east-1"):
                """Publish a message to an SNS topic with additional logging"""
                try:
                    client = boto3_client_getter(region)
                    print(f"Publishing message to {topic_arn} in {region}")
                    response = client(operation)(Message=message, TopicArn=topic_arn)
                    print(f"Successfully published message with ID: {response.get('MessageId')}")
                    return {
                        "success": True,
                        "message_id": response.get("MessageId"),
                        "timestamp": str(response.get("Timestamp", ""))
                    }
                except Exception as e:
                    print(f"Error publishing message: {str(e)}")
                    return {"error": str(e)}
        )
    }
}

# Create generator with custom configuration
sns_generator = AWSToolGenerator(
    service_name="sns",
    service_display_name="Simple Notification Service",
    mcp=mcp,
    tool_configuration=tool_configuration
)

sns_generator.generate()
mcp.run()

Contributing

Contributions are welcome! Here's how you can contribute to this project:

  1. Fork the Repository

    • Fork the repository on GitHub
  2. Clone Your Fork

    git clone https://github.com/your-username/aws_service_mcp_generator.git
    cd aws_service_mcp_generator
    
  3. Set Up Development Environment

    python -m venv .venv
    source .venv/bin/activate  # On Windows: .venv\Scripts\activate
    pip install -e .
    uv add --dev pyright ruff
    
  4. Create a Branch

    git checkout -b feature/your-feature-name
    
  5. Make Your Changes

    • Implement your feature or bug fix
    • Add or update tests as necessary
    • Update documentation if needed
  6. Run Tests

    pytest
    
  7. Run Linters

    ruff check .
    
  8. Commit Your Changes

    git commit -m "Add feature: your feature description"
    
  9. Push to Your Fork

    git push origin feature/your-feature-name
    
  10. Submit a Pull Request

    • Go to the original repository on GitHub
    • Click "New Pull Request"
    • Select your fork and branch
    • Fill in the PR template with details about your changes

Code Style

This project follows these coding standards:

  • Line length: 99 characters
  • Quote style: Single quotes
  • Python version: 3.10+
  • Use type hints

Running Tests

pytest

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

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

aws_service_mcp_generator-2.0.0.tar.gz (56.7 kB view details)

Uploaded Source

Built Distribution

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

aws_service_mcp_generator-2.0.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file aws_service_mcp_generator-2.0.0.tar.gz.

File metadata

File hashes

Hashes for aws_service_mcp_generator-2.0.0.tar.gz
Algorithm Hash digest
SHA256 db787b4f4f38bcb02b4427c8b8cad7b646deab0c6e4ccf94d80aa5662626eb37
MD5 e55178e017aea016cfb4af0be4ccc943
BLAKE2b-256 4c0bc321a2fa7d33a60cc7d9e5d537f4194f78597dd737b75258906d159f0e36

See more details on using hashes here.

Provenance

The following attestation bundles were made for aws_service_mcp_generator-2.0.0.tar.gz:

Publisher: python-publish.yml on kenliao94/aws_service_mcp_generator

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

File details

Details for the file aws_service_mcp_generator-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for aws_service_mcp_generator-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e575a01bb8837921075df9900a4b8f3eacecdbbf61ef525e62e9503eee88fc12
MD5 562948641d16428ce571ff632b101022
BLAKE2b-256 c5e9c13e672b9fb9e38d92851eced18036b962b7d92df1d186eb2062c09eba7f

See more details on using hashes here.

Provenance

The following attestation bundles were made for aws_service_mcp_generator-2.0.0-py3-none-any.whl:

Publisher: python-publish.yml on kenliao94/aws_service_mcp_generator

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