dynamic_mcp 0.0.7

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: a259bd2c1e6c0b320f1163d9462ebb21233374baa50c2b6f4c61fd33b9856b77
4
+ data.tar.gz: e239a1b63aa1d895ed38c6ad9a79c9a9f8c16c0a83031e320307ce0bfa9f6078
5
+ SHA512:
6
+ metadata.gz: 92984b786e0bfddaaae6d2b812a74a3ea10a6e73bee31ee2a38066273c2c486e54c7cea986f855c9551e81a658a60d75e36ec28b7fea02b03adbf12a97e6ad5f
7
+ data.tar.gz: 2e59a9329f1a2ff305b1b7aa32e228499cf22c7d0237f3ae2ecb6dfac03ca0b5bd35cf3b4c4f5d02a0307e63252fe4919b4bea0c1febe6316c75219316b958ff
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Bryant Morrill
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,83 @@
1
+ # ruby-mcp
2
+ A dynamic and flexible Ruby MCP server built on [FastMCP](https://github.com/yjacquin/fast-mcp).
3
+
4
+ This gem is a Ruby MCP server in a box. It's designed to allow you to get a new MCP server up and running in just a few minutes, and add tools, resources and prompts with as little effort as possible.
5
+
6
+ Once DynamicMCP is deployed within the directory you want it to work in, it builds the necessary code to expose resources and prompts to an AI agent dynamically. All you need to do is drop in the markdown or ruby files that you want to be exposed, and Ruby MCP does the rest.
7
+
8
+ For tools, DynamicMCP allows you to simply drop in ruby files that contain FastMCP tool classes and it will automatically require them and register them to be available to the AI agent. For resources, you can drop in markdown files with the proper front matter or drop in Ruby classes that implement a resource using FastMCP. For prompts, only markdown files are supported for the time being and they get exposed as tools, but once FastMCP supports prompts then DynamicMCP will also support them.
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ gem install dynamic_mcp
14
+ ```
15
+
16
+ Then inside the directory where you want the mcp server to exist:
17
+
18
+ ```bash
19
+ deploy_dynamic_mcp
20
+ ```
21
+
22
+ The above command will install files into the `./mcp` directory, asking you if you want to override them if they already exist. When it is finished, it will output the path to the MCP server start up file so that you may configure your AI agents to use it.
23
+
24
+ For example, to configure gemini to use your new MCP server, you would put the following in your `.gemini/settings.json` file:
25
+
26
+ ```json
27
+ {
28
+ "mcpServers": [
29
+ {
30
+ "name": "dynamic_mcp_server",
31
+ "command": "ruby",
32
+ "args": ["path/to/mcp/server.rb"],
33
+ "cwd": "path/to/mcp",
34
+ "timeout": 30000,
35
+ "trust": false
36
+ }
37
+ ]
38
+ }
39
+ ```
40
+
41
+ ## Usage
42
+
43
+ With the MCP server installed and your agent configured to use it, you can now drop `.md` or `.rb` files into `./mcp/resources` and `./mcp/prompts` and `.rb` files into `./mcp/tools` and they will automatically be exposed to the agent via the server. Just be sure to follow the below guides for each type of file.
44
+
45
+ ### Tools
46
+
47
+ Tool files must be `.rb` files that define a class that inherits form `::FastMCP::Tool`. An example file is generated as part of the installation inside the `./mcp/tools` directory. See the [FastMCP github page](https://github.com/yjacquin/fast-mcp) for more about how to implement a tool in Ruby.
48
+
49
+ ### Resources
50
+
51
+ Resources can either be ruby classes that inherit from `::FastMCP::Resource` or markdown files, in which case the ruby classes will be dynamically defined to serve the contents of the file to the agent.
52
+
53
+ #### Resource Markdown Files
54
+
55
+ Resources are simply markdown files that have a frontmatter section to help facilitate registering them with the MCP server. That front matter should look like this:
56
+
57
+ ```markdown
58
+ ---
59
+ resource_name: "example"
60
+ uri: "dynamic_mcp:///example"
61
+ mime_type: "text/markdown"
62
+ ---
63
+ ```
64
+
65
+ The `uri` attribute should be unique, as this is how the AI agent can invoke specific resources.
66
+
67
+ ### Prompts
68
+
69
+ `FastMCP` does not yet support prompts so they are simply implemented as tools and will show up as tools to the agent. To add a prompt using DynamicMCP, simply drop a markdown file with the proper front matter into `./mcp/prompts`. The frontmatter should look like this:
70
+
71
+ ```markdown
72
+ ---
73
+ description: "This prompt instructs the AI agent to meow three times"
74
+ name: "Meow"
75
+ ---
76
+ ```
77
+
78
+ The `name` attribute should be unique, as this is how the AI agent can invoke specific prompts.
79
+
80
+ ### Integration
81
+
82
+ The `./mcp` directory is meant to be committed to a repository and/or shared. The server within it is an independent ruby application that simply needs its dependencies available on the system on which it runs. The globally installed gem knows nothing about the servers it creates.
83
+
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'fileutils'
4
+
5
+ # The directory where the gem is installed
6
+ gem_path = Gem.loaded_specs['dynamic_mcp'].full_gem_path
7
+
8
+ # The source directory to copy from
9
+ source = File.join(gem_path, 'mcp')
10
+
11
+ # The destination directory (current working directory)
12
+ destination = File.join(Dir.pwd, 'mcp')
13
+
14
+ puts "Deploying MCP server to #{destination}..."
15
+
16
+ # Copy the mcp directory
17
+ # Get a list of all files and directories in the source
18
+ source_files = Dir.glob(File.join(source, "**", "*.{rb,md,yml}"))
19
+
20
+ source_files.each do |file|
21
+ # The destination path for this file
22
+ dest_file = File.join(destination, file.sub(source, ''))
23
+ dest_dir = File.dirname(dest_file)
24
+
25
+ FileUtils.mkdir_p(dest_dir) unless File.directory?(dest_dir)
26
+
27
+ if File.exist?(dest_file)
28
+ print "overwrite #{dest_file}? (y/n) "
29
+ answer = STDIN.gets.chomp
30
+ if answer.downcase == 'y'
31
+ FileUtils.cp(file, dest_file)
32
+ end
33
+ else
34
+ FileUtils.cp(file, dest_file)
35
+ end
36
+ end
37
+
38
+ puts "Deployment successful!"
39
+ puts "To start the server, run: ruby #{File.join(destination, 'server.rb')}"
40
+
@@ -0,0 +1,45 @@
1
+ require "front_matter_parser"
2
+ require_relative "../utilities/file_ops"
3
+
4
+ module DynamicMcp
5
+ module Prompts
6
+ module PromptGenerator
7
+ def self.generate(config)
8
+ prompt_paths = config["dynamic_mcp"]["source_data"]["prompts"]
9
+ prompt_files = prompt_paths.flat_map { |path| ::DynamicMcp::Utilities::FileOps.get_all_files(config["server_root"], path) }
10
+
11
+ prompt_files.map do |file|
12
+ ext = File.extname(file)
13
+
14
+ if ext == ".md" || ext == ".markdown"
15
+ define_prompt(file)
16
+ end
17
+ end
18
+ end
19
+
20
+ def self.define_prompt(file)
21
+ parsed = FrontMatterParser::Parser.parse_file(file)
22
+
23
+ klass = Class.new(FastMcp::Tool) do
24
+ description "This tool outputs a prompt. #{parsed.front_matter["description"]}"
25
+ @name = parsed.front_matter["name"]
26
+ @content = parsed.content
27
+
28
+ def self.content
29
+ @content
30
+ end
31
+
32
+ def call
33
+ self.class.content
34
+ end
35
+
36
+ def self.name
37
+ @name
38
+ end
39
+ end
40
+
41
+ klass
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,48 @@
1
+ require "front_matter_parser"
2
+ require_relative "../utilities/file_ops"
3
+
4
+ module DynamicMcp
5
+ module Resources
6
+ module ResourceGenerator
7
+ def self.generate(config)
8
+ resource_paths = config["dynamic_mcp"]["source_data"]["resources"]
9
+ resource_files = resource_paths.flat_map { |path| ::DynamicMcp::Utilities::FileOps.get_all_files(config["server_root"], path) }
10
+
11
+ resource_files.map do |file|
12
+ ext = File.extname(file)
13
+
14
+ if ext == ".rb"
15
+ require file
16
+
17
+ class_name = File.basename(file, ".rb").split('_').map(&:capitalize).join
18
+ klass = Object.const_get(class_name)
19
+ klass.ancestors.include?(FastMcp::Resource) ? klass : nil
20
+ elsif ext == ".md" || ext == ".markdown"
21
+ define_resource(file)
22
+ end
23
+ end
24
+ end
25
+
26
+ def self.define_resource(file)
27
+ parsed = FrontMatterParser::Parser.parse_file(file)
28
+
29
+ klass = Class.new(FastMcp::Resource) do
30
+ uri parsed.front_matter["uri"]
31
+ resource_name parsed.front_matter["resource_name"]
32
+ mime_type parsed.front_matter["mime_type"]
33
+ @content = parsed.content
34
+
35
+ def self.content
36
+ @content
37
+ end
38
+
39
+ def content
40
+ self.class.content
41
+ end
42
+ end
43
+
44
+ klass
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,19 @@
1
+ require_relative "../utilities/file_ops"
2
+
3
+ module DynamicMcp
4
+ module Tools
5
+ module ToolGenerator
6
+ def self.generate(config)
7
+ tool_paths = config["dynamic_mcp"]["source_data"]["tools"]
8
+ tool_files = tool_paths.flat_map { |path| ::DynamicMcp::Utilities::FileOps.get_all_files(config["server_root"], path) }
9
+
10
+ tool_files.map do |file|
11
+ require file
12
+ class_name = File.basename(file, ".rb").split('_').map(&:capitalize).join
13
+ klass = Object.const_get(class_name)
14
+ klass.ancestors.include?(FastMcp::Tool) ? klass : nil
15
+ end.compact
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,18 @@
1
+ module DynamicMcp
2
+ module Utilities
3
+ module FileOps
4
+ def self.get_all_files(root, path)
5
+ full_path = File.join(root, path)
6
+
7
+ if File.file?(full_path)
8
+ [full_path]
9
+ elsif File.directory?(File.join(root, path))
10
+ Dir.glob(File.join(full_path, '**', '*')).select { |f| File.file?(f) }
11
+ else
12
+ []
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+
@@ -0,0 +1,3 @@
1
+ module DynamicMcp
2
+ VERSION = "0.0.7"
3
+ end
@@ -0,0 +1,3 @@
1
+ require_relative "dynamic_mcp/tools/tool_generator"
2
+ require_relative "dynamic_mcp/resources/resource_generator"
3
+ require_relative "dynamic_mcp/prompts/prompt_generator"
data/mcp/config.yml ADDED
@@ -0,0 +1,10 @@
1
+ dynamic_mcp:
2
+ server_name: "ruby-mcp"
3
+ version: 0.0.0
4
+ source_data:
5
+ prompts:
6
+ - prompts
7
+ resources:
8
+ - resources
9
+ tools:
10
+ - tools
@@ -0,0 +1,8 @@
1
+ ---
2
+ description: "This prompt instructs the AI agent to meow three times"
3
+ name: "Meow"
4
+ ---
5
+
6
+ # Meow
7
+
8
+ Meow like a cat three times.
@@ -0,0 +1,9 @@
1
+ ---
2
+ resource_name: "example"
3
+ uri: "dynamic_mcp:///example"
4
+ mime_type: "text/markdown"
5
+ ---
6
+
7
+ # This is an example
8
+
9
+ Example text.
data/mcp/server.rb ADDED
@@ -0,0 +1,35 @@
1
+ require "fast_mcp"
2
+ require "yaml"
3
+
4
+ require "dynamic_mcp"
5
+
6
+ config = ::YAML.load_file("#{__dir__}/config.yml")
7
+ config["server_root"] = __dir__
8
+
9
+ tools = ::DynamicMcp::Tools::ToolGenerator.generate(config)
10
+ resources = ::DynamicMcp::Resources::ResourceGenerator.generate(config)
11
+ prompts = ::DynamicMcp::Prompts::PromptGenerator.generate(config)
12
+
13
+ server = FastMcp::Server.new(
14
+ name: config["dynamic_mcp"]["server_name"],
15
+ version: config["dynamic_mcp"]["version"]
16
+ )
17
+
18
+ tools.each do |tool|
19
+ server.register_tool(tool)
20
+ end
21
+
22
+ resources.each do |resource|
23
+ server.register_resource(resource)
24
+ end
25
+
26
+ # FastMcp does not yet support prompts
27
+ # so we are implementing them as tools
28
+ # for now.
29
+ prompts.each do |prompt|
30
+ server.register_tool(prompt)
31
+ end
32
+
33
+ server.start
34
+
35
+
@@ -0,0 +1,9 @@
1
+ require "fast_mcp"
2
+
3
+ class Flash < FastMcp::Tool
4
+ description "Challenge phrase..."
5
+
6
+ def call
7
+ "thunder"
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dynamic_mcp
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.7
5
+ platform: ruby
6
+ authors:
7
+ - Bryant Morrill
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2025-08-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: fast-mcp
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: fileutils
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: front_matter_parser
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: DynamicMcp lets you get an MCP server up an running in seconds and automatically
56
+ exposes tools, resources, and prompts as you drop them into their designated directories.
57
+ email: bryantreadmorrill@gmail.com
58
+ executables:
59
+ - deploy_dynamic_mcp
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - LICENSE
64
+ - README.md
65
+ - bin/deploy_dynamic_mcp
66
+ - lib/dynamic_mcp.rb
67
+ - lib/dynamic_mcp/prompts/prompt_generator.rb
68
+ - lib/dynamic_mcp/resources/resource_generator.rb
69
+ - lib/dynamic_mcp/tools/tool_generator.rb
70
+ - lib/dynamic_mcp/utilities/file_ops.rb
71
+ - lib/dynamic_mcp/version.rb
72
+ - mcp/config.yml
73
+ - mcp/prompts/example.md
74
+ - mcp/resources/example.md
75
+ - mcp/server.rb
76
+ - mcp/tools/flash.rb
77
+ homepage: https://rubygems.org/gems/dynamic_mcp
78
+ licenses:
79
+ - MIT
80
+ metadata:
81
+ homepage_uri: https://rubygems.org/gems/dynamic_mcp
82
+ source_code_uri: https://github.com/WriterZephos/dynamic_mcp
83
+ changelog_uri: https://github.com/WriterZephos/dynamic_mcp
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ requirements: []
99
+ rubygems_version: 3.5.11
100
+ signing_key:
101
+ specification_version: 4
102
+ summary: A dynamic and flexible Ruby MCP server
103
+ test_files: []