MCP Configuration
Configure gpt-image-1 MCP with various MCP-compatible clients including Claude Desktop, Cline, and other Model Context Protocol implementations.
Overview
The Model Context Protocol (MCP) enables gpt-image-1 to integrate with various AI clients and applications. This guide covers:
- Client Configuration: Setting up different MCP clients
- Server Configuration: Configuring the MCP server
- Authentication: Managing API keys and credentials
- Advanced Settings: Performance tuning and customization
Quick Start
Basic Configuration
Add the server to your MCP client configuration:
{
"mcpServers": {
"@napolab/gpt-image-1-mcp": {
"command": "node",
"args": ["/absolute/path/to/@napolab/gpt-image-1-mcp-mcp/dist/index.js"],
"env": {
"OPENAI_API_KEY": "sk-your-api-key-here"
}
}
}
}
Client-Specific Configuration
Claude Desktop
Configure in ~/Library/Application Support/Claude/claude_desktop_config.json
(macOS) or %APPDATA%\Claude\claude_desktop_config.json
(Windows):
{
"mcpServers": {
"@napolab/gpt-image-1-mcp": {
"command": "node",
"args": ["/path/to/@napolab/gpt-image-1-mcp-mcp/dist/index.js"],
"env": {
"OPENAI_API_KEY": "sk-your-openai-api-key"
}
}
}
}
Cline (VS Code Extension)
Configure in VS Code settings or .vscode/settings.json
:
{
"cline.mcpServers": {
"@napolab/gpt-image-1-mcp": {
"command": "node",
"args": ["/path/to/@napolab/gpt-image-1-mcp-mcp/dist/index.js"],
"env": {
"OPENAI_API_KEY": "sk-your-openai-api-key"
}
}
}
}
Custom MCP Client
For custom implementations, use the standard MCP protocol:
import { MCPClient } from "@modelcontextprotocol/sdk";
const client = new MCPClient({
name: "@napolab/gpt-image-1-mcp",
version: "1.0.0",
});
await client.connect({
command: "node",
args: ["/path/to/@napolab/gpt-image-1-mcp-mcp/dist/index.js"],
env: {
OPENAI_API_KEY: "sk-your-openai-api-key",
},
});
Configuration Options
Basic Settings
Server Path Configuration
{
"mcpServers": {
"@napolab/gpt-image-1-mcp": {
"command": "node",
"args": ["/absolute/path/to/dist/index.js"],
"cwd": "/path/to/project/root"
}
}
}
Development Mode
{
"mcpServers": {
"@napolab/gpt-image-1-mcp": {
"command": "npm",
"args": ["run", "dev"],
"cwd": "/path/to/@napolab/gpt-image-1-mcp-mcp"
}
}
}
Environment Variables
Required Variables
{
"mcpServers": {
"@napolab/gpt-image-1-mcp": {
"command": "node",
"args": ["/path/to/dist/index.js"],
"env": {
"OPENAI_API_KEY": "sk-your-openai-api-key"
}
}
}
}
Optional Configuration
{
"mcpServers": {
"@napolab/gpt-image-1-mcp": {
"command": "node",
"args": ["/path/to/dist/index.js"],
"env": {
"OPENAI_API_KEY": "sk-your-openai-api-key",
"DEFAULT_IMAGE_QUALITY": "hd",
"DEFAULT_IMAGE_SIZE": "landscape",
"DEFAULT_STYLE": "vivid",
"AUTO_TRANSLATE_JAPANESE": "true",
"DEFAULT_OUTPUT_DIRECTORY": "/path/to/images",
"RATE_LIMIT_REQUESTS_PER_MINUTE": "50"
}
}
}
}
Advanced Configuration
Performance Tuning
{
"mcpServers": {
"@napolab/gpt-image-1-mcp": {
"command": "node",
"args": ["--max-old-space-size=4096", "/path/to/dist/index.js"],
"env": {
"OPENAI_API_KEY": "sk-your-openai-api-key",
"ENABLE_RESULT_CACHING": "true",
"CACHE_DURATION_HOURS": "24",
"API_TIMEOUT_SECONDS": "120"
}
}
}
}
Debugging Configuration
{
"mcpServers": {
"@napolab/gpt-image-1-mcp": {
"command": "node",
"args": ["--inspect=9229", "/path/to/dist/index.js"],
"env": {
"OPENAI_API_KEY": "sk-your-openai-api-key",
"LOG_LEVEL": "debug",
"ENABLE_REQUEST_LOGGING": "true"
}
}
}
}
Multiple Instances
Different Configurations
Run multiple instances with different settings:
{
"mcpServers": {
"@napolab/gpt-image-1-mcp-hd": {
"command": "node",
"args": ["/path/to/dist/index.js"],
"env": {
"OPENAI_API_KEY": "sk-your-openai-api-key",
"DEFAULT_IMAGE_QUALITY": "hd",
"DEFAULT_OUTPUT_DIRECTORY": "/path/to/hd-images"
}
},
"@napolab/gpt-image-1-mcp-standard": {
"command": "node",
"args": ["/path/to/dist/index.js"],
"env": {
"OPENAI_API_KEY": "sk-your-openai-api-key",
"DEFAULT_IMAGE_QUALITY": "standard",
"DEFAULT_OUTPUT_DIRECTORY": "/path/to/standard-images"
}
}
}
}
Environment-Specific Configuration
{
"mcpServers": {
"@napolab/gpt-image-1-mcp-dev": {
"command": "node",
"args": ["/path/to/dist/index.js"],
"env": {
"OPENAI_API_KEY": "sk-your-dev-api-key",
"LOG_LEVEL": "debug",
"RATE_LIMIT_REQUESTS_PER_MINUTE": "10"
}
},
"@napolab/gpt-image-1-mcp-prod": {
"command": "node",
"args": ["/path/to/dist/index.js"],
"env": {
"OPENAI_API_KEY": "sk-your-prod-api-key",
"LOG_LEVEL": "warn",
"RATE_LIMIT_REQUESTS_PER_MINUTE": "100"
}
}
}
}
Security Configuration
API Key Management
Environment File Method
{
"mcpServers": {
"@napolab/gpt-image-1-mcp": {
"command": "node",
"args": ["/path/to/dist/index.js"],
"env": {
"OPENAI_API_KEY": "${OPENAI_API_KEY}"
}
}
}
}
Then set the environment variable:
export OPENAI_API_KEY=sk-your-api-key
Secure File Permissions
# Secure your configuration file
chmod 600 ~/.config/mcp/config.json
Network Security
Localhost Only
{
"mcpServers": {
"@napolab/gpt-image-1-mcp": {
"command": "node",
"args": ["/path/to/dist/index.js"],
"env": {
"OPENAI_API_KEY": "sk-your-api-key",
"BIND_ADDRESS": "127.0.0.1"
}
}
}
}
Docker Configuration
Docker Compose
version: "3.8"
services:
mcp-server:
build: .
environment:
- OPENAI_API_KEY=sk-your-api-key
- DEFAULT_IMAGE_QUALITY=hd
volumes:
- ./images:/app/images
ports:
- "3000:3000"
MCP Client Configuration for Docker
{
"mcpServers": {
"@napolab/gpt-image-1-mcp": {
"command": "docker",
"args": [
"run",
"--rm",
"-e",
"OPENAI_API_KEY=sk-your-api-key",
"-v",
"/host/images:/app/images",
"@napolab/gpt-image-1-mcp-mcp"
]
}
}
}
Validation and Testing
Configuration Validation
Test your configuration:
# Test the server directly
node dist/index.js
# Test with MCP client
mcp-client test @napolab/gpt-image-1-mcp
Health Check
// Health check endpoint
await client.callTool("health-check", {});
Tool Verification
// List available tools
const tools = await client.listTools();
console.log("Available tools:", tools);
// Test image generation
const result = await client.callTool("generate-image", {
prompt: "Test image",
quality: "standard",
});
Troubleshooting
Common Configuration Issues
Server Not Starting
Error: Cannot find module '/path/to/dist/index.js'
Solution: Ensure the path is absolute and the file exists:
# Build the project first
npm run build
# Verify the file exists
ls -la /absolute/path/to/dist/index.js
API Key Issues
Error: Invalid API key
Solution: Verify your OpenAI API key:
# Test API key
curl -H "Authorization: Bearer sk-your-api-key" \
https://api.openai.com/v1/models
Permission Denied
Error: EACCES: permission denied
Solution: Check file permissions:
chmod +x /path/to/dist/index.js
Debug Configuration
Enable Verbose Logging
{
"mcpServers": {
"@napolab/gpt-image-1-mcp": {
"command": "node",
"args": ["/path/to/dist/index.js"],
"env": {
"OPENAI_API_KEY": "sk-your-api-key",
"LOG_LEVEL": "debug",
"ENABLE_REQUEST_LOGGING": "true"
}
}
}
}
Test Connection
// Test MCP connection
try {
await client.connect();
console.log("Connected successfully");
} catch (error) {
console.error("Connection failed:", error);
}
Best Practices
Configuration Management
- Use Absolute Paths: Always use absolute paths for server commands
- Environment Variables: Store sensitive data in environment variables
- Version Control: Don't commit API keys to version control
- Documentation: Document your configuration choices
Performance Optimization
{
"mcpServers": {
"@napolab/gpt-image-1-mcp": {
"command": "node",
"args": [
"--max-old-space-size=4096",
"--optimize-for-size",
"/path/to/dist/index.js"
],
"env": {
"OPENAI_API_KEY": "sk-your-api-key",
"ENABLE_RESULT_CACHING": "true",
"RATE_LIMIT_REQUESTS_PER_MINUTE": "50"
}
}
}
}
Monitoring and Logging
{
"mcpServers": {
"@napolab/gpt-image-1-mcp": {
"command": "node",
"args": ["/path/to/dist/index.js"],
"env": {
"OPENAI_API_KEY": "sk-your-api-key",
"LOG_LEVEL": "info",
"LOG_FILE_PATH": "/var/log/mcp-server.log",
"ENABLE_REQUEST_LOGGING": "false"
}
}
}
}
Platform-Specific Notes
macOS
# Configuration location
~/Library/Application Support/Claude/claude_desktop_config.json
# Example path
/Users/username/projects/@napolab/gpt-image-1-mcp-mcp/dist/index.js
Windows
# Configuration location
%APPDATA%\Claude\claude_desktop_config.json
# Example path (use forward slashes)
C:/Users/username/projects/@napolab/gpt-image-1-mcp-mcp/dist/index.js
Linux
# Configuration location
~/.config/claude/claude_desktop_config.json
# Example path
/home/username/projects/@napolab/gpt-image-1-mcp-mcp/dist/index.js
Next Steps
- Getting Started - Basic setup guide
- Environment Variables - Detailed configuration options
- API Reference - Available tools and methods
- Examples - Usage examples