Skip to main content
Glama
devhub

DevHub CMS MCP

Official
by devhub

upload_image

Add images to the DevHub CMS media gallery by uploading base64-encoded files in webp, jpeg, or png formats with specified filenames.

Instructions

Upload an image to the DevHub media gallery

Supports webp, jpeg and png images

Args:
    base64_image_content: Base 64 encoded content of the image file
    filename: Filename including the extension

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
base64_image_contentYes
filenameYes

Implementation Reference

  • The upload_image tool handler: uploads a base64-encoded image to the DevHub CMS media gallery using the API, returns image ID and path.
    @mcp.tool()
    def upload_image(base64_image_content: str, filename: str) -> str:
        """Upload an image to the DevHub media gallery
    
        Supports webp, jpeg and png images
    
        Args:
            base64_image_content: Base 64 encoded content of the image file
            filename: Filename including the extension
        """
        client, base_url = get_client()
        payload = {
            'type': 'image',
            'upload': {
                'file': base64_image_content,
                'filename': filename,
            }
        }
        r = client.post(
            '{}images/'.format(base_url),
            json=payload,
        )
        image = r.json()
        return f"""
    Image ID: {image['id']}
    Image Path (for use in HTML src attributes): {image['absolute_path']}
    """
  • Registration of the upload_image tool via the @mcp.tool() decorator on the FastMCP server instance.
    @mcp.tool()
  • Input schema defined by function parameters (base64_image_content: str, filename: str) and docstring describing usage and supported formats.
    def upload_image(base64_image_content: str, filename: str) -> str:
        """Upload an image to the DevHub media gallery
    
        Supports webp, jpeg and png images
    
        Args:
            base64_image_content: Base 64 encoded content of the image file
            filename: Filename including the extension
        """
  • Helper function get_client() used by upload_image to obtain OAuth client and base URL for DevHub API calls.
    def get_client():
        """Get DevHub API client and base_url."""
        client = OAuth1Session(
            os.environ['DEVHUB_API_KEY'],
            client_secret=os.environ['DEVHUB_API_SECRET'])
        base_url = '{}/api/v2/'.format(os.environ['DEVHUB_BASE_URL'])
        return client, base_url

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/devhub/devhub-cms-mcp'

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