Skip to main content
Glama
bendusy

Pollinations MCP Server

by bendusy

generate_text

Generate AI text content using Pollinations.ai models. Provide a prompt to create text responses, customize with model selection, system instructions, and output formatting options.

Instructions

使用Pollinations.ai生成文本

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYes文本提示词
modelNo要使用的模型(如openai、mistral等)openai
seedNo随机种子值(用于生成一致的结果)
systemNo系统提示词(设置AI行为)
jsonNo是否返回JSON格式的响应
privateNo设置为true可使响应私有

Implementation Reference

  • The primary handler function for the 'generate_text' tool. Validates input arguments, calls the PollinationsTextAPI to generate text, formats the response, and handles errors appropriately.
    private async handleGenerateText(args: any) {
      try {
        if (!this.isValidGenerateTextArgs(args)) {
          throw this.handleValidationError('无效的文本生成参数');
        }
    
        const { prompt, model = 'openai', seed, system, json = false, private: isPrivate = false } = args;
    
        const result = await this.textAPI.generateTextGet(prompt, {
          model,
          seed,
          json,
          system,
          private: isPrivate
        });
    
        return {
          content: [
            {
              type: 'text',
              text: typeof result === 'string' ? result : JSON.stringify(result, null, 2),
            },
          ],
        };
      } catch (error) {
        // 处理所有错误
        let pollinationsError: PollinationsError;
        
        if (error instanceof PollinationsError) {
          pollinationsError = error;
        } else {
          pollinationsError = this.handleApiError(error);
        }
        
        return {
          content: [
            {
              type: 'text',
              text: pollinationsError.toUserFriendlyMessage(),
            },
          ],
          isError: true,
        };
      }
    }
  • Type guard function that validates the input arguments for the generate_text tool, ensuring correct types for prompt, model, seed, system, json, and private parameters.
    private isValidGenerateTextArgs(args: any): args is {
      prompt: string;
      model?: string;
      seed?: number;
      system?: string;
      json?: boolean;
      private?: boolean;
    } {
      return (
        typeof args === 'object' &&
        args !== null &&
        typeof args.prompt === 'string' &&
        (args.model === undefined || typeof args.model === 'string') &&
        (args.seed === undefined || typeof args.seed === 'number') &&
        (args.system === undefined || typeof args.system === 'string') &&
        (args.json === undefined || typeof args.json === 'boolean') &&
        (args.private === undefined || typeof args.private === 'boolean')
      );
    }
  • src/index.ts:227-263 (registration)
    Tool registration in the ListToolsRequestSchema handler, defining the name, description, and input schema for the 'generate_text' tool.
    {
      name: 'generate_text',
      description: '使用Pollinations.ai生成文本',
      inputSchema: {
        type: 'object',
        properties: {
          prompt: {
            type: 'string',
            description: '文本提示词',
          },
          model: {
            type: 'string',
            description: '要使用的模型(如openai、mistral等)',
            default: 'openai',
          },
          seed: {
            type: 'number',
            description: '随机种子值(用于生成一致的结果)',
          },
          system: {
            type: 'string',
            description: '系统提示词(设置AI行为)',
          },
          json: {
            type: 'boolean',
            description: '是否返回JSON格式的响应',
            default: false,
          },
          private: {
            type: 'boolean',
            description: '设置为true可使响应私有',
            default: false,
          },
        },
        required: ['prompt'],
      },
    },
  • Helper method in PollinationsTextAPI class that constructs the API URL and makes the HTTP GET request to Pollinations.ai text generation endpoint.
    async generateTextGet(prompt: string, options: {
      model?: string;
      seed?: number;
      json?: boolean;
      system?: string;
      private?: boolean;
    } = {}) {
      const { model = 'openai', seed, json = false, system, private: isPrivate = false } = options;
      
      let url = `${this.baseTextUrl}/${encodeURIComponent(prompt)}?model=${model}`;
      
      if (seed !== undefined) {
        url += `&seed=${seed}`;
      }
      
      if (json) {
        url += `&json=true`;
      }
      
      if (system) {
        url += `&system=${encodeURIComponent(system)}`;
      }
      
      if (isPrivate) {
        url += `&private=true`;
      }
      
      try {
        const response = await axios.get(url);
        return response.data;
      } catch (error) {
        throw new Error(`文本生成失败: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • src/index.ts:274-275 (registration)
    Dispatch case in the CallToolRequestSchema handler that routes 'generate_text' calls to the handleGenerateText method.
    case 'generate_text':
      return this.handleGenerateText(request.params.arguments);
Behavior2/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. It mentions using Pollinations.ai but doesn't describe key behaviors like rate limits, authentication needs, response format, or potential errors. For a text generation tool with no annotation coverage, this leaves significant gaps in understanding how it operates.

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

Conciseness5/5

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

The description is a single, efficient sentence with zero waste. It's front-loaded and appropriately sized for its purpose, making it easy to parse quickly without unnecessary elaboration.

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 complexity of a text generation tool with 6 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain return values, error handling, or behavioral traits, leaving the agent with insufficient context to use the tool effectively beyond basic parameter input.

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%, so the schema already documents all 6 parameters thoroughly. The description adds no additional meaning beyond what the schema provides, such as explaining interactions between parameters or usage examples. Baseline 3 is appropriate when the schema does the heavy lifting.

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

Purpose3/5

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

The description '使用Pollinations.ai生成文本' states the action (generate) and resource (text) but is vague about scope and differentiation. It doesn't specify what kind of text is generated (creative, technical, etc.) or how it differs from sibling tools like generate_image, which also uses Pollinations.ai but for images. The purpose is understandable but lacks specificity.

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

Usage Guidelines2/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. It doesn't mention prerequisites, limitations, or compare it to sibling tools like generate_image for image generation or download_image for downloading content. The description only states what it does, not when it's appropriate.

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/bendusy/pollinations-mcp'

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