home / mcp / cogview-4 text-to-image mcp server

CogView-4 Text-to-Image MCP Server

Provides an MCP-compliant interface to generate images from text prompts using CogView-4 API.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "2716025420-mcp-zhipu-text-to-image-kuma": {
      "command": "python",
      "args": [
        "F:\\mcp3\\varable_try_mcp.py"
      ],
      "env": {
        "ZHIPU_API_KEY": "your_api_key_here"
      }
    }
  }
}

This MCP server provides an interface to generate images from text prompts using the CogView-4 API via the MCP (Model Context Protocol) standard. It enables you to run the image generator locally or remotely and connect through MCP clients such as Claude Desktop or Cline, with robust logging and error handling.

How to use

You can run the MCP server locally or connect to it from MCP clients to generate images from text prompts. The server supports stdio MCP mode and integrates CogView-4 for image generation. To start using it, ensure you have a valid API key from the CogView/Open Platform and enable your MCP client to communicate with the server via the configured stdio interface.

How to install

Prerequisites you need before installation:

- Python 3.8 or newer for the server runtime.

- Node.js and npm for optional npm-based usage.

- A CogView-4 API key obtained from the智谱 AI开放平台.

Additional setup steps

Install the MCP server package globally using npm (recommended for quick start) or install from source and run the Python script directly.

npm install -g mcp-zhipu-text-to-image-kuma

Configuration and environment

Create an environment file or set the variable in your environment. You must provide your CogView-4 API key to authorize image generation.

ZHIPU_API_KEY=your_actual_api_key_here

Run using Python (direct from source)

Run the MCP server directly from the source file via Python.

python F:\mcp3\varable_try_mcp.py

Run using npm via npx (local npm-based start)

Start the MCP server using npm if you installed via npm.

npm start

Configuring clients (Claude Desktop or Cline)

Configure your MCP client to connect to the server through a stdio MCP entry. The following examples show how to set up the server entry on Claude Desktop or Cline. These configurations reference the command used to launch the server and the required environment variable.

{
  "mcpServers": {
    "mcp-zhipu-text-to-image-kuma": {
      "command": "python",
      "args": ["F:\\mcp3\\varable_try_mcp.py"],
      "env": {
        "ZHIPU_API_KEY": "your_api_key_here"
      }
    }
  }
}

Direct run options

You can run the server directly from the source or use the npm-based start command.

# From source
python varable_try_mcp.py

# Or via npm (if installed)
npm start

Tools and endpoints

Primary tool available is generate_image, which creates images from prompts. It accepts a required prompt and optional size and quality parameters. The API endpoint used is the CogView-4 generation service with a 60-second timeout.

Available tools

generate_image

Generates an image from the provided prompt and optional size and quality, returning the image URL and related metadata.