Skip to main content
Glama
phuihock
by phuihock

fill_mask

Complete text with missing words using AI. This tool predicts and fills masked tokens in sentences to generate coherent text.

Instructions

Fill masked tokens in text using DeepInfra OpenAI-compatible API.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function that implements the fill_mask tool logic. It constructs a prompt to fill in masked text using the completions API with a specified model and returns the generated response.
        async def fill_mask(text: str) -> str:
            """Fill masked tokens in text using DeepInfra OpenAI-compatible API."""
            model = DEFAULT_MODELS["fill_mask"]
            prompt = f"""Fill in the [MASK] token in the following text with the most appropriate word. Provide the completed sentence and explain your choice.
    
    Text: {text}
    
    Response format: {{"filled_text": "completed sentence", "chosen_word": "word", "explanation": "reasoning"}}"""
            try:
                response = await client.completions.create(
                    model=model,
                    prompt=prompt,
                    max_tokens=200,
                    temperature=0.1,
                )
                if response.choices:
                    return response.choices[0].text
                else:
                    return "Unable to fill mask"
            except Exception as e:
                return f"Error filling mask: {type(e).__name__}: {str(e)}"
  • Conditional block that registers the fill_mask tool with the FastMCP server using the @app.tool() decorator if enabled via ENABLED_TOOLS.
    if "all" in ENABLED_TOOLS or "fill_mask" in ENABLED_TOOLS:
        @app.tool()
  • Configuration for the default model used by the fill_mask tool.
    "fill_mask": os.getenv("MODEL_FILL_MASK", "microsoft/DialoGPT-medium"),
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. While it mentions the API being used, it doesn't describe what 'filling masked tokens' actually does operationally, what the typical output looks like, whether there are rate limits, authentication requirements, or any side effects. The description is too minimal for a tool that presumably performs text transformation.

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 extremely concise - a single sentence that directly states the tool's function and the API used. There's zero wasted language, and it's appropriately sized for what it communicates.

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

Completeness3/5

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

Given that there's an output schema (which handles return values), the description doesn't need to explain outputs. However, for a text transformation tool with no annotations and minimal parameter documentation, the description should provide more context about what 'masked tokens' are and typical use cases. It's minimally adequate but leaves significant gaps in understanding.

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?

The description provides no information about the single parameter 'text' beyond what's in the schema (which has 0% description coverage). However, with only one parameter and no schema descriptions, the baseline is 3 since the description doesn't add any parameter-specific details but also doesn't need to compensate for multiple undocumented parameters.

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 states the tool 'fills masked tokens in text' which gives a general purpose, but it's vague about what 'masked tokens' are and doesn't specify the exact resource or mechanism. It mentions using the 'DeepInfra OpenAI-compatible API' which provides some context, but doesn't clearly distinguish this from sibling tools like text_generation or text_classification.

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 explicit guidance is provided on when to use this tool versus alternatives. The description doesn't mention any specific scenarios, prerequisites, or exclusions. With multiple sibling text-processing tools available, the lack of differentiation leaves the agent without clear usage criteria.

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/phuihock/mcp-deeinfra'

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