kiro-discord-bot

Media MCP #

mcp-media-server is an optional MCP server for media generation. It is not required for normal bot operation.

Providers #

The server registers providers from available API keys:

API keyEnabled capabilities
GEMINI_API_KEYImage generation, video generation, music generation, text to speech.
OPENAI_API_KEYImage generation and text to speech.

If no provider API key is set, the server exits at startup.

Optional defaults:

VariablePurpose
MEDIA_DEFAULT_IMAGE_MODELOverride the default image model.
MEDIA_DEFAULT_VIDEO_MODELOverride the default video model.
MEDIA_DEFAULT_MUSIC_MODELOverride the default music model.
MEDIA_DEFAULT_TTS_MODELOverride the default text-to-speech model.
MEDIA_SYNC_WAIT_SECHow long legacy generate_* tools wait for an immediate result before returning a job_id.
MEDIA_SYNC_TIMEOUT_SECMaximum runtime for a managed job started by a legacy generate_* tool.

Tools #

ToolPurpose
generate_imageGenerate an image through a managed job. Returns a local path when it finishes quickly, or a job_id when it is still running.
start_image_generationStart an asynchronous image generation job and return a job_id immediately.
start_image_editStart an asynchronous image edit job using image_path and prompt.
start_video_generationStart an asynchronous video generation job and return a job_id immediately.
start_music_generationStart an asynchronous music generation job.
start_text_to_speechStart an asynchronous text-to-speech job.
get_media_jobCheck an asynchronous media job. When status=succeeded, the response includes the local file path.
list_media_jobsList recent asynchronous media jobs.
cancel_media_jobCancel a queued or running asynchronous media job.
edit_imageEdit an existing local image through a managed job. Returns a local path when it finishes quickly, or a job_id when it is still running.
generate_videoGenerate a video through a managed job. Returns a local path when it finishes quickly, or a job_id when it is still running.
generate_musicGenerate music through a managed job. Returns a local path when it finishes quickly, or a job_id when it is still running.
text_to_speechGenerate speech through a managed job. Returns a local path when it finishes quickly, or a job_id when it is still running.
list_modelsList available models, optionally filtered by image, video, music, or tts.

Generated artifacts are returned as local file paths to the agent. Use a channel policy that matches how much media generation cost and egress you want to allow.

Managed And Async Media Jobs #

Media generation can take longer than the MCP client's request timeout. The legacy entrypoints (generate_image, edit_image, generate_video, generate_music, and text_to_speech) are managed facades: they start a tracked job, wait briefly for a quick result, and return either the saved local path or a job_id for polling.

This avoids wasting provider quota on a failed synchronous attempt. If a legacy tool returns a job_id, keep polling that job with get_media_job; do not start another generation for the same request.

The explicit start_* async tools are still available when the agent or operator already wants job-style control from the beginning.

The flow is:

  1. Call a legacy generate_* tool or the matching start_* tool with the same media arguments.
  2. Store the returned job_id.
  3. Poll get_media_job until status is succeeded or failed.
  4. Use the returned local Path when the job succeeds.

The server process keeps jobs in memory, so pending job state survives MCP request timeouts but not a restart of mcp-media-server. Generated files are still written under MEDIA_OUTPUT_DIR.

Environment VariableDefaultMeaning
MEDIA_SYNC_WAIT_SEC20How long a legacy tool waits for an immediate result before returning a job_id. Keep this below the MCP client's request timeout.
MEDIA_SYNC_TIMEOUT_SEC600Maximum runtime for a managed job started by a legacy generate_* tool. Explicit async jobs use MEDIA_JOB_TIMEOUT_SEC instead.
MEDIA_JOB_TIMEOUT_SEC900Maximum runtime for an async media job.
MEDIA_JOB_RETENTION_SEC86400How long completed async job metadata remains listable.
MEDIA_JOB_MAX_ACTIVE4Maximum queued or running async media jobs in one server process. Set 0 to disable the limit.

Operational Notes #

Media tools can spend external provider quota and may produce files that are not suitable for every Discord channel. Keep the media server disabled by default and enable it per channel through /mcp manage when the channel has a clear use case.