ExUtcp.Transports.Mcp (ex_utcp v0.3.2)

Copy Markdown View Source

Production-ready MCP (Model Context Protocol) transport implementation for UTCP.

MCP is a protocol for connecting AI assistants to external data sources and tools. This transport supports JSON-RPC 2.0 communication over HTTP/HTTPS with SSE support.

Summary

Functions

Calls a tool using the MCP transport.

Calls a tool with streaming support using the MCP transport.

Returns a specification to start this module under a supervisor.

Closes the MCP transport.

Deregisters a tool provider from the MCP transport.

Creates a new MCP transport with the given options.

Registers a tool provider with the MCP transport.

Sends a JSON-RPC notification to the MCP server.

Sends a JSON-RPC request to the MCP server.

Starts the MCP transport GenServer.

Returns whether this transport supports streaming.

Returns the transport name.

Functions

call_tool(tool_name, args, provider)

Calls a tool using the MCP transport.

call_tool_stream(tool_name, args, provider)

@spec call_tool_stream(String.t(), map(), ExUtcp.Types.provider()) ::
  ExUtcp.Types.stream_call_result()

Calls a tool with streaming support using the MCP transport.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

close()

@spec close() :: :ok

Closes the MCP transport.

deregister_tool_provider(provider)

@spec deregister_tool_provider(ExUtcp.Types.provider()) ::
  ExUtcp.Types.deregister_result()

Deregisters a tool provider from the MCP transport.

new(opts \\ [])

@spec new(keyword()) :: %ExUtcp.Transports.Mcp{
  connection_timeout: term(),
  logger: term(),
  max_retries: term(),
  pool_opts: term(),
  retry_config: term(),
  retry_delay: term()
}

Creates a new MCP transport with the given options.

register_tool_provider(provider)

@spec register_tool_provider(ExUtcp.Types.provider()) ::
  ExUtcp.Types.register_result()

Registers a tool provider with the MCP transport.

send_notification(method, params, provider)

@spec send_notification(String.t(), map(), ExUtcp.Types.mcp_provider()) ::
  :ok | {:error, String.t()}

Sends a JSON-RPC notification to the MCP server.

send_request(method, params, provider)

Sends a JSON-RPC request to the MCP server.

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()

Starts the MCP transport GenServer.

supports_streaming?()

@spec supports_streaming?() :: true

Returns whether this transport supports streaming.

transport_name()

@spec transport_name() :: String.t()

Returns the transport name.