Module: VectorMCP

Defined in:
lib/vector_mcp.rb,
lib/vector_mcp/tool.rb,
lib/vector_mcp/util.rb,
lib/vector_mcp/errors.rb,
lib/vector_mcp/logger.rb,
lib/vector_mcp/server.rb,
lib/vector_mcp/session.rb,
lib/vector_mcp/version.rb,
lib/vector_mcp/security.rb,
lib/vector_mcp/image_util.rb,
lib/vector_mcp/invocation.rb,
lib/vector_mcp/log_filter.rb,
lib/vector_mcp/middleware.rb,
lib/vector_mcp/rails/tool.rb,
lib/vector_mcp/definitions.rb,
lib/vector_mcp/token_store.rb,
lib/vector_mcp/handlers/core.rb,
lib/vector_mcp/middleware/base.rb,
lib/vector_mcp/middleware/hook.rb,
lib/vector_mcp/request_context.rb,
lib/vector_mcp/sampling/result.rb,
lib/vector_mcp/server/registry.rb,
lib/vector_mcp/sampling/request.rb,
lib/vector_mcp/middleware/context.rb,
lib/vector_mcp/middleware/manager.rb,
lib/vector_mcp/util/token_sweeper.rb,
lib/vector_mcp/security/middleware.rb,
lib/vector_mcp/server/capabilities.rb,
lib/vector_mcp/security/auth_result.rb,
lib/vector_mcp/middleware/anonymizer.rb,
lib/vector_mcp/security/auth_manager.rb,
lib/vector_mcp/transport/http_stream.rb,
lib/vector_mcp/security/authorization.rb,
lib/vector_mcp/server/message_handling.rb,
lib/vector_mcp/security/session_context.rb,
lib/vector_mcp/security/strategies/custom.rb,
lib/vector_mcp/security/strategies/api_key.rb,
lib/vector_mcp/security/strategies/jwt_token.rb,
lib/vector_mcp/transport/base_session_manager.rb,
lib/vector_mcp/transport/http_stream/event_store.rb,
lib/vector_mcp/transport/http_stream/stream_handler.rb,
lib/vector_mcp/transport/http_stream/session_manager.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 (streamable HTTP)
  • 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 HTTP stream transport and begins processing JSON-RPC messages

The default HTTP stream transport supports multiple concurrent clients over HTTP.

Defined Under Namespace

Modules: Definitions, Handlers, ImageUtil, LogFilter, Middleware, Rails, Sampling, Security, Transport, Util Classes: Error, ForbiddenError, InitializationError, InternalError, InvalidParamsError, InvalidRequestError, Invocation, Logger, MethodNotFoundError, NotFoundError, ParseError, ProtocolError, RequestContext, SamplingError, SamplingRejectedError, SamplingTimeoutError, Server, ServerError, Session, TokenStore, Tool, UnauthorizedError

Constant Summary collapse

VERSION =

The current version of the VectorMCP gem.

"0.6.0"

Class Method Summary collapse

Class Method Details

.deprecation_warning(message) ⇒ void

This method returns an undefined value.

Emit a deprecation warning. Centralized so tests and applications can intercept or silence deprecations in one place.

Parameters:

  • message (String)

    description of the deprecated usage and its replacement



69
70
71
# File 'lib/vector_mcp.rb', line 69

def deprecation_warning(message)
  warn("[DEPRECATION] VectorMCP: #{message}")
end

.loggerVectorMCP::Logger

Get the default logger

Returns:



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

def logger
  @logger ||= Logger.for("vectormcp")
end

.logger_for(component) ⇒ VectorMCP::Logger

Get a component-specific logger

Parameters:

  • component (String, Symbol)

    the component name

Returns:



55
56
57
# File 'lib/vector_mcp.rb', line 55

def logger_for(component)
  Logger.for(component)
end

.newObject

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.



80
81
82
# File 'lib/vector_mcp.rb', line 80

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