npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@monsoft/mcp-generate-image-openai

v0.1.0

Published

MCP for generating images using OpenAI's API

Readme

MCP Generate Image OpenAI

A Model Context Protocol (MCP) server for generating images using OpenAI's image generation API.

npm version License: MIT

Features

  • Implements the Model Context Protocol for image generation
  • Supports both stdio and Server-Sent Events (SSE) transports
  • Easy integration with OpenAI's DALL-E API
  • Configurable through environment variables
  • Extensible architecture with tools, resources, and prompts

Installation

npm install mcp-generate-image-openai

Prerequisites

  • Node.js 16 or later
  • An OpenAI API key with access to image generation models

Usage

Basic Usage

import { startServer } from 'mcp-generate-image-openai';

// Start the server with configuration from environment variables
startServer()
    .then(() => console.log('Server started successfully'))
    .catch((err) => console.error('Failed to start server:', err));

Manual Configuration

import { startMcpServer, startMcpServerSSE } from 'mcp-generate-image-openai';

// Start with stdio transport
startMcpServer('your-openai-api-key')
    .then(() => console.log('Stdio server started'))
    .catch((err) => console.error('Error:', err));

// Or start with SSE transport
startMcpServerSSE('your-openai-api-key', 3000)
    .then(() => console.log('SSE server started on port 3000'))
    .catch((err) => console.error('Error:', err));

Configuration

Environment Variables

The server can be configured using the following environment variables:

| Variable | Description | Default | | ---------------- | ---------------------------- | -------- | | OPENAI_API_KEY | Your OpenAI API key | Required | | PORT | Port for SSE server | 3000 | | RUN_SSE | Whether to use SSE transport | false |

Command Line Arguments

You can also provide configuration through command-line arguments, which will override environment variables:

node your-script.js --openai-api-key=your-key --port=8080 --run-sse

API

Server Functions

startServer()

The main entry point that automatically configures and starts the server based on environment variables.

startMcpServer(apiKey: string)

Starts an MCP server with stdio transport.

  • Parameters:
    • apiKey: OpenAI API key

startMcpServerSSE(apiKey: string, port: number)

Starts an MCP server with SSE transport.

  • Parameters:
    • apiKey: OpenAI API key
    • port: HTTP server port

SSE Endpoints

When using SSE transport:

  • GET /sse: Establishes an SSE connection
    • Query parameter: sessionId (optional, defaults to 'default')
  • POST /messages: Sends messages to an established session
    • Body parameter: sessionId (optional, defaults to 'default')

Examples

Integrating with a Client Application

// Client code example
import { McpClient } from '@modelcontextprotocol/sdk/client';

const client = new McpClient({
    transport: 'stdio', // or 'sse' for web applications
    serverUrl: 'http://localhost:3000', // Only needed for SSE
});

await client.connect();

// Generate an image
const result = await client.execute({
    toolName: 'generate_image',
    params: {
        prompt: 'A futuristic city with flying cars',
        size: '1024x1024',
    },
});

console.log('Generated image URL:', result.imageUrl);

Development

Project Structure

src/
├── config/      # Environment and configuration handling
├── prompts/     # Prompt templates and definitions
├── resources/   # Resource implementations
├── tools/       # Tool implementations
└── server.ts    # Main server implementation

Building

npm run build

Testing

npm test

License

MIT © [Your Organization]

Contributing

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

Acknowledgements