Phantom.Request (phantom_mcp v0.7.3)

Copy Markdown View Source

Standard requests and responses for the MCP protocol

Summary

Functions

Invalid request due to no streaming connection being available

Duplicate JSON-RPC request id for a session

Elicitation complete notification

An empty response

Response error

The HTTP routing headers (Mcp-Method, Mcp-Name) do not match the request body, or a required header is missing (SEP-2243, MCP 2026-07-28).

Server encountered an issue

Invalid request

Invalid request due to bad parameters

A request omitted a client capability required to process it.

The request did not declare the Tasks extension (io.modelcontextprotocol/tasks), such as when a tool only runs as a task. See Phantom.Tasks.

The method is not implemented or found

A generic notifiation

Invalid request due to parsing error

Ping request

Prompts List updated notification

The resource is not found.

Resource updated notification

Resources List updated notification

Protocol versions that use the stateless core (no initialize or session).

Every protocol version Phantom supports.

Task status notification

Tools List updated notification

The requested MCP protocol version is unsupported.

Error indicating URL mode elicitation is required before retrying

Annotate a JSON-RPC result with MCP 2026-07-28 cache hints.

Types

t()

@opaque t()

Functions

closed(message \\ nil)

Invalid request due to no streaming connection being available

completion_response(results)

duplicate_request()

Duplicate JSON-RPC request id for a session

elicitation_complete(elicitation_id)

Elicitation complete notification

empty()

An empty response

error(id \\ nil, error)

Response error

header_mismatch(message)

The HTTP routing headers (Mcp-Method, Mcp-Name) do not match the request body, or a required header is missing (SEP-2243, MCP 2026-07-28).

internal_error(message \\ nil)

Server encountered an issue

invalid(message \\ nil)

Invalid request

invalid_params()

invalid_params(data)

Invalid request due to bad parameters

missing_capability(required)

A request omitted a client capability required to process it.

Capabilities are named by path, such as "sampling" or "elicitation.url", and reported to the client as a ClientCapabilities object. Pass that object directly when a name contains dots, such as an extension.

missing_task_capability()

The request did not declare the Tasks extension (io.modelcontextprotocol/tasks), such as when a tool only runs as a task. See Phantom.Tasks.

not_found(message \\ nil)

The method is not implemented or found

notify(content)

A generic notifiation

notify_progress(progress_token, progress, total, message \\ nil)

Progress notifiation

parse_error(message \\ nil)

Invalid request due to parsing error

ping()

Ping request

prompts_updated()

Prompts List updated notification

resource_not_found(data, session)

The resource is not found.

Under MCP 2026-07-28 (SEP-2164) the JSON-RPC code is the standard -32602 Invalid Params. Under earlier protocol versions it remains the MCP-custom -32002 so legacy clients continue to match.

resource_updated(content)

Resource updated notification

resources_updated()

Resources List updated notification

stateless_protocols()

Protocol versions that use the stateless core (no initialize or session).

supported_protocols()

Every protocol version Phantom supports.

task_updated(content)

Task status notification

tools_updated()

Tools List updated notification

unsupported_protocol(requested)

The requested MCP protocol version is unsupported.

url_elicitation_required(elicitations)

Error indicating URL mode elicitation is required before retrying

with_cache(result, opts)

Annotate a JSON-RPC result with MCP 2026-07-28 cache hints.

These are advisory — the server doesn't cache; the hints tell the client (and any intermediate CDN / gateway) how to treat the result. Modeled on HTTP Cache-Control.

Options:

  • :ttl_ms — how long the client may consider the result fresh, in milliseconds (becomes top-level ttlMs on the result)
  • :scope — :public (shareable across users) or :private (per-session); becomes top-level cacheScope

Works on any result map — tools/call, resources/read, prompts/get, list responses, completions:

Tool.text("...") |> Request.with_cache(ttl_ms: 60_000, scope: :public)

Resource.list(links, nil) |> Request.with_cache(ttl_ms: 300_000, scope: :public)