mcp_stdio_ruby 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: fab19f99766156cb36a1a619581b700a34be89ceca3e19edca0288cfc8990302
4
+ data.tar.gz: 477e27d118fd1e09d0177dd5ffc15e05576708a35175379c76996259e0bf0b85
5
+ SHA512:
6
+ metadata.gz: e4408b311907e9230e06adaadf9be8538fa5462631c5ff7b5feec212879afc67359095d91e087538efa1d70a6e9724eb60dd9bc51b2a38433ff8f8d09be3c520
7
+ data.tar.gz: 849ed98678d2d398bd7e4d18ea394be0c33c7363e265aa67ace6aa7900f44858ed544d9f18dcfaa457c0b3c3a458bdb4db069179ab6c6a1266d5f7aa7ed5f04c
@@ -0,0 +1,10 @@
1
+ {
2
+ "mcpServers": {
3
+ "hello-stdio-ruby": {
4
+ "command": "ruby",
5
+ "args": [
6
+ "$HOME/gemini-cli-codeassist/mcp-stdio-ruby/main.rb"
7
+ ]
8
+ }
9
+ }
10
+ }
data/.gitignore ADDED
@@ -0,0 +1,29 @@
1
+ # Ruby
2
+ *.gem
3
+ *.rbc
4
+ /.bundle/
5
+ /vendor/bundle/
6
+ /spec/reports/
7
+ /spec/examples.txt
8
+ .rspec_status
9
+ /coverage/
10
+ /tmp/
11
+ *.log
12
+ /doc/
13
+ /.yardoc/
14
+
15
+ # Environment
16
+ .env
17
+ .env*.local
18
+
19
+ # OS
20
+ .DS_Store
21
+ Thumbs.db
22
+
23
+ # IDEs
24
+ .idea/
25
+ .vscode/
26
+ *.iml
27
+ .project
28
+ .target
29
+ .settings/
data/.rubocop.yml ADDED
@@ -0,0 +1,11 @@
1
+ AllCops:
2
+ NewCops: enable
3
+ SuggestExtensions: false
4
+ TargetRubyVersion: 3.1 # Assuming a reasonably modern Ruby version
5
+
6
+ Style/StringLiterals:
7
+ Enabled: true
8
+ EnforcedStyle: single_quotes
9
+
10
+ Layout/LineLength:
11
+ Max: 120
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.4.8
data/GEMINI.md ADDED
@@ -0,0 +1,55 @@
1
+ # Gemini Code Assistant Context
2
+
3
+ This document provides context for the Gemini Code Assistant to understand the project and assist in development.
4
+
5
+ ## Project Overview
6
+
7
+ This is a **Ruby based Model Context Protocol (MCP) server**. It is designed to expose tools (like `greet`) over standard input/output (stdio) for integration with MCP clients (such as Claude Desktop or Gemini clients).
8
+
9
+ ## Key Technologies
10
+
11
+ * **Language:** Ruby
12
+ * **SDK:** `mcp` (Model Context Protocol SDK)
13
+ https://github.com/modelcontextprotocol/ruby-sdk
14
+
15
+ ## Project Structure
16
+
17
+ * `main.rb`: Main entry point (Ruby).
18
+ * `lib/`: Application source code and tools.
19
+ * `greet_tool.rb`: Example tool implementation.
20
+ * `app_logger.rb`: Logging functionality.
21
+ * `spec/`: RSpec test suite.
22
+ * `Makefile`: Development shortcuts (test, lint, clean).
23
+
24
+ ## Development Setup
25
+
26
+ 1. **Install Dependencies:**
27
+ ```bash
28
+ bundle install
29
+ ```
30
+
31
+ ## Testing & Quality
32
+
33
+ * **Run Tests:**
34
+ ```bash
35
+ bundle exec rspec
36
+ ```
37
+ * **Lint Code:**
38
+ ```bash
39
+ bundle exec rubocop
40
+ ```
41
+
42
+ ## Running the Server
43
+
44
+ The server is configured to run using the `stdio` transport.
45
+
46
+ ```bash
47
+ bundle exec ruby main.rb
48
+ ```
49
+
50
+ *Note: Since this is an MCP server running over stdio, it is typically not run directly by a human but rather spawned by an MCP client.*
51
+
52
+ ## Ruby MCP Developer Resources
53
+
54
+ * **MCP Ruby SDK (GitHub):** [https://github.com/modelcontextprotocol/ruby-sdk](https://github.com/modelcontextprotocol/ruby-sdk)
55
+ * **Model Context Protocol Documentation:** [https://modelcontextprotocol.io/](https://modelcontextprotocol.io/)
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ ruby '3.4.8'
6
+
7
+ gem 'logger'
8
+ gem 'mcp'
9
+
10
+ group :development, :test do
11
+ gem 'rake'
12
+ gem 'rspec'
13
+ gem 'rubocop'
14
+ gem 'rubocop-rspec'
15
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,81 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ addressable (2.8.8)
5
+ public_suffix (>= 2.0.2, < 8.0)
6
+ ast (2.4.3)
7
+ bigdecimal (4.0.1)
8
+ diff-lcs (1.6.2)
9
+ json (2.18.0)
10
+ json-schema (6.1.0)
11
+ addressable (~> 2.8)
12
+ bigdecimal (>= 3.1, < 5)
13
+ json_rpc_handler (0.1.1)
14
+ language_server-protocol (3.17.0.5)
15
+ lint_roller (1.1.0)
16
+ logger (1.7.0)
17
+ mcp (0.4.0)
18
+ json-schema (>= 4.1)
19
+ json_rpc_handler (~> 0.1)
20
+ parallel (1.27.0)
21
+ parser (3.3.10.0)
22
+ ast (~> 2.4.1)
23
+ racc
24
+ prism (1.7.0)
25
+ public_suffix (7.0.0)
26
+ racc (1.8.1)
27
+ rainbow (3.1.1)
28
+ rake (13.3.1)
29
+ regexp_parser (2.11.3)
30
+ rspec (3.13.2)
31
+ rspec-core (~> 3.13.0)
32
+ rspec-expectations (~> 3.13.0)
33
+ rspec-mocks (~> 3.13.0)
34
+ rspec-core (3.13.6)
35
+ rspec-support (~> 3.13.0)
36
+ rspec-expectations (3.13.5)
37
+ diff-lcs (>= 1.2.0, < 2.0)
38
+ rspec-support (~> 3.13.0)
39
+ rspec-mocks (3.13.7)
40
+ diff-lcs (>= 1.2.0, < 2.0)
41
+ rspec-support (~> 3.13.0)
42
+ rspec-support (3.13.6)
43
+ rubocop (1.82.1)
44
+ json (~> 2.3)
45
+ language_server-protocol (~> 3.17.0.2)
46
+ lint_roller (~> 1.1.0)
47
+ parallel (~> 1.10)
48
+ parser (>= 3.3.0.2)
49
+ rainbow (>= 2.2.2, < 4.0)
50
+ regexp_parser (>= 2.9.3, < 3.0)
51
+ rubocop-ast (>= 1.48.0, < 2.0)
52
+ ruby-progressbar (~> 1.7)
53
+ unicode-display_width (>= 2.4.0, < 4.0)
54
+ rubocop-ast (1.49.0)
55
+ parser (>= 3.3.7.2)
56
+ prism (~> 1.7)
57
+ rubocop-rspec (3.8.0)
58
+ lint_roller (~> 1.1)
59
+ rubocop (~> 1.81)
60
+ ruby-progressbar (1.13.0)
61
+ unicode-display_width (3.2.0)
62
+ unicode-emoji (~> 4.1)
63
+ unicode-emoji (4.2.0)
64
+
65
+ PLATFORMS
66
+ ruby
67
+ x86_64-linux
68
+
69
+ DEPENDENCIES
70
+ logger
71
+ mcp
72
+ rake
73
+ rspec
74
+ rubocop
75
+ rubocop-rspec
76
+
77
+ RUBY VERSION
78
+ ruby 3.4.8p72
79
+
80
+ BUNDLED WITH
81
+ 2.6.9
data/Makefile ADDED
@@ -0,0 +1,64 @@
1
+ # Makefile for mcp-stdio-ruby
2
+
3
+ .PHONY: all install run build test lint format type-check status pull push clean
4
+
5
+ all: install test lint
6
+
7
+ # Target to install dependencies
8
+ install:
9
+ @echo "Installing dependencies..."
10
+ @bundle install
11
+
12
+ # Target to run the application
13
+ run:
14
+ @echo "Running the application..."
15
+ @bundle exec ruby main.rb
16
+
17
+ release:
18
+ @echo "Running the application..."
19
+ @bundle exec ruby main.rb
20
+
21
+ # Target to build the application (placeholder)
22
+ build:
23
+ @echo "Building the application..."
24
+ @echo "No build steps defined for this project."
25
+
26
+ # Target to run tests
27
+ test:
28
+ @echo "Running tests..."
29
+ @bundle exec rspec
30
+
31
+ # Target to lint the code
32
+ lint:
33
+ @echo "Linting the code..."
34
+ @bundle exec rubocop
35
+
36
+ # Target to format the code
37
+ format:
38
+ @echo "Formatting the code..."
39
+ @bundle exec rubocop -a
40
+
41
+ # Target to type-check the code
42
+ type-check:
43
+ @echo "Type-checking the code..."
44
+ @echo "Ruby is dynamic; consider using Sorbet or Steep if needed."
45
+
46
+ # Target to show git status
47
+ status:
48
+ @echo "Showing git status..."
49
+ @git status
50
+
51
+ # Target to pull latest changes from git
52
+ pull:
53
+ @echo "Pulling latest changes from git..."
54
+ @git pull
55
+
56
+ # Target to push changes to git
57
+ push:
58
+ @echo "Pushing changes to git..."
59
+ @git push
60
+
61
+ .PHONY: clean
62
+ clean:
63
+ @echo "Cleaning up..."
64
+ @rm -rf vendor .bundle
data/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # MCP Stdio Ruby Server
2
+
3
+ A simple Model Context Protocol (MCP) server implemented in Ruby. This server provides a `greet` tool and uses the `stdio` transport for communication with MCP clients.
4
+
5
+ ## Features
6
+
7
+ - **greet**: A tool that accepts a message and echoes it back, demonstrating simple tool integration.
8
+ - **Logging**: Integrated application logging for debugging and monitoring.
9
+
10
+ ## Prerequisites
11
+
12
+ - Ruby 3.0 or higher
13
+ - Bundler
14
+
15
+ ## Setup
16
+
17
+ 1. **Clone the repository** (if you haven't already).
18
+ 2. **Install Dependencies**:
19
+ ```bash
20
+ make install
21
+ ```
22
+ or
23
+ ```bash
24
+ bundle install
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ ### Running the Server
30
+
31
+ To start the server using the stdio transport:
32
+
33
+ ```bash
34
+ make run
35
+ ```
36
+ or
37
+ ```bash
38
+ bundle exec ruby main.rb
39
+ ```
40
+
41
+ ### Integrated Tools
42
+
43
+ #### `greet`
44
+ - **Arguments**:
45
+ - `message` (string, required): The message to repeat.
46
+ - **Returns**: A text response containing the input message.
47
+
48
+ ## Development
49
+
50
+ The project uses `rake` for common development tasks:
51
+
52
+ - **Run Tests**: `bundle exec rake test`
53
+ - **Lint Code**: `bundle exec rake lint`
54
+ - **Auto-format Code**: `bundle exec rubocop -a`
55
+
56
+ ## License
57
+
58
+ This project is licensed under the MIT License - see the LICENSE file for details.
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rubocop/rake_task'
4
+ require 'rspec/core/rake_task'
5
+
6
+ task default: %i[test lint]
7
+
8
+ desc 'Run RSpec tests'
9
+ RSpec::Core::RakeTask.new(:test) do |t|
10
+ t.pattern = 'spec/**/*_spec.rb'
11
+ end
12
+
13
+ desc 'Run RuboCop'
14
+ RuboCop::RakeTask.new(:lint)
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'logger'
4
+
5
+ module McpStdioRuby
6
+ # Provides a centralized logger for the application.
7
+ module AppLogger
8
+ class << self
9
+ def logger
10
+ @logger ||= Logger.new($stderr).tap do |l|
11
+ l.level = Logger::INFO
12
+ end
13
+ end
14
+
15
+ attr_writer :logger
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'mcp'
4
+ require_relative 'app_logger'
5
+
6
+ module McpStdioRuby
7
+ # Define the greet tool
8
+ class GreetTool < MCP::Tool
9
+ tool_name 'greet'
10
+ description 'Gives a friendly greeting.'
11
+ input_schema(
12
+ type: 'object',
13
+ properties: {
14
+ name: {
15
+ type: 'string',
16
+ description: 'The name to greet.'
17
+ }
18
+ },
19
+ required: ['name']
20
+ )
21
+
22
+ class << self
23
+ def call(name:)
24
+ AppLogger.logger.info "GreetTool called with name: #{name}"
25
+ MCP::Tool::Response.new(
26
+ [
27
+ {
28
+ type: 'text',
29
+ text: "Hello, #{name}!"
30
+ }
31
+ ]
32
+ )
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'mcp'
4
+ require_relative 'app_logger'
5
+ require_relative 'greet_tool'
6
+
7
+ module McpStdioRuby
8
+ # Encapsulates the MCP Server logic
9
+ class Server
10
+ attr_reader :server
11
+
12
+ def initialize
13
+ @server = MCP::Server.new(
14
+ name: 'hello-world-server',
15
+ version: '1.0.0',
16
+ tools: [GreetTool]
17
+ )
18
+ end
19
+
20
+ def start
21
+ AppLogger.logger.info "Starting MCP server: #{server.name} (v#{server.version})"
22
+ run_transport
23
+ rescue Interrupt
24
+ AppLogger.logger.info 'Shutting down MCP server...'
25
+ rescue StandardError => e
26
+ handle_error(e)
27
+ end
28
+
29
+ private
30
+
31
+ def run_transport
32
+ MCP::Server::Transports::StdioTransport.new(server).open
33
+ end
34
+
35
+ def handle_error(err)
36
+ AppLogger.logger.error "Server error: #{err.message}"
37
+ AppLogger.logger.error err.backtrace.join("\n")
38
+ exit 1
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'mcp_stdio_ruby/app_logger'
4
+ require_relative 'mcp_stdio_ruby/greet_tool'
5
+ require_relative 'mcp_stdio_ruby/server'
6
+
7
+ # Main module for the MCP Stdio Ruby application
8
+ module McpStdioRuby
9
+ end
data/main.rb ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative 'lib/mcp_stdio_ruby'
5
+
6
+ # Run the server using stdio transport
7
+ McpStdioRuby::Server.new.start if __FILE__ == $PROGRAM_NAME
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mcp_stdio_ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Code Assistant
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: mcp
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '0.1'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '0.1'
26
+ - !ruby/object:Gem::Dependency
27
+ name: logger
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '1.6'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.6'
40
+ - !ruby/object:Gem::Dependency
41
+ name: rake
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '13.0'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '13.0'
54
+ - !ruby/object:Gem::Dependency
55
+ name: rspec
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '3.0'
61
+ type: :development
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '3.0'
68
+ - !ruby/object:Gem::Dependency
69
+ name: rubocop
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '1.0'
75
+ type: :development
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '1.0'
82
+ - !ruby/object:Gem::Dependency
83
+ name: rubocop-rspec
84
+ requirement: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '3.0'
89
+ type: :development
90
+ prerelease: false
91
+ version_requirements: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '3.0'
96
+ description: A Ruby implementation of a Model Context Protocol (MCP) server using
97
+ stdio transport.
98
+ email:
99
+ - example@example.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gemini/settings.json"
105
+ - ".gitignore"
106
+ - ".rubocop.yml"
107
+ - ".ruby-version"
108
+ - GEMINI.md
109
+ - Gemfile
110
+ - Gemfile.lock
111
+ - Makefile
112
+ - README.md
113
+ - Rakefile
114
+ - lib/mcp_stdio_ruby.rb
115
+ - lib/mcp_stdio_ruby/app_logger.rb
116
+ - lib/mcp_stdio_ruby/greet_tool.rb
117
+ - lib/mcp_stdio_ruby/server.rb
118
+ - main.rb
119
+ homepage: https://github.com/example/mcp_stdio_ruby
120
+ licenses:
121
+ - MIT
122
+ metadata:
123
+ homepage_uri: https://github.com/example/mcp_stdio_ruby
124
+ source_code_uri: https://github.com/example/mcp_stdio_ruby
125
+ changelog_uri: https://github.com/example/mcp_stdio_ruby/blob/main/CHANGELOG.md
126
+ rdoc_options: []
127
+ require_paths:
128
+ - lib
129
+ required_ruby_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: 3.0.0
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ requirements: []
140
+ rubygems_version: 3.6.9
141
+ specification_version: 4
142
+ summary: A Ruby based Model Context Protocol (MCP) server.
143
+ test_files: []