VectorMCP

by sergiobayona

157 downloads Not rated yet MIT license

About

A easy-to-use and minimal server implementation for the Model Context Protocol (MCP) in Ruby.

Details

License
MIT license

Explore

MCP Specification Adherence: Implements core server-side aspects of the MCP specification.
Tools: Define and register custom tools (functions) that the LLM can invoke.
Resources: Expose data sources (files, database results, API outputs) for the LLM to read.
Prompts: Provide structured prompt templates the LLM can request and use.
Transport:
Stdio (stable): Simple transport using standard input/output, ideal for process-based servers.
SSE (work-in-progress): Server-Sent Events support is under active development and currently unavailable.
Extensible Handlers: Provides default handlers for core MCP methods, which can be overridden.
Clear Error Handling: Custom error classes mapping to JSON-RPC/MCP error codes.
Ruby-like API: Uses blocks for registering handlers, following idiomatic Ruby patterns.

Add this line to your application's Gemfile:

gem 'vector_mcp'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install vector_mcp

> ⚠️ Heads-up: SSE transport is not yet supported in the released gem. When it lands it will require additional gems (async, async-http, falcon, rack).

server.register_tool(
name: 'echo',
description: 'Returns whatever message you send.',
input_schema: {
type: 'object',
properties: { message: { type: 'string' } },
required: ['message']
}
) { |args, _session| args['message'] }

Tools are functions your server exposes. Use register_tool with a block.

```ruby
server.register_tool(
name: "calculate_sum",
description: "Adds two numbers together.",
input_schema: {
type: "object",
properties: {
a: { type: "number", description: "First number" },
b: { type: "number", description: "Second number" }
},
required: ["a", "b"]
}
) do |args, session|

<!-- Badges (Add URLs later) -->
Gem Version
Build Status
Maintainability
Test Coverage
License: MIT

VectorMCP provides server-side tools for implementing the Model Context Protocol (MCP) in Ruby applications. MCP is a specification for how Large Language Models (LLMs) can discover and interact with external tools, resources, and prompts provided by separate applications (MCP Servers).

This library allows you to easily create MCP servers that expose your application's capabilities (like functions, data sources, or predefined prompt templates) to compatible LLM clients (e.g., Claude Desktop App, custom clients).

Features

MCP Specification Adherence: Implements core server-side aspects of the MCP specification.
Tools: Define and register custom tools (functions) that the LLM can invoke.
Resources: Expose data sources (files, database results, API outputs) for the LLM to read.
Prompts: Provide structured prompt templates the LLM can request and use.
Transport:
Stdio (stable): Simple transport using standard input/output, ideal for process-based servers.
SSE (work-in-progress): Server-Sent Events support is under active development and currently unavailable.
Extensible Handlers: Provides default handlers for core MCP methods, which can be overridden.
Clear Error Handling: Custom error classes mapping to JSON-RPC/MCP error codes.
Ruby-like API: Uses blocks for registering handlers, following idiomatic Ruby patterns.

Installation

Add this line to your application's Gemfile:

gem 'vector_mcp'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install vector_mcp

> ⚠️ Heads-up: SSE transport is not yet supported in the released gem. When it lands it will require additional gems (async, async-http, falcon, rack).

Quick Start

This example creates a simple server that runs over standard input/output and provides one tool.

```ruby
require 'vector_mcp'

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.