McpServer.Completion (HTTP MCP Server v0.6.0)

View Source

Represents completion suggestions for prompt arguments or resource URI template variables.

This module provides a structured way to return auto-completion suggestions to clients. It's used by both prompt argument completion and resource URI template variable completion.

Fields

  • values - List of completion suggestions
  • total - Total number of possible completions (optional)
  • has_more - Whether there are more completions available beyond those returned (optional)

Examples

iex> completion = McpServer.Completion.new(
...>   values: ["Alice", "Bob", "Charlie"]
...> )
%McpServer.Completion{
  values: ["Alice", "Bob", "Charlie"]
}

iex> completion = McpServer.Completion.new(
...>   values: ["option1", "option2"],
...>   total: 100,
...>   has_more: true
...> )
%McpServer.Completion{
  values: ["option1", "option2"],
  total: 100,
  has_more: true
}

Summary

Functions

Creates a new Completion struct.

Types

t()

@type t() :: %McpServer.Completion{
  has_more: boolean() | nil,
  total: integer() | nil,
  values: [String.t()]
}

Functions

new(opts)

@spec new(keyword()) :: t()

Creates a new Completion struct.

Parameters

  • opts - Keyword list of completion options:
    • :values (required) - List of completion suggestions
    • :total - Total number of possible completions
    • :has_more - Whether there are more completions available

Examples

iex> McpServer.Completion.new(values: ["Alice", "Bob"])
%McpServer.Completion{values: ["Alice", "Bob"]}

iex> McpServer.Completion.new(
...>   values: ["file1.txt", "file2.txt"],
...>   total: 50,
...>   has_more: true
...> )
%McpServer.Completion{
  values: ["file1.txt", "file2.txt"],
  total: 50,
  has_more: true
}

iex> McpServer.Completion.new(values: [], total: 0, has_more: false)
%McpServer.Completion{values: [], total: 0, has_more: false}