Skip to main content
Glama

FLUX_1-schnell-infer

Generate images from text prompts using the FLUX.1 model. Specify dimensions, inference steps, and seed parameters for image creation.

Instructions

Call the FLUX.1-schnell endpoint /infer

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYesPrompt
seedNoSeed
randomize_seedNoRandomize seed
widthNoWidth
heightNoHeight
num_inference_stepsNoNumber of inference steps

Implementation Reference

  • Core handler function that executes the Gradio client.submit to the /infer endpoint of FLUX.1-schnell space, processes events, progress, and converts results to MCP format.
    async handleToolCall(
      parameters: Record<string, unknown>,
      progressToken: string | undefined,
      server: Server,
    ): Promise<CallToolResult> {
      const events = [];
      try {
        let result = null;
        const submission: AsyncIterable<GradioEvent> = this.client.submit(
          this.endpointPath.endpoint,
          parameters,
        ) as AsyncIterable<GradioEvent>;
        const progressNotifier = createProgressNotifier(server);
        for await (const msg of submission) {
          if (config.debug) events.push(msg);
          if (msg.type === "data") {
            if (Array.isArray(msg.data)) {
              const hasContent = msg.data.some(
                (item: unknown) => typeof item !== "object",
              );
    
              if (hasContent) result = msg.data;
              if (null === result) result = msg.data;
            }
          } else if (msg.type === "status") {
            if (msg.stage === "error") {
              throw new Error(`Gradio error: ${msg.message || "Unknown error"}`);
            }
            if (progressToken) await progressNotifier.notify(msg, progressToken);
          }
        }
    
        if (!result) {
          throw new Error("No data received from endpoint");
        }
    
        return await this.convertPredictResults(
          this.endpoint.returns,
          result,
          this.endpointPath,
        );
      } catch (error) {
        const errorMessage =
          error instanceof Error ? error.message : String(error);
        throw new Error(`Error calling endpoint: ${errorMessage}`);
      } finally {
        if (config.debug && events.length > 0) {
          await fs.writeFile(
            `${this.mcpToolName}_status_${crypto
              .randomUUID()
              .substring(0, 5)}.json`,
            JSON.stringify(events, null, 2),
          );
        }
      }
    }
  • Entry point for tool execution, processes input arguments (handles files), normalizes progress token, and delegates to handleToolCall.
    async call(
      request: CallToolRequest,
      server: Server,
    ): Promise<CallToolResult> {
      const progressToken = request.params._meta?.progressToken as
        | string
        | number
        | undefined;
    
      const parameters = request.params.arguments as Record<string, unknown>;
    
      // Get the endpoint parameters to check against
      const endpointParams = this.endpoint.parameters;
    
      // Process each parameter, applying handle_file for file inputs
      for (const [key, value] of Object.entries(parameters)) {
        const param = endpointParams.find(
          (p) => p.parameter_name === key || p.label === key,
        );
        if (param && isFileParameter(param) && typeof value === "string") {
          const file = await this.validatePath(value);
          parameters[key] = handle_file(file);
        }
      }
    
      const normalizedToken =
        typeof progressToken === "number"
          ? progressToken.toString()
          : progressToken;
    
      return this.handleToolCall(parameters, normalizedToken, server);
    }
  • src/index.ts:56-71 (registration)
    Creates EndpointWrapper instances for each configured spacePath (including default 'black-forest-labs/FLUX.1-schnell'), sets mcpToolName to 'FLUX_1-schnell-infer', and stores in endpoints map used for registration.
    for (const spacePath of config.spacePaths) {
      try {
        const endpoint = await EndpointWrapper.createEndpoint(
          spacePath,
          workingDir,
        );
        endpoints.set(endpoint.toolDefinition().name, endpoint);
      } catch (e) {
        if (e instanceof Error) {
          console.error(`Error loading ${spacePath}: ${e.message}`);
        } else {
          throw e;
        }
        continue;
      }
    }
  • src/index.ts:77-115 (registration)
    Registers all endpoint tools (including FLUX_1-schnell-infer) in the MCP listTools handler by mapping endpoints to their toolDefinition().
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [
          {
            name: AVAILABLE_FILES,
            description:
              "A list of available file and resources. " +
              "If the User requests things like 'most recent image' or 'the audio' use " +
              "this tool to identify the intended resource." +
              "This tool returns 'resource uri', 'name', 'size', 'last modified'  and 'mime type' in a markdown table",
            inputSchema: {
              type: "object",
              properties: {},
            },
          },
          {
            name: SEARCH_FOR_SPACE,
            description:
              "Use semantic search to find an endpoint on the `Hugging Face Spaces` service. The search term will usually " +
              "be 3-7 words describing a task or activity the Person is trying to accomplish. The results are returned in a markdown table. " +
              "Present all results to the Person. Await specific guidance from the Person before making further Tool calls.",
            inputSchema: {
              type: "object",
              properties: {
                query: {
                  type: "string",
                  // TODO description assumes  user is using claude desktop which has knowledge of HF Spaces.
                  // consider updating for not CLAUDE_DESKTOP mode. 3.7 sys prompt refers to Human as Person
                  description: "The semantic search term to use.",
                },
              },
            },
          },
          ...Array.from(endpoints.values()).map((endpoint) =>
            endpoint.toolDefinition(),
          ),
        ],
      };
    });
  • src/index.ts:167-188 (registration)
    Registers the callTool handler that dispatches calls to the specific EndpointWrapper.call() based on tool name.
      const endpoint = endpoints.get(request.params.name);
    
      if (!endpoint) {
        throw new Error(`Unknown tool: ${request.params.name}`);
      }
      try {
        return await endpoint.call(request, server);
      } catch (error) {
        if (error instanceof Error) {
          return {
            content: [
              {
                type: `text`,
                text: `mcp-hfspace error: ${error.message}`,
              },
            ],
            isError: true,
          };
        }
        throw error;
      }
    });
  • Generates the MCP inputSchema for the tool from the Gradio ApiEndpoint parameters (used by toolDefinition()).
    export function convertApiToSchema(endpoint: ApiEndpoint) {
      const properties: { [key: string]: ParameterSchema } = {};
      const required: string[] = [];
      let propertyCounter = 1;
      const unnamedParameters: Record<string, number> = {};
    
      endpoint.parameters.forEach((param: ApiParameter, index: number) => {
        // Get property name from parameter_name, label, or generate one
        const propertyName =
          param.parameter_name ||
          param.label ||
          `Unnamed Parameter ${propertyCounter++}`;
        if (!param.parameter_name) {
          unnamedParameters[propertyName] = index;
        }
        // Convert parameter using existing function
        properties[propertyName] = convertParameter(param);
    
        // Add to required if no default value
        if (!param.parameter_has_default) {
          required.push(propertyName);
        }
      });
    
      return {
        type: "object",
        properties,
        required,
      };
    }
  • Defines the default HuggingFace space path 'black-forest-labs/FLUX.1-schnell' used to create the FLUX_1-schnell-infer tool.
      spacePaths: (() => {
        const filtered = argv._.filter((arg) => arg.toString().trim().length > 0);
        return filtered.length > 0
          ? filtered
          : ["black-forest-labs/FLUX.1-schnell"];
      })(),
    };
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. However, it offers no information about what the tool does (e.g., image generation, inference), side effects, rate limits, authentication needs, or output format. This leaves the agent completely in the dark about the tool's behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness2/5

Is the description appropriately sized, front-loaded, and free of redundancy?

While concise with a single sentence, the description is under-specified and fails to convey essential information. It does not front-load key details (e.g., purpose), making it inefficient rather than appropriately concise. The sentence does not earn its place by adding value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a 6-parameter tool with no annotations and no output schema, the description is severely incomplete. It does not explain what the tool does, its inputs/outputs, or behavioral traits, leaving critical gaps for the agent to understand and invoke it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with all parameters documented in the input schema (e.g., 'prompt', 'seed', 'width'). The description adds no additional meaning or context beyond what the schema provides, such as explaining how parameters interact or their impact on results. This meets the baseline score of 3 for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Call the FLUX.1-schnell endpoint /infer' is tautological—it restates the tool name without explaining what the tool actually does. It lacks a specific verb and resource (e.g., 'generate images from text prompts using a FLUX model'), making it vague and unhelpful for distinguishing from siblings like 'available-files' or 'search-spaces'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. The description does not mention context, prerequisites, or exclusions, leaving the agent with no clues about appropriate usage scenarios or how it differs from sibling tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/evalstate/mcp-hfspace'

If you have feedback or need assistance with the MCP directory API, please join our Discord server