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
- Copy
.env.exampleto.env:
cp .env.example .env
- Edit
.envand 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
- OpenRouter API Key: Sign up at https://openrouter.ai/ and get your key from https://openrouter.ai/keys
- ZhipuAI API Key: Sign up at https://open.bigmodel.cn/ and get your key from https://open.bigmodel.cn/usercenter/apikeys
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 generationmodel(string, required): OpenRouter model IDgoogle/gemini-2.0-flash-exp-image-generationbytedance-seed/seedream-4.5openai/gpt-image-1openai/gpt-image-1-miniblack-forest-labs/flux-2-maxblack-forest-labs/flux-2-pro
mode(string, optional): Prompt enhancement modetechnical_architecture: For technical diagramsdesign_mockup: For UI/UX designspromotional_material: For marketing contentoffice_chart: For business chartscustom: No enhancement (default)
quality(string, optional): Image quality (low,medium,high) - default:mediumlayout(string, optional): Image layout (square,landscape,portrait) - default:squarefilename_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 generationreference_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 modecontent_adjustment: Adjust content while keeping styleelement_replace: Replace specific elementsstyle_transfer: Transfer artistic styletext_modification: Modify text in imagecustom: 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 URLsprompt_template(string, optional): Analysis templatedescribe: General image description (default)ocr: Text extraction (OCR)detect_objects: Object detectionanalyze_chart: Chart/data visualization analysiscustom: Use custom prompt
custom_prompt(string, optional): Custom prompt (required whenprompt_templateiscustom)model(string, optional): GLM model to useglm-4.6v: High performanceglm-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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tf_tools_mcp-0.1.5.tar.gz.
File metadata
- Download URL: tf_tools_mcp-0.1.5.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2e1247488fbe1235e6d89aaa76d57e323dd9873cfc6581b7d91a0b6ff66c24a
|
|
| MD5 |
c7520da1ccfd77fb6c8cad534fd91ef2
|
|
| BLAKE2b-256 |
e9d19f61115722dac1f5f91e4c3b7323bc910f0606f68d399467c8789e83deac
|
Provenance
The following attestation bundles were made for tf_tools_mcp-0.1.5.tar.gz:
Publisher:
workflow.yml on A2C-SMCP/tf_tools_mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tf_tools_mcp-0.1.5.tar.gz -
Subject digest:
b2e1247488fbe1235e6d89aaa76d57e323dd9873cfc6581b7d91a0b6ff66c24a - Sigstore transparency entry: 936650511
- Sigstore integration time:
-
Permalink:
A2C-SMCP/tf_tools_mcp@8d00c182a6a38de160c9aa6984f95bf75153ba8e -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/A2C-SMCP
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@8d00c182a6a38de160c9aa6984f95bf75153ba8e -
Trigger Event:
push
-
Statement type:
File details
Details for the file tf_tools_mcp-0.1.5-py3-none-any.whl.
File metadata
- Download URL: tf_tools_mcp-0.1.5-py3-none-any.whl
- Upload date:
- Size: 60.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0035be132ed30c9a93a796792ceae475b1e1a6d80cfe75bac8a88242ce416888
|
|
| MD5 |
24a2c6ab5592251b433c1671332b8dae
|
|
| BLAKE2b-256 |
c064134ce230b6772b59c229fa0907a6c30ce6901feaf12e9d10647a1890a060
|
Provenance
The following attestation bundles were made for tf_tools_mcp-0.1.5-py3-none-any.whl:
Publisher:
workflow.yml on A2C-SMCP/tf_tools_mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tf_tools_mcp-0.1.5-py3-none-any.whl -
Subject digest:
0035be132ed30c9a93a796792ceae475b1e1a6d80cfe75bac8a88242ce416888 - Sigstore transparency entry: 936650513
- Sigstore integration time:
-
Permalink:
A2C-SMCP/tf_tools_mcp@8d00c182a6a38de160c9aa6984f95bf75153ba8e -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/A2C-SMCP
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@8d00c182a6a38de160c9aa6984f95bf75153ba8e -
Trigger Event:
push
-
Statement type: