Module: VectorMCP

Defined in:
lib/vector_mcp.rb,
lib/vector_mcp/util.rb,
lib/vector_mcp/errors.rb,
lib/vector_mcp/server.rb,
lib/vector_mcp/session.rb,
lib/vector_mcp/version.rb,
lib/vector_mcp/image_util.rb,
lib/vector_mcp/definitions.rb,
lib/vector_mcp/handlers/core.rb,
lib/vector_mcp/transport/sse.rb,
lib/vector_mcp/sampling/result.rb,
lib/vector_mcp/server/registry.rb,
lib/vector_mcp/transport/stdio.rb,
lib/vector_mcp/sampling/request.rb,
lib/vector_mcp/server/capabilities.rb,
lib/vector_mcp/server/message_handling.rb

Overview

The VectorMCP module provides a full-featured, opinionated Ruby implementation of the Model Context Protocol (MCP). It gives developers everything needed to spin up an MCP-compatible server—including:

  • Transport adapters (synchronous stdio or asynchronous HTTP + SSE)
  • High-level abstractions for tools, resources, and prompts
  • JSON-RPC 2.0 message handling with sensible defaults and detailed error reporting helpers
  • A small, dependency-free core (aside from optional async transports) that can be embedded in CLI apps, web servers, or background jobs.

At its simplest you can do:

require "vector_mcp"

server = VectorMCP.new(name: "my-mcp-server")
server.register_tool(
  name: "echo",
  description: "Echo back the supplied text",
  input_schema: {type: "object", properties: {text: {type: "string"}}}
) { |args| args["text"] }

server.run # => starts the stdio transport and begins processing JSON-RPC messages

For production you could instead pass an SSE transport instance to run in order to serve multiple concurrent clients over HTTP.

Defined Under Namespace

Modules: Definitions, Handlers, ImageUtil, Sampling, Transport, Util Classes: Error, InitializationError, InternalError, InvalidParamsError, InvalidRequestError, MethodNotFoundError, NotFoundError, ParseError, ProtocolError, SamplingError, SamplingRejectedError, SamplingTimeoutError, Server, ServerError, Session

Constant Summary collapse

VERSION =

The current version of the VectorMCP gem.

"0.2.0"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.loggerObject (readonly)

Returns the value of attribute logger.



53
54
55
# File 'lib/vector_mcp.rb', line 53

def logger
  @logger
end

Class Method Details

.new(*args, **kwargs) ⇒ Object

Creates a new Server instance. This is a thin wrapper around VectorMCP::Server.new; it exists purely for syntactic sugar so you can write VectorMCP.new instead of VectorMCP::Server.new.

Any positional or keyword arguments are forwarded verbatim to the underlying constructor, so refer to VectorMCP::Server#initialize for the full list of accepted parameters.



62
63
64
# File 'lib/vector_mcp.rb', line 62

def new(*args, **kwargs)
  Server.new(*args, **kwargs)
end