mcp_on_ruby 0.3.0 → 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.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +56 -28
  3. data/CODE_OF_CONDUCT.md +30 -58
  4. data/CONTRIBUTING.md +61 -67
  5. data/LICENSE.txt +2 -2
  6. data/README.md +159 -509
  7. data/bin/console +11 -0
  8. data/bin/setup +6 -0
  9. data/docs/advanced-usage.md +132 -0
  10. data/docs/api-reference.md +35 -0
  11. data/docs/testing.md +55 -0
  12. data/examples/claude/README.md +171 -0
  13. data/examples/claude/claude-bridge.js +122 -0
  14. data/lib/mcp_on_ruby/configuration.rb +74 -0
  15. data/lib/mcp_on_ruby/errors.rb +137 -0
  16. data/lib/mcp_on_ruby/generators/install_generator.rb +46 -0
  17. data/lib/mcp_on_ruby/generators/resource_generator.rb +63 -0
  18. data/lib/mcp_on_ruby/generators/templates/README +31 -0
  19. data/lib/mcp_on_ruby/generators/templates/application_resource.rb +20 -0
  20. data/lib/mcp_on_ruby/generators/templates/application_tool.rb +18 -0
  21. data/lib/mcp_on_ruby/generators/templates/initializer.rb +41 -0
  22. data/lib/mcp_on_ruby/generators/templates/resource.rb +50 -0
  23. data/lib/mcp_on_ruby/generators/templates/resource_spec.rb +67 -0
  24. data/lib/mcp_on_ruby/generators/templates/sample_resource.rb +57 -0
  25. data/lib/mcp_on_ruby/generators/templates/sample_tool.rb +59 -0
  26. data/lib/mcp_on_ruby/generators/templates/tool.rb +38 -0
  27. data/lib/mcp_on_ruby/generators/templates/tool_spec.rb +55 -0
  28. data/lib/mcp_on_ruby/generators/tool_generator.rb +51 -0
  29. data/lib/mcp_on_ruby/railtie.rb +108 -0
  30. data/lib/mcp_on_ruby/resource.rb +161 -0
  31. data/lib/mcp_on_ruby/server.rb +378 -0
  32. data/lib/mcp_on_ruby/tool.rb +134 -0
  33. data/lib/mcp_on_ruby/transport.rb +330 -0
  34. data/lib/mcp_on_ruby/version.rb +6 -0
  35. data/lib/mcp_on_ruby.rb +142 -0
  36. metadata +62 -173
  37. data/lib/ruby_mcp/client.rb +0 -43
  38. data/lib/ruby_mcp/configuration.rb +0 -90
  39. data/lib/ruby_mcp/errors.rb +0 -17
  40. data/lib/ruby_mcp/models/context.rb +0 -52
  41. data/lib/ruby_mcp/models/engine.rb +0 -31
  42. data/lib/ruby_mcp/models/message.rb +0 -60
  43. data/lib/ruby_mcp/providers/anthropic.rb +0 -269
  44. data/lib/ruby_mcp/providers/base.rb +0 -57
  45. data/lib/ruby_mcp/providers/openai.rb +0 -265
  46. data/lib/ruby_mcp/schemas.rb +0 -56
  47. data/lib/ruby_mcp/server/app.rb +0 -84
  48. data/lib/ruby_mcp/server/base_controller.rb +0 -49
  49. data/lib/ruby_mcp/server/content_controller.rb +0 -68
  50. data/lib/ruby_mcp/server/contexts_controller.rb +0 -67
  51. data/lib/ruby_mcp/server/controller.rb +0 -29
  52. data/lib/ruby_mcp/server/engines_controller.rb +0 -34
  53. data/lib/ruby_mcp/server/generate_controller.rb +0 -140
  54. data/lib/ruby_mcp/server/messages_controller.rb +0 -30
  55. data/lib/ruby_mcp/server/router.rb +0 -84
  56. data/lib/ruby_mcp/storage/active_record.rb +0 -414
  57. data/lib/ruby_mcp/storage/base.rb +0 -43
  58. data/lib/ruby_mcp/storage/error.rb +0 -8
  59. data/lib/ruby_mcp/storage/memory.rb +0 -69
  60. data/lib/ruby_mcp/storage/redis.rb +0 -197
  61. data/lib/ruby_mcp/storage_factory.rb +0 -43
  62. data/lib/ruby_mcp/validator.rb +0 -45
  63. data/lib/ruby_mcp/version.rb +0 -6
  64. data/lib/ruby_mcp.rb +0 -71
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 04166e9711a0a9c233c43a2f1bba53b27d0a716a7cc996c52f597433e559909d
4
- data.tar.gz: 588bbbd27e9bc620e4cf4ea14b97b4e8c5cd869b672f8956a2a17b16b179afdb
3
+ metadata.gz: 41b083ae138856bff622b5bbdcaa2112ee08961b1eda6acec5a4bb5a7a6f0b04
4
+ data.tar.gz: e67b154ece12257fd300fd4824d25392a1a103de5ef0c8b0654fe17af970dd97
5
5
  SHA512:
6
- metadata.gz: c22a5a6e40162c8754975bb89288ee5147314e41564a97ea25ab7b85fae03eecfcdc7246a0567520d6813ead8bc22e88ffcfa265ccf16653c2da8f06da8adb28
7
- data.tar.gz: e16b57bd9c57d50f1f9f46328d29b94986e54785b166cbf321db1d06366fcd0fa2d43dd7206468ac3671219be7800c8a1f8ccbaaea2eaa77ca4e95217c32da2f
6
+ metadata.gz: a3927a0dbfba3cc726868a3f05690340d90bbd6a0715be53880bec3611f861bbf1cc7f817167e4df3373d6fd76e013575745a00c625e7a119f839683c7aa9166
7
+ data.tar.gz: 4e9b2179b6c709597b0fe6d8327f8e7d1539107d32d2f76c237a82e3e1d06c86dcc0ea1d17e2f226e5524cb1772e91fc0478c7e188d977252db9de51a57708a1
data/CHANGELOG.md CHANGED
@@ -1,41 +1,69 @@
1
1
  # Changelog
2
2
 
3
- ## [0.3.0] - 2023-05-01
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.0.0] - 2025-01-28
4
9
 
5
10
  ### Added
6
- - ActiveRecord storage backend for database persistence
7
- - Support for Rails integration with ActiveRecord storage
8
- - Auto-creation of database tables with configurable prefixes
9
- - Proper handling of different data types (text, binary, JSON)
10
- - Symbolization of hash keys for consistent API
11
- - Comprehensive test suite for ActiveRecord storage
11
+ - Production-ready MCP server implementation for Rails applications
12
+ - Rails-native integration with generators, middleware, and Railtie
13
+ - Full JSON-RPC 2.0 protocol support over HTTP transport
14
+ - Rails generators for quick setup:
15
+ - `rails generate mcp_on_ruby:install` - Complete MCP server setup
16
+ - `rails generate mcp_on_ruby:tool` - Create new tools with templates
17
+ - `rails generate mcp_on_ruby:resource` - Create new resources with URI templates
18
+ - Comprehensive security features:
19
+ - Bearer token authentication
20
+ - Rate limiting (configurable per minute)
21
+ - CORS support with configurable origins
22
+ - DNS rebinding protection
23
+ - Localhost-only mode for development
24
+ - Automatic tool and resource discovery in Rails apps
25
+ - JSON Schema validation for tool inputs
26
+ - URI templating for resources
27
+ - Error handling with proper JSON-RPC error codes
28
+ - Claude Desktop integration with stdio bridge example
29
+ - Extensive documentation and examples
12
30
 
13
31
  ### Changed
14
- - Enhanced `StorageFactory` to support ActiveRecord backend
15
- - Updated configuration system with ActiveRecord options
16
- - Improved documentation with ActiveRecord storage examples
32
+ - Complete architectural rewrite focused on Rails integration
33
+ - Simplified API following Rails conventions
34
+ - Improved error handling and logging
35
+ - Better security defaults
17
36
 
18
- ## [0.2.0] - 2025-04-21
37
+ ### Fixed
38
+ - Rails 8 compatibility issues with frozen arrays
39
+ - Middleware initialization timing issues
40
+ - Tool auto-registration in development mode
41
+ - PostgreSQL parameter binding in tool examples
19
42
 
20
- ### Added
21
- - Redis storage backend with comprehensive test coverage
22
- - Configurable TTL and namespace support for Redis keys
23
- - Rails integration with Redis storage examples
24
- - Wiki documentation for Redis storage setup and usage
43
+ ### Removed
44
+ - Standalone client implementation (focus on server-side)
45
+ - STDIO transport (HTTP-only, with bridge examples for stdio clients)
46
+ - Prompts and roots features (not commonly used in Rails context)
25
47
 
26
- ### Changed
27
- - Enhanced storage factory to support different backend types
28
- - Improved configuration API for more intuitive setup
29
- - Updated README with Redis storage documentation
48
+ ## [0.2.0] - 2024-07-24
30
49
 
31
- ## [0.1.0] - 2025-04-18
50
+ ### Added
51
+ - OAuth 2.1 authentication for secure remote connections
52
+ - Permission-based access control for MCP methods
53
+ - JWT token validation and management
54
+ - Automatic token refresh mechanism
55
+ - HTTP transport authentication integration
56
+ - Middleware architecture for server authentication
57
+ - Authentication examples and documentation
32
58
 
33
- Initial release of version 0.1.0 of the Ruby Gem.
59
+ ## [0.1.0] - 2024-06-15
34
60
 
35
61
  ### Added
36
- - Core MCP implementation with Rack server
37
- - Provider support for OpenAI and Anthropic
38
- - In-memory storage backend
39
- - Context, message, and content management
40
- - Basic authentication support
41
- - Comprehensive test suite
62
+ - Initial implementation of core MCP protocol
63
+ - JSON-RPC 2.0 message format
64
+ - HTTP and STDIO transports
65
+ - Basic server and client functionality
66
+ - Tool definition and execution
67
+ - Resource management
68
+ - Prompt handling
69
+ - Root filesystem access
data/CODE_OF_CONDUCT.md CHANGED
@@ -2,83 +2,55 @@
2
2
 
3
3
  ## Our Pledge
4
4
 
5
- We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
-
7
- We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, religion, or sexual identity
10
+ and orientation.
8
11
 
9
12
  ## Our Standards
10
13
 
11
- Examples of behavior that contributes to a positive environment for our community include:
14
+ Examples of behavior that contributes to a positive environment:
12
15
 
13
- * Demonstrating empathy and kindness toward other people
14
- * Being respectful of differing opinions, viewpoints, and experiences
15
- * Giving and gracefully accepting constructive feedback
16
- * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
- * Focusing on what is best not just for us as individuals, but for the overall community
16
+ * Using welcoming and inclusive language
17
+ * Being respectful of differing viewpoints and experiences
18
+ * Gracefully accepting constructive criticism
19
+ * Focusing on what is best for the community
20
+ * Showing empathy towards other community members
18
21
 
19
- Examples of unacceptable behavior include:
22
+ Examples of unacceptable behavior:
20
23
 
21
- * The use of sexualized language or imagery, and sexual attention or
22
- advances of any kind
24
+ * The use of sexualized language or imagery, and sexual attention or advances
23
25
  * Trolling, insulting or derogatory comments, and personal or political attacks
24
26
  * Public or private harassment
25
- * Publishing others' private information, such as a physical or email
26
- address, without their explicit permission
27
- * Other conduct which could reasonably be considered inappropriate in a
28
- professional setting
27
+ * Publishing others' private information without explicit permission
28
+ * Other conduct which could reasonably be considered inappropriate
29
29
 
30
30
  ## Enforcement Responsibilities
31
31
 
32
- Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
-
34
- Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
32
+ Project maintainers are responsible for clarifying and enforcing our standards of
33
+ acceptable behavior and will take appropriate and fair corrective action in
34
+ response to any behavior that they deem inappropriate, threatening, offensive,
35
+ or harmful.
35
36
 
36
37
  ## Scope
37
38
 
38
- This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+ This Code of Conduct applies within all community spaces, and also applies when
40
+ an individual is officially representing the community in public spaces.
39
41
 
40
42
  ## Enforcement
41
43
 
42
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at nagendra.dhanakeerthi@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
-
44
- All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
-
46
- ## Enforcement Guidelines
47
-
48
- Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
-
50
- ### 1. Correction
51
-
52
- **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
-
54
- **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
-
56
- ### 2. Warning
44
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
45
+ reported to the community leaders responsible for enforcement at
46
+ [INSERT EMAIL ADDRESS].
57
47
 
58
- **Community Impact**: A violation through a single incident or series of actions.
59
-
60
- **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
-
62
- ### 3. Temporary Ban
63
-
64
- **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
-
66
- **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
-
68
- ### 4. Permanent Ban
69
-
70
- **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
-
72
- **Consequence**: A permanent ban from any sort of public interaction within the community.
48
+ All complaints will be reviewed and investigated promptly and fairly.
73
49
 
74
50
  ## Attribution
75
51
 
76
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
- available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
-
79
- Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
-
81
- [homepage]: https://www.contributor-covenant.org
52
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
53
+ version 2.0, available at
54
+ https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
82
55
 
83
- For answers to common questions about this code of conduct, see the FAQ at
84
- https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
56
+ [homepage]: https://www.contributor-covenant.org
data/CONTRIBUTING.md CHANGED
@@ -1,92 +1,86 @@
1
- # Contributing to RubyMCP
1
+ # Contributing to MCP on Ruby
2
2
 
3
- Thank you for considering contributing to RubyMCP! This document outlines the process for contributing to the project.
3
+ We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's:
4
4
 
5
- ## Code of Conduct
5
+ - Reporting a bug
6
+ - Discussing the current state of the code
7
+ - Submitting a fix
8
+ - Proposing new features
9
+ - Becoming a maintainer
6
10
 
7
- This project and everyone participating in it is governed by our [Code of Conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code.
8
-
9
- ## How Can I Contribute?
10
-
11
- ### Reporting Bugs
12
-
13
- This section guides you through submitting a bug report for RubyMCP.
14
-
15
- Before creating bug reports, please check [the issue list](https://github.com/nagstler/mcp_on_ruby/issues) to avoid duplicating an existing report. When you create a bug report, include as many details as possible:
16
-
17
- * **Use a clear and descriptive title**
18
- * **Describe the exact steps to reproduce the bug**
19
- * **Provide specific examples**
20
- * **Describe the behavior you observed**
21
- * **Explain the behavior you expected**
22
- * **Include screenshots or animated GIFs** if possible
23
- * **Include details about your configuration and environment**
24
-
25
- ### Suggesting Enhancements
26
-
27
- This section guides you through submitting an enhancement suggestion for RubyMCP.
28
-
29
- Enhancement suggestions are tracked as GitHub issues. When creating an enhancement suggestion:
30
-
31
- * **Use a clear and descriptive title**
32
- * **Provide a detailed description of the suggested enhancement**
33
- * **Explain why this enhancement would be useful**
34
- * **Specify which version you're using**
35
- * **Specify the name and version of the OS you're using**
11
+ ## Development Process
36
12
 
37
- ### Pull Requests
13
+ We use GitHub to host code, to track issues and feature requests, as well as accept pull requests.
38
14
 
39
- * Fill in the required template
40
- * Follow the Ruby style guide
41
- * Include tests for new features
42
- * Document new code based on the rest of the codebase
43
- * End all files with a newline
15
+ ## Pull Requests
44
16
 
45
- ## Development Process
17
+ 1. Fork the repo and create your branch from `main`.
18
+ 2. If you've added code that should be tested, add tests.
19
+ 3. If you've changed APIs, update the documentation.
20
+ 4. Ensure the test suite passes.
21
+ 5. Make sure your code lints.
22
+ 6. Issue that pull request!
46
23
 
47
- ### Setting Up Development Environment
24
+ ## Development Setup
48
25
 
49
26
  ```bash
50
- # Fork and clone the repository
51
- git clone https://github.com/yourusername/ruby_mcp.git
52
- cd ruby_mcp
27
+ # Clone your fork
28
+ git clone https://github.com/nagstler/mcp_on_ruby.git
29
+ cd mcp_on_ruby
53
30
 
54
31
  # Install dependencies
55
32
  bundle install
56
33
 
57
- # Run tests
58
- bundle exec rspec
34
+ # Run the generators to test Rails integration
35
+ mkdir test_app && cd test_app
36
+ rails new . --skip-git
37
+ echo "gem 'mcp_on_ruby', path: '..' " >> Gemfile
38
+ bundle install
39
+ rails generate mcp_on_ruby:install
59
40
 
41
+ # Test the gem
42
+ cd .. && ruby -e "require './lib/mcp_on_ruby'; puts 'Gem loads successfully'"
43
+ ```
60
44
 
61
- ### Testing
45
+ ## Code Style
62
46
 
63
- Write tests for all new features
64
- Ensure all tests pass before submitting a pull request
65
- Run the full test suite locally before submission
47
+ - Follow standard Ruby conventions
48
+ - Use meaningful variable and method names
49
+ - Add documentation for public APIs
50
+ - Keep methods focused and small
66
51
 
67
- ```bash
68
- bundle exec rspec
69
- ```
52
+ ## Testing
70
53
 
71
- ### Style Guidelines
54
+ Currently, we use manual testing and examples. In the future, we plan to add:
55
+ - RSpec test suite
56
+ - Integration tests with Rails
57
+ - CI/CD pipeline
72
58
 
73
- Code should follow the Ruby style guide
74
- Run RuboCop to check your code style
59
+ ## Bug Reports
75
60
 
76
- ```bash
77
- bundle exec rubocop
78
- ```
61
+ We use GitHub issues to track public bugs. Report a bug by [opening a new issue](https://github.com/nagstler/mcp_on_ruby/issues).
62
+
63
+ **Great Bug Reports** tend to have:
64
+
65
+ - A quick summary and/or background
66
+ - Steps to reproduce
67
+ - Be specific!
68
+ - Give sample code if you can
69
+ - What you expected would happen
70
+ - What actually happens
71
+ - Notes (possibly including why you think this might be happening, or stuff you tried that didn't work)
72
+
73
+ ## Feature Requests
79
74
 
80
- ### Release Process
75
+ We use GitHub issues to track feature requests. Propose a feature by [opening a new issue](https://github.com/nagstler/mcp_on_ruby/issues).
81
76
 
82
- RubyMCP follows Semantic Versioning.
77
+ **Great Feature Requests** include:
83
78
 
84
- - MAJOR version for incompatible API changes
85
- - MINOR version for backward-compatible functionality additions
86
- - PATCH version for backward-compatible bug fixes
79
+ - Clear use case description
80
+ - Why this feature would be useful
81
+ - Proposed API or implementation approach
82
+ - Examples of how it would be used
87
83
 
88
- ### First-time Contributors
89
- If you're new to the project, look for issues labeled with good first issue which are ideal starting points for newcomers.
84
+ ## License
90
85
 
91
- ### License
92
- By contributing to RubyMCP, you agree that your contributions will be licensed under the project's MIT License.
86
+ By contributing, you agree that your contributions will be licensed under the same MIT License that covers the project.
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2025 Nagendra Dhanakeerthi
3
+ Copyright (c) 2024
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
21
+ THE SOFTWARE.