Module: Ask::MCP

Defined in:
lib/ask/mcp.rb,
lib/ask/mcp/tool.rb,
lib/ask/mcp/client.rb,
lib/ask/mcp/prompt.rb,
lib/ask/mcp/server.rb,
lib/ask/mcp/version.rb,
lib/ask/mcp/resource.rb,
lib/ask/mcp/validator.rb,
lib/ask/mcp/auth/oauth.rb,
lib/ask/mcp/auth/token.rb,
lib/ask/mcp/server/stdio.rb,
lib/ask/mcp/x_mcp_header.rb,
lib/ask/mcp/trace_context.rb,
lib/ask/mcp/transport/sse.rb,
lib/ask/mcp/native/messages.rb,
lib/ask/mcp/transport/stdio.rb,
lib/ask/mcp/adapters/ask_tool.rb,
lib/ask/mcp/adapters/tool_server.rb,
lib/ask/mcp/transport/streamable_http.rb,
lib/ask/mcp/auth/client_id_metadata_document.rb

Defined Under Namespace

Modules: Adapters, Auth, Native, TraceContext, Transport, XMcpHeader Classes: AuthError, Client, ConnectionError, Error, Prompt, ProtocolError, Resource, Server, Tool, ValidationError, Validator

Constant Summary collapse

PROTOCOL_VERSION =

The MCP protocol revision this gem implements and advertises. Single source of truth — Client and Server::Stdio both reference this so the advertised version can never drift between the two sides.

PROTOCOL_VERSION is the legacy default (stateful initialize handshake). SUPPORTED_PROTOCOL_VERSIONS is what the server advertises via server/discover; LATEST_PROTOCOL_VERSION is the stateless 2026-07-28 revision that clients and servers negotiate to.

"2025-06-18"
LATEST_PROTOCOL_VERSION =
"2026-07-28"
SUPPORTED_PROTOCOL_VERSIONS =
[PROTOCOL_VERSION, "2025-11-25", LATEST_PROTOCOL_VERSION].freeze
VERSION =
"0.4.2"

Class Method Summary collapse

Class Method Details

.connect(transport, options = {}) ⇒ Object



56
57
58
# File 'lib/ask/mcp.rb', line 56

def connect(transport, options = {})
  Client.new(transport, options)
end

.from_http(url, options = {}) ⇒ Object



70
71
72
73
# File 'lib/ask/mcp.rb', line 70

def from_http(url, options = {})
  transport = Transport::StreamableHTTP.new(url, options)
  Client.new(transport)
end

.from_sse(url, options = {}) ⇒ Object



65
66
67
68
# File 'lib/ask/mcp.rb', line 65

def from_sse(url, options = {})
  transport = Transport::SSE.new(url, options)
  Client.new(transport)
end

.from_stdio(command, args = [], options = {}) ⇒ Object



60
61
62
63
# File 'lib/ask/mcp.rb', line 60

def from_stdio(command, args = [], options = {})
  transport = Transport::Stdio.new(command, args, options)
  Client.new(transport)
end

.validate!(schema, arguments) ⇒ Object

Validate tool arguments against a JSON Schema input schema



76
77
78
# File 'lib/ask/mcp.rb', line 76

def validate!(schema, arguments)
  Validator.new(schema).validate!(arguments)
end