Skip to content

Repository files navigation

ruby-mcp-server

An MCP (Model Context Protocol) server that exposes information from a specific Ruby installation directory. Built with the official mcp gem and served via puma + nginx (HTTPS with RSA certificates).

Inspired by the gem-codesearch MCP server in ruby/ruby-infra-recipe.

Architecture

Claude Code  --HTTPS-->  nginx (TLS, port 18443)  -->  puma (tcp://127.0.0.1:9292)  -->  config.ru

Tools

Tool Source Description
get_ruby_version ruby --version Ruby version, platform, and build description
get_ruby_config ruby -e with RbConfig::CONFIG Build configuration (compiler, flags, configure options, prefix)
get_gem_environment gem env RubyGems environment (version, paths, platforms, sources)
list_gems gem list Installed gems with versions
get_gem_info gem info <name> Detailed information about a specific installed gem
get_openssl_info ruby -e with require "openssl" OpenSSL version, library version, FIPS mode, providers
list_openssl_algorithms ruby -e with OpenSSL::Digest, Cipher, PKey::EC Available OpenSSL digests, ciphers, and elliptic curves
get_shared_libraries ldd <prefix>/bin/ruby Shared libraries linked to the Ruby binary

Prerequisites

  • Ruby >= 4.0
  • Bundler
  • nginx
  • OpenSSL (for TLS certificate generation)

Setup

$ ./script/setup.sh

This runs bundle install, generates self-signed RSA TLS certificates, and validates the nginx configuration.

Usage

Start the server

$ ./script/start.sh

The server auto-detects the Ruby installation from ruby on PATH. To use a specific Ruby, set RUBY_MCP_PREFIX:

$ RUBY_MCP_PREFIX=~/.local/ruby-4.1.0-debug-3ef48ef9c8-openssl-4.1.0-7194354488 ./script/start.sh

Add to Claude Code

Since the server uses a self-signed certificate, Claude Code needs to trust the CA certificate. Set NODE_EXTRA_CA_CERTS before starting Claude Code:

$ export NODE_EXTRA_CA_CERTS=/path/to/ruby-mcp-server/build/ssl/ca.crt

Then add the MCP server:

$ claude mcp add --transport http ruby https://127.0.0.1:18443/

Examples

Example prompts and responses on Claude Code:

❯ What Ruby version is installed?

  Thought for 6s (ctrl+o to expand)

  Called ruby (ctrl+o to expand)

● Ruby 4.1.0dev (master branch, built 2026-05-19) on x86_64-linux, using the
  PRISM parser.

✻ Baked for 12s

❯ What OpenSSL version is linked to Ruby?

  Called ruby (ctrl+o to expand)

● Ruby is linked to OpenSSL 4.1.0-dev (debug build). FIPS mode is off, using the
  default provider. The OpenSSL directory is at
  ~/.local/openssl-4.1.0-dev-debug-7194354488/ssl/certs.

✻ Sautéed for 10s

❯ Show me the Ruby build configuration. Was it compiled with debug flags?

  Called ruby (ctrl+o to expand)

● Yes, this Ruby was compiled with full debug flags:

  - -O0 — no optimization (unoptimized for easier debugging)
  - -g3 -ggdb3 -gdwarf-4 — maximum debug symbol levels
  - --enable-shared — built as a shared library (libruby.so.4.1.0)

  The build is linked against the debug OpenSSL at
  ~/.local/openssl-4.1.0-dev-debug-7194354488 and installed to
  ~/.local/ruby-4.1.0-debug-3ef48ef9c8-openssl-4.1.0-7194354488. Compiler is gcc
  with extensive warning flags enabled.

✻ Brewed for 11s

❯ List the installed gems.

  Called ruby (ctrl+o to expand)

● Here are the installed gems. Notable non-default ones:

  ┌──────────────┬─────────┬──────────────────────────────┐
  │     Gem      │ Version │           Purpose            │
  ├──────────────┼─────────┼──────────────────────────────┤
  │ mcp          │ 1.1.0   │ MCP protocol library         │
  ├──────────────┼─────────┼──────────────────────────────┤
  │ puma         │ 8.0.2   │ Web server                   │
  ├──────────────┼─────────┼──────────────────────────────┤
  │ rack         │ 3.2.6   │ HTTP interface               │
  ├──────────────┼─────────┼──────────────────────────────┤
  │ nio4r        │ 2.7.5   │ Non-blocking I/O             │
  ├──────────────┼─────────┼──────────────────────────────┤
  │ json_schemer │ 2.5.0   │ JSON Schema validation       │
  ├──────────────┼─────────┼──────────────────────────────┤
  │ hana         │ 1.3.7   │ JSON Patch/Pointer           │
  ├──────────────┼─────────┼──────────────────────────────┤
  │ simpleidn    │ 0.2.3   │ IDN handling                 │
  ├──────────────┼─────────┼──────────────────────────────┤
  │ test-unit    │ 3.7.8   │ Testing framework            │
  ├──────────────┼─────────┼──────────────────────────────┤
  │ power_assert │ 3.0.1   │ Test assertions              │
  ├──────────────┼─────────┼──────────────────────────────┤
  │ rake         │ 13.4.2  │ Task runner                  │
  ├──────────────┼─────────┼──────────────────────────────┤
  │ bigdecimal   │ 4.1.2   │ Arbitrary precision decimals │
  └──────────────┴─────────┴──────────────────────────────┘

  The rest are default/bundled gems that ship with Ruby 4.1.0dev.

✻ Worked for 12s

❯ What version of the openssl gem is installed? Show its details.

  Called ruby (ctrl+o to expand)

● The openssl gem version 4.0.2 is installed as a default gem:

  - Authors: Martin Bosslet, SHIBATA Hiroshi, Zachary Scott, Kazuki Yamaguchi
  - Homepage: https://github.com/ruby/openssl
  - Licenses: Ruby, BSD-2-Clause
  - Install path: ~/.local/ruby-4.1.0-debug-3ef48ef9c8-openssl-4.1.0-7194354488/
  lib/ruby/gems/4.1.0+1
  - Description: SSL/TLS and general-purpose cryptography for Ruby

✻ Churned for 11s

❯ What OpenSSL algorithms are available? Is ML-KEM supported?

  Called ruby (ctrl+o to expand)

● Here's a summary of available algorithms:

  Digests: MD4, MD5, RIPEMD160, SHA1, SHA224, SHA256, SHA384, SHA512

  Ciphers: Wide range including AES (128/192/256 in CBC/GCM/CTR/etc.),
  ChaCha20-Poly1305, Camellia, ARIA, Blowfish, CAST5, DES/3DES, IDEA, RC2/RC4,
  SEED, SM4

  Elliptic Curves: Standard NIST curves (prime256v1, secp384r1, secp521r1),
  Brainpool curves, SM2, and various legacy curves

  Regarding ML-KEM: No, it is not supported. ML-KEM (formerly CRYSTALS-Kyber) is
  a post-quantum key encapsulation mechanism. It does not appear in the
  algorithm lists. While OpenSSL 4.1.0-dev may have some PQC work in progress,
  the ML-KEM KEM algorithm wouldn't show up in the digests, ciphers, or curves
  lists — it's a KEM, not any of those. The list_openssl_algorithms tool doesn't
  enumerate KEMs separately, so you'd need to test it directly (e.g., via
  OpenSSL::PKey.generate_key("ML-KEM-768")) to confirm availability.
✻ Brewed for 14s

❯ What shared libraries is the Ruby binary linked to?

  Called ruby (ctrl+o to expand)

● The Ruby binary at
  ~/.local/ruby-4.1.0-debug-3ef48ef9c8-openssl-4.1.0-7194354488/bin/ruby links
  to these shared libraries:

  ┌──────────────────────┬────────────────────────────────────────────────┐
  │       Library        │                      Path                      │
  ├──────────────────────┼────────────────────────────────────────────────┤
  │ libruby.so.4.1       │ ~/.local/ruby-4.1.0-debug-…/lib/libruby.so.4.1 │
  ├──────────────────────┼────────────────────────────────────────────────┤
  │ libz.so.1            │ /lib64/libz.so.1 (zlib)                        │
  ├──────────────────────┼────────────────────────────────────────────────┤
  │ libcrypt.so.2        │ /lib64/libcrypt.so.2                           │
  ├──────────────────────┼────────────────────────────────────────────────┤
  │ libm.so.6            │ /lib64/libm.so.6 (math)                        │
  ├──────────────────────┼────────────────────────────────────────────────┤
  │ libc.so.6            │ /lib64/libc.so.6 (glibc)                       │
  ├──────────────────────┼────────────────────────────────────────────────┤
  │ libgcc_s.so.1        │ /lib64/libgcc_s.so.1 (GCC runtime)             │
  ├──────────────────────┼────────────────────────────────────────────────┤
  │ ld-linux-x86-64.so.2 │ /lib64/ld-linux-x86-64.so.2 (dynamic linker)   │
  └──────────────────────┴────────────────────────────────────────────────┘

  Notable: OpenSSL is not directly linked to the ruby binary itself — it's
  loaded at runtime via the openssl extension (openssl.so), which links to
  libssl/libcrypto separately.

Tests

$ bundle exec rake test

License

GPL-3.0. See LICENSE for details.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages