Skip to main content
Glama

FLUX_1-schnell-infer

Generate images from text prompts using the FLUX.1 model via Hugging Face Spaces. Specify dimensions, steps, and seeds to create custom visual content.

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 logic for executing the tool: submits parameters to the Gradio client for the /infer endpoint of FLUX.1-schnell space, handles progress and data events, converts results to MCP content.
    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),
          );
        }
      }
    }
  • MCP CallToolRequestSchema handler that looks up the endpoint by tool name ('FLUX_1-schnell-infer') and invokes endpoint.call().
    server.setRequestHandler(CallToolRequestSchema, async (request) => {
      if (AVAILABLE_FILES === request.params.name) {
        return {
          content: [
            {
              type: `resource`,
              resource: {
                uri: `/available-files`,
                mimeType: `text/markdown`,
                text: await workingDir.generateResourceTable(),
              },
            },
          ],
        };
      }
    
      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;
      }
    });
  • src/index.ts:75-95 (registration)
    Registers the ListToolsRequestSchema handler which includes tool definitions for all endpoints, exposing the 'FLUX_1-schnell-infer' tool.
    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: {},
            },
          },
          ...Array.from(endpoints.values()).map((endpoint) =>
            endpoint.toolDefinition(),
          ),
        ],
      };
    });
  • src/index.ts:54-69 (registration)
    Creates EndpointWrapper instances for configured spacePaths (defaults to 'evalstate/FLUX.1-schnell'), generates tool name 'FLUX_1-schnell-infer', and registers in endpoints Map by name.
    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;
      }
    }
  • Parses space path 'evalstate/FLUX.1-schnell/infer' and formats mcpToolName to 'FLUX_1-schnell-infer' by replacing invalid characters like '.' with '_'.
    export function parsePath(path: string): EndpointPath {
      const parts = path.replace(/^\//, "").split("/");
    
      if (parts.length != 3) {
        throw new Error(
          `Invalid Endpoint path format [${path}]. Use or vendor/space/endpoint`,
        );
      }
    
      const [owner, space, rawEndpoint] = parts;
      return {
        owner,
        space,
        endpoint: isNaN(Number(rawEndpoint))
          ? `/${rawEndpoint}`
          : parseInt(rawEndpoint),
        mcpToolName: formatMcpToolName(space, rawEndpoint),
        mcpDisplayName: formatMcpDisplayName(space, rawEndpoint),
      };
    
      function formatMcpToolName(space: string, endpoint: string | number) {
        return `${space}-${endpoint}`.replace(/[^a-zA-Z0-9_-]/g, "_").slice(0, 64);
      }
    
      function formatMcpDisplayName(space: string, endpoint: string | number) {
        return `${space} endpoint /${endpoint}`;
      }
    }
  • Default spacePaths configuration to ['evalstate/FLUX.1-schnell'] if no args provided, which generates the FLUX_1-schnell-infer tool.
      spacePaths: (() => {
        const filtered = argv._.filter((arg) => arg.toString().trim().length > 0);
        return filtered.length > 0 ? filtered : ["evalstate/FLUX.1-schnell"];
      })(),
    };
  • Generates the tool definition including name 'FLUX_1-schnell-infer', description, and inputSchema converted from the Gradio /infer endpoint API.
    toolDefinition() {
      return {
        name: this.mcpToolName,
        description: `Call the ${this.mcpDescriptionName()}`,
        inputSchema: convertApiToSchema(this.endpoint),
      };
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It only states the endpoint call without explaining what the tool does (e.g., image generation), its effects (e.g., creates an image file), performance traits, or any constraints like rate limits or authentication needs, resulting in insufficient transparency for a tool with multiple parameters.

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

Conciseness4/5

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

The description is a single, concise sentence that directly states the action. It is front-loaded with no unnecessary words, making it efficient. However, it lacks depth, which is a content issue rather than a structural one, so it scores well for conciseness.

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

Completeness2/5

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

Given the tool's complexity with 6 parameters and no output schema, the description is incomplete. It fails to explain the tool's purpose, behavior, or output, leaving significant gaps. Without annotations or a clear context, it does not provide enough information for effective use, especially compared to sibling tools.

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%, providing basic descriptions for all parameters. The description adds no additional meaning beyond the schema, such as explaining parameter interactions or use cases. However, since the schema is fully documented, the baseline score of 3 is appropriate as the description does not compensate but also does not detract.

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' restates the tool name and title without specifying what the tool does. It mentions an endpoint but lacks a clear verb and resource, such as generating images or processing prompts, making the purpose vague and not distinguishing it from sibling tools 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 any context, prerequisites, or exclusions, leaving the agent with no information on 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/xiyuefox/mcp-hfspace'

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