MCP ExplorerExplorer

Grok2 Image Mcp Server

@fl0w1ndon a year ago
27 MIT
FreeCommunity
AI Systems
grok2-image mcp server

Overview

What is Grok2 Image Mcp Server

Grok2-image-mcp-server is an image generation service based on the Model Context Protocol (MCP). It allows chat assistants to generate images using the Grok-2 model via the MCP protocol.

Use cases

Use cases include generating promotional images for marketing, creating visual content for social media, and assisting in design processes by providing quick image prototypes based on user queries.

How to use

To use grok2-image-mcp-server, you can install it using npx with the command ‘npx -y grok2-image-mcp-server’. You may also configure it with the necessary environment variables like XAIAPI_KEY and XAIAPI_BASE_URL.

Key features

Key features include seamless integration with chat assistants, the ability to generate images based on user input, and compliance with the Model Context Protocol (MCP) for standardized communication.

Where to use

Grok2-image-mcp-server can be used in various fields such as customer service, creative industries, and any application requiring image generation from textual descriptions.

Content

Grok2 Image MCP Server

一个基于 Model Context Protocol (MCP) 的 Grok-2 图像生成服务。此服务允许聊天助手通过 MCP 协议使用 Grok-2 模型生成图像。

安装

使用 npx(推荐)

npx -y grok2-image-mcp-server
{
  "mcpServers": {
    "grok2_image": {
      "command": "npx",
      "args": [
        "grok2-image-mcp-server"
      ],
      "env": {
        "XAIAPI_KEY": "xAI Key"
      }
    }
  }
}

环境变量

XAIAPI_KEY -> xAI Key

XAIAPI_BASE_URL(可选) -> 请求接口代理,若不填则默认使用 https://api.x.ai/v1,遇到无法访问的情况可使用第三方代理,末尾以v1结束

示例:

XAIAPI_BASE_URL=https://api-proxy.me/xai/v1  //某个公开代理,不保证可用性

IMAGE_PROXY_DOMAIN(可选) -> 图片代理域名,若不填则返回默认的图片接口域名 imgen.x.ai,遇到无法访问的情况可使用第三方代理

示例:

IMAGE_PROXY_DOMAIN=https://image.proxy.workers.dev

HTTP_PROXY(可选) -> 网络代理服务器地址,支持 HTTP、HTTPS 协议,可用于解决网络访问问题

示例:

HTTP_PROXY=http://127.0.0.1:7890

HTTP_PROXY=https://user:[email protected]:8080

使用 cloudflare workers 代理图片 URL

遇到图片无法访问的情况,可以考虑使用 cloudflare workers 代理图片 URL,复制以下代码到 cloudflare workers 中,并部署,随后绑定自定义域名,并在环境变量中配置 IMAGE_PROXY_DOMAIN 为自定义域名,例如 https://image.proxy.workers.dev

addEventListener('fetch', event => {
  event.respondWith(handleRequest(event.request))
})

const TARGET_DOMAIN = 'imgen.x.ai'

async function handleRequest(request) {

  const url = new URL(request.url)
  const targetUrl = `https://${TARGET_DOMAIN}${url.pathname}${url.search}`


  const init = {
    method: request.method,
    headers: request.headers,
    body: request.method === 'GET' || request.method === 'HEAD' ? undefined : request.body,
    redirect: 'follow'
  }


  const response = await fetch(targetUrl, init)


  const newHeaders = new Headers(response.headers)
  newHeaders.set('Access-Control-Allow-Origin', '*')

  return new Response(response.body, {
    status: response.status,
    statusText: response.statusText,
    headers: newHeaders
  })
}

许可证

MIT

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers