loading…
Search for a command to run...
loading…
An MCP server that integrates with fal.ai to provide AI agents with tools for image generation, text processing, audio synthesis, and model management via a uni
An MCP server that integrates with fal.ai to provide AI agents with tools for image generation, text processing, audio synthesis, and model management via a unified interface.
An MCP (Model Context Protocol) server that integrates with fal.ai to provide seamless access to AI models for image generation, text processing, audio synthesis, and more. Use this package to connect AI agents like Cursor, Claude Desktop, ChatGPT, and other MCP-compatible tools to fal.ai's powerful AI model catalog.
✨ 8 Tools for model discovery, execution, and job management
🔗 4 Resources for configuration and documentation
📝 1 Prompt for image generation assistance
🚀 Dual Transport support (stdio and SSE)
🔒 Type-safe with full TypeScript support
🎯 Zero dependencies on fal.ai SDK (pure HTTP client)
npm install -g @monsoft/mcp-fal-ai
Or install locally in your project:
npm install @monsoft/mcp-fal-ai
git clone https://github.com/Monsoft-Solutions/model-context-protocols.git
cd model-context-protocols/packages/mcp-fal-ai
npm install
npm run build
Before using this MCP server, you need a fal.ai API key:
Configure this MCP server in your AI agent by following the instructions for your specific tool.
Using global npm installation:
{
"mcpServers": {
"fal-ai": {
"command": "mcp-fal-ai",
"env": {
"FAL_API_KEY": "your-fal-api-key-here"
}
}
}
}
Using npx:
{
"mcpServers": {
"fal-ai": {
"command": "npx",
"args": ["-y", "@monsoft/mcp-fal-ai"],
"env": {
"FAL_API_KEY": "your-fal-api-key-here"
}
}
}
}
Locate your Claude Desktop configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.json~/.config/Claude/claude_desktop_config.jsonAdd or update the MCP server configuration:
{
"mcpServers": {
"fal-ai": {
"command": "npx",
"args": ["-y", "@monsoft/mcp-fal-ai"],
"env": {
"FAL_API_KEY": "your-fal-api-key-here"
}
}
}
}
For ChatGPT with MCP support (if available):
{
"mcpServers": {
"fal-ai": {
"command": "npx",
"args": ["-y", "@monsoft/mcp-fal-ai"],
"env": {
"FAL_API_KEY": "your-fal-api-key-here"
}
}
}
}
For any MCP-compatible client:
Using stdio transport:
FAL_API_KEY=your-api-key npx @monsoft/mcp-fal-ai
Using SSE transport:
FAL_API_KEY=your-api-key npx @monsoft/mcp-fal-ai --run-sse --port 3001
Configuration options:
{
"command": "npx",
"args": ["-y", "@monsoft/mcp-fal-ai"],
"env": {
"FAL_API_KEY": "your-fal-api-key-here",
"RUN_SSE": "false",
"PORT": "3001"
}
}
You can also pass configuration via command-line flags:
--fal-api-key or -k: Your fal.ai API key--run-sse or -s: Enable SSE transport (default: false)--port or -p: Port for SSE server (default: 3001)Example:
npx @monsoft/mcp-fal-ai --fal-api-key YOUR_KEY --run-sse --port 3001
Once configured in your AI agent, you can use the fal.ai tools directly in your conversations:
User: Use fal.ai to generate an image of a sunset over mountains
Agent: I'll help you generate that image using fal.ai.
1. First, let me search for image generation models...
[calls: fal-search-models with keyword "image generation"]
2. I'll use the flux-pro model. Let me get its schema...
[calls: fal-get-model-schema with modelId "fal-ai/flux-pro"]
3. Now I'll generate the image...
[calls: fal-enqueue with proper parameters]
4. Checking status...
[calls: fal-get-status with requestId]
5. Retrieving the result...
[calls: fal-get-result with requestId]
User: What AI models are available on fal.ai?
Agent: Let me search for available models...
[calls: fal-list-models with limit 10]
User: Show me the input parameters for the flux-pro model
Agent: I'll fetch the schema for that model...
[calls: fal-get-model-schema with modelId "fal-ai/flux-pro"]
The MCP server exposes the following tools to AI agents:
fal-list-modelsList all available models from fal.ai with optional pagination.
Parameters:
limit (number, optional): Maximum number of models to returnpage (number, optional): Page number for paginationExample:
{
"limit": 20,
"page": 1
}
fal-search-modelsSearch for models by keywords with optional category and limit filtering.
Parameters:
keyword (string, required): Search keyword (e.g., "image generation", "text to speech")limit (number, optional): Maximum number of resultscategory (string, optional): Filter by categoryExample:
{
"keyword": "image generation",
"limit": 10
}
fal-get-model-schemaGet the OpenAPI schema for a specific model to understand its input/output parameters.
Parameters:
modelId (string, required): Model identifier (e.g., "fal-ai/flux-pro")Example:
{
"modelId": "fal-ai/flux-pro"
}
fal-run-syncRun a model synchronously (blocks until completion). Best for fast models.
Parameters:
modelId (string, required): Model identifierinput (object, required): Model-specific input parametersExample:
{
"modelId": "fal-ai/flux-pro",
"input": {
"prompt": "A serene sunset over mountains",
"image_size": "landscape_16_9"
}
}
fal-enqueueQueue a model execution asynchronously. Returns a request ID for status tracking.
Parameters:
modelId (string, required): Model identifierinput (object, required): Model-specific input parametersReturns: { request_id: string }
fal-get-statusCheck the status of an asynchronous job.
Parameters:
requestId (string, required): Request ID from fal-enqueuemodelId (string, required): Model identifierReturns: Status object with state (IN_QUEUE, IN_PROGRESS, COMPLETED, FAILED)
fal-get-resultRetrieve the result of a completed asynchronous job.
Parameters:
requestId (string, required): Request ID from fal-enqueuemodelId (string, required): Model identifierReturns: Model output (automatically downloads and embeds images as base64)
fal-cancelCancel a running or queued asynchronous job.
Parameters:
requestId (string, required): Request ID from fal-enqueuemodelId (string, required): Model identifierThe MCP server provides the following resources:
config://falConfiguration information about the current fal.ai connection.
docs://fal/usageUsage guide showing the typical workflow for generating images and running models.
docs://fal/tools-referenceQuick reference documentation for all available tools.
fal-model://{modelId}/schemaDynamic resource that returns the OpenAPI schema for any model.
Example: fal-model://fal-ai/flux-pro/schema
review-fal-promptA prompt template that helps improve image generation prompts for better fal.ai results.
Parameters:
prompt (string): Your original image promptUsage: The agent can use this prompt to enhance your image generation requests.
The package includes several example scripts for testing and development:
cd packages/mcp-fal-ai
npm run build
FAL_API_KEY=YOUR_KEY npm run example:list-models
This example demonstrates:
FAL_API_KEY=YOUR_KEY npm run example:generate-nano-banana
This example shows:
FAL_API_KEY=YOUR_KEY npm run example:get-model-schema
This example demonstrates:
✅ Core Functionality Complete
🚧 Potential Future Enhancements
fal-upload-file)fal-enqueue-and-wait)packages/mcp-fal-ai/
├── README.md # This file
├── package.json # NPM package configuration
├── tsconfig.json # TypeScript configuration
├── src/
│ ├── index.ts # CLI entry point
│ ├── server/
│ │ └── index.ts # MCP server (stdio/SSE)
│ ├── config/
│ │ └── env.ts # Environment validation (Zod)
│ ├── services/
│ │ └── fal-client.ts # HTTP client for fal.ai API
│ ├── tools/
│ │ └── index.ts # MCP tool implementations
│ ├── resources/
│ │ └── index.ts # MCP resource implementations
│ ├── prompts/
│ │ └── index.ts # MCP prompt implementations
│ ├── types/
│ │ └── model.ts # Type definitions
│ ├── errors/
│ │ ├── api-errors.ts # HTTP error classes
│ │ └── environment-validation-error.ts
│ └── utils/ # Utility functions
├── dist/ # Compiled output (generated)
└── examples/ # Example scripts
AI Agent (Cursor, Claude, ChatGPT, etc.)
↓
MCP Server (stdio or SSE transport)
├─ 8 Tools (discovery, execution, status, control)
├─ 4 Resources (config, docs, schemas)
└─ 1 Prompt (enhancement)
↓
FalClient (HTTP wrapper)
├─ Authentication (Key header)
├─ Request/Response handling
└─ Error mapping
↓
fal.ai API
├─ https://fal.ai/api (models catalog)
├─ https://fal.run (sync execution)
└─ https://queue.fal.run (async execution)
Synchronous Mode (fal-run-sync)
https://fal.runAsynchronous Mode (fal-enqueue → fal-get-status → fal-get-result)
https://queue.fal.runstrict: true)any types (use unknown when type is uncertain)Custom error classes for different HTTP status codes:
401 → UnauthorizedError // Invalid API key
403 → ForbiddenError // Access denied
404 → NotFoundError // Model/endpoint not found
429 → RateLimitError // Too many requests
5xx → ServerError // fal.ai server error
4xx → ApiError // Other client errors
Required:
FAL_API_KEY: Your fal.ai API keyOptional:
RUN_SSE: Enable SSE transport (default: false)PORT: SSE server port (default: 3001)| Package | Purpose |
|---|---|
@modelcontextprotocol/sdk |
MCP server/client SDK |
zod |
Runtime schema validation |
zod-to-json-schema |
Convert Zod to JSON Schema |
yargs |
CLI argument parsing |
undici |
Fast HTTP client |
express |
SSE server (when enabled) |
| Package | Purpose |
|---|---|
typescript |
TypeScript compiler |
@types/node |
Node.js type definitions |
shx |
Cross-platform shell commands |
FAL_API_KEY is set correctlyFAL_API_KEY=xxx npx @monsoft/mcp-fal-ai to testfal-ai/flux-pro)fal-get-model-schemaIssue: Environment validation failed: FAL_API_KEY is required
Solution: Set the FAL_API_KEY environment variable
Issue: UnauthorizedError when calling tools
Solution: Your API key may be invalid or expired
Issue: Tools not appearing in agent Solution: Check MCP server configuration and restart agent
Contributions are welcome! Please follow these guidelines:
typescript.rules)model-context-protocol.rules)anygit clone https://github.com/Monsoft-Solutions/model-context-protocols.git
cd model-context-protocols/packages/mcp-fal-ai
npm install
npm run build
FAL_API_KEY=xxx npm run example:list-models
FAL_API_KEY=xxx npm run example:generate-nano-banana
FAL_API_KEY=xxx npm run example:get-model-schema
MIT License - see LICENSE file for details
Package Version: 0.1.0
Last Updated: October 17, 2025
Status: Production Ready ✅
Add this to claude_desktop_config.json and restart Claude Desktop.
{
"mcpServers": {
"monsoft-mcp-fal-ai": {
"command": "npx",
"args": []
}
}
}