Skip to main content

Image generation and understanding tools using OpenRouter and Zhipu AI

Project description

TF Tools MCP

Image generation and understanding tools for MCP (Model Context Protocol) using OpenRouter and Zhipu AI.

Features

  • Text-to-Image Generation: Generate images from text prompts using multiple models via OpenRouter

    • Supported models: Gemini 2.0 Flash, Seedream 4.5, GPT-5 Image, FLUX.2 Max/Pro
    • Optional AI-powered prompt enhancement using GLM-4.6V
    • Multiple quality levels and layouts
  • Image-to-Image Generation: Transform reference images with text guidance

    • Support for local files and URLs
    • Smart prompt enhancement for various transformation modes
  • Image Understanding: Analyze images with GLM-4.6V vision model

    • Single and batch image analysis
    • Multiple analysis templates: description, OCR, object detection, chart analysis
    • Detailed token usage statistics

Installation

Using uv (recommended)

# Clone the repository
git clone https://github.com/turingfocus/tf_tools_mcp.git
cd tf_tools_mcp

# Install dependencies
uv sync

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

Using pip

# Clone the repository
git clone https://github.com/turingfocus/tf_tools_mcp.git
cd tf_tools_mcp

# Install dependencies
pip install -e .

Configuration

  1. Copy .env.example to .env:
cp .env.example .env
  1. Edit .env and add your API keys:
# Required for image generation
OPENROUTER_API_KEY=your_openrouter_api_key_here

# Required for image understanding
ZHIPUAI_API_KEY=your_zhipuai_api_key_here

# Optional settings
IMAGE_STORAGE_DIR=./generated_images
ENABLE_PROMPT_ENHANCEMENT=true

Getting API Keys

Usage with MCP Clients

Claude Desktop

Add the server to your Claude Desktop configuration:

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

{
  "mcpServers": {
    "tf-tools-mcp": {
      "command": "uv",
      "args": [
        "--directory",
        "/path/to/tf_tools_mcp",
        "run",
        "tf-tools-mcp"
      ],
      "env": {
        "OPENROUTER_API_KEY": "your_api_key_here",
        "ZHIPUAI_API_KEY": "your_api_key_here"
      }
    }
  }
}

Or if installed with pip:

{
  "mcpServers": {
    "tf-tools-mcp": {
      "command": "tf-tools-mcp",
      "env": {
        "OPENROUTER_API_KEY": "your_api_key_here",
        "ZHIPUAI_API_KEY": "your_api_key_here"
      }
    }
  }
}

Restart Claude Desktop and the tools will be available.

Claude Code (CLI)

Install as an MCP server:

claude mcp install tf-tools-mcp

Or configure manually in ~/.config/claude-code/mcp_config.json:

{
  "mcpServers": {
    "tf-tools-mcp": {
      "command": "tf-tools-mcp",
      "env": {
        "OPENROUTER_API_KEY": "your_api_key_here",
        "ZHIPUAI_API_KEY": "your_api_key_here"
      }
    }
  }
}

Available Tools

text_to_image

Generate images from text prompts.

Parameters:

  • prompt (string, required): Text prompt for image generation
  • model (string, required): OpenRouter model ID
    • google/gemini-2.0-flash-exp-image-generation
    • bytedance-seed/seedream-4.5
    • openai/gpt-image-1
    • openai/gpt-image-1-mini
    • black-forest-labs/flux-2-max
    • black-forest-labs/flux-2-pro
  • mode (string, optional): Prompt enhancement mode
    • technical_architecture: For technical diagrams
    • design_mockup: For UI/UX designs
    • promotional_material: For marketing content
    • office_chart: For business charts
    • custom: No enhancement (default)
  • quality (string, optional): Image quality (low, medium, high) - default: medium
  • layout (string, optional): Image layout (square, landscape, portrait) - default: square
  • filename_prefix (string, optional): Prefix for saved filename - default: generated

Example:

Generate an image of a sunset over mountains with vibrant colors
using the Gemini 2.0 Flash model, high quality, landscape layout.

image_to_image

Generate images from reference images with text guidance.

Parameters:

  • prompt (string, required): Text prompt for image generation
  • reference_image (string, required): Path to reference image (local file or URL)
  • model (string, required): OpenRouter model ID (same as text_to_image)
  • mode (string, optional): Prompt enhancement mode
    • content_adjustment: Adjust content while keeping style
    • element_replace: Replace specific elements
    • style_transfer: Transfer artistic style
    • text_modification: Modify text in image
    • custom: No enhancement (default)
  • quality, layout, filename_prefix: Same as text_to_image

Example:

Transform this image to have a cyberpunk aesthetic
using the reference image at /path/to/image.jpg
with the FLUX.2 Max model.

image_understanding

Analyze and understand images using GLM-4.6V.

Parameters:

  • images (array of strings, required): List of image paths or URLs
  • prompt_template (string, optional): Analysis template
    • describe: General image description (default)
    • ocr: Text extraction (OCR)
    • detect_objects: Object detection
    • analyze_chart: Chart/data visualization analysis
    • custom: Use custom prompt
  • custom_prompt (string, optional): Custom prompt (required when prompt_template is custom)
  • model (string, optional): GLM model to use
    • glm-4.6v: High performance
    • glm-4.6v-flashx: Fast (default)

Example:

Analyze this image /path/to/image.jpg
and describe all the objects you can see.

Development

Running Tests

# Run all tests
make test

# Run with real API calls (requires API keys)
make test-real

Project Structure

tf_tools_mcp/
├── tf_tools_mcp/
│   ├── server.py              # MCP server entry point
│   ├── tools/
│   │   ├── img_gen_tools/     # Image generation tools
│   │   │   ├── text_to_image.py
│   │   │   ├── image_to_image.py
│   │   │   ├── constants.py   # Model configurations
│   │   │   ├── types.py       # Type definitions
│   │   │   └── enhancers/     # Prompt enhancement
│   │   └── file_preview_tools/
│   │       └── image_understanding.py
│   └── __init__.py
├── tests/                     # Test suite
├── pyproject.toml            # Project configuration
├── Makefile                  # Build scripts
└── README.md

License

MIT License - see LICENSE file for details

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Support

For issues and questions, please use the GitHub issue tracker.

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

tf_tools_mcp-0.1.2.tar.gz (41.7 kB view details)

Uploaded Source

Built Distribution

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

tf_tools_mcp-0.1.2-py3-none-any.whl (60.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for tf_tools_mcp-0.1.2.tar.gz
Algorithm Hash digest
SHA256 e7f9324fb900b5ad241a5d94ac30f7db95fe56fd7b3fd48db29738f6be248ada
MD5 550fb16b2cfaacdc6560ad89cf7c3f24
BLAKE2b-256 9dd6d42b93777d6ffe5e49881d1f37aab775a51bac14ab76027adc3c4cf44690

See more details on using hashes here.

Provenance

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

Publisher: workflow.yml on A2C-SMCP/tf_tools_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 tf_tools_mcp-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: tf_tools_mcp-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 60.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tf_tools_mcp-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ae58b5e8f127958424583cd4ea07732d7d9eb585f28af7877522c8d99eab6765
MD5 b343f85dc906fbf55f04d49531ea31cc
BLAKE2b-256 9651fa62975357b811258eff6276a50dc82494f6fc913934ab354cb3c9ff4d27

See more details on using hashes here.

Provenance

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

Publisher: workflow.yml on A2C-SMCP/tf_tools_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