Ruby-Mcp-Server
Ruby-Mcp-Server是一款code方向的AI技能,核心价值是Best practices and patterns for building Model Context Protocol (MCP) servers in Ruby using the official MCP Ruby SDK gem,可用于解决开发者在code领域的实际问题,帮助用户提升效率、自动化重复任务或优化工作流。
Best practices and patterns for building Model Context Protocol (MCP) servers in Ruby using the official MCP Ruby SDK gem.
mkdir -p ./skills/ruby-mcp-server && curl -sfL https://raw.githubusercontent.com/github/awesome-copilot/main/skills/ruby-mcp-server/SKILL.md -o ./skills/ruby-mcp-server/SKILL.md Run in terminal / PowerShell. Requires curl (Unix) or PowerShell 5+ (Windows).
Skill Content
# Ruby MCP Server Development Guidelines
When building MCP servers in Ruby, follow these best practices and patterns using the official Ruby SDK.
Installation
Add the MCP gem to your Gemfile:
gem 'mcp'Then run:
bundle installServer Setup
Create an MCP server instance:
require 'mcp'
server = MCP::Server.new(
name: 'my_server',
version: '1.0.0'
)Adding Tools
Define tools using classes or blocks:
Tool as Class
class GreetTool < MCP::Tool
tool_name 'greet'
description 'Generate a greeting message'
input_schema(
properties: {
name: { type: 'string', description: 'Name to greet' }
},
required: ['name']
)
output_schema(
properties: {
message: { type: 'string' },
timestamp: { type: 'string', format: 'date-time' }
},
required: ['message']
)
annotations(
read_only_hint: true,
idempotent_hint: true
)
def self.call(name:, server_context:)
MCP::Tool::Response.new([{
type: 'text',
text: "Hello, #{name}! Welcome to MCP."
}], structured_content: {
message: "Hello, #{name}!",
timestamp: Time.now.iso8601
})
end
end
server = MCP::Server.new(
name: 'my_server',
tools: [GreetTool]
)Tool with Block
server.define_tool(
name: 'calculate',
description: 'Perform mathematical calculations',
input_schema: {
properties: {
operation: { type: 'string', enum: ['add', 'subtract', 'multiply', 'divide'] },
a: { type: 'number' },
b: { type: 'number' }
},
required: ['operation', 'a', 'b']
},
annotations: {
read_only_hint: true,
idempotent_hint: true
}
) do |args, server_context|
operation = args['operation']
a = args['a']
b = args['b']
result = case operation
when 'add' then a + b
when 'subtract' then a - b
when 'multiply' then a * b
when 'divide'
return MCP::Tool::Response.new([{ type: 'text', text: 'Division by zero' }], is_error: true) if b == 0
a / b
else
return MCP::Tool::Response.new([{ type: 'text', text: "Unknown operation: #{operation}" }], is_error: true)
end
MCP::Tool::Response.new([{ type: 'text', text: "Result: #{result}" }])
endAdding Resources
Define resources for data access:
# Register resources
resource = MCP::Resource.new(
uri: 'resource://data/example',
name: 'example-data',
description: 'Example resource data',
mime_type: 'application/json'
)
server = MCP::Server.new(
name: 'my_server',
resources: [resource]
)
# Define read handler
server.resources_read_handler do |params|
case params[:uri]
when 'resource://data/example'
[{
uri: params[:uri],
mimeType: 'application/json',
text: { message: 'Example data', timestamp: Time.now }.to_json
}]
else
raise "Unknown resource: #{params[:uri]}"
end
endAdding Prompts
Define prompt templates:
Prompt as Class
class CodeReviewPrompt < MCP::Prompt
prompt_name 'code_review'
description 'Generate a code review prompt'
arguments [
MCP::Prompt::Argument.new(
name: 'language',
description: 'Programming language',
required: true
),
MCP::Prompt::Argument.new(
name: 'focus',
description: 'Review focus area',
required: false
)
]
def self.template(args, server_context:)
language = args['language'] || 'Ruby'
focus = args['focus'] || 'general quality'
MCP::Prompt::Result.new(
description: "Code review for #{language} with focus on #{focus}",
messages: [
MCP::Prompt::Message.new(
role: 'user',
content: MCP::Content::Text.new("Please review this #{language} code with focus on #{focus}.")
),
MCP::Prompt::Message.new(
role: 'assistant',
content: MCP::Content::Text.new("I'll review the code focusing on #{focus}. Please share the code.")
)
]
)
end
end
🎯 Best For
- UI designers
- Product designers
- Claude users
- GitHub Copilot users
- Software engineers
💡 Use Cases
- Generating component mockups
- Creating design system tokens
- Code quality improvement
- Best practice enforcement
📖 How to Use This Skill
- 1
Install the Skill
Copy the install command from the Terminal tab and run it. The SKILL.md file downloads to your local skills directory.
- 2
Load into Your AI Assistant
Open Claude or GitHub Copilot and reference the skill. Paste the SKILL.md content or use the system prompt tab.
- 3
Apply Ruby-Mcp-Server to Your Work
Open your project in the AI assistant and ask it to apply the skill. Start with a small module to verify the output quality.
- 4
Review and Refine
Review AI suggestions before committing. Run tests, check for regressions, and iterate on the skill output.
❓ Frequently Asked Questions
Does this work with Figma?
Some design skills integrate with Figma plugins. Check the Works With section for supported tools.
Is Ruby-Mcp-Server compatible with Cursor and VS Code?
Yes — this skill works with any AI coding assistant including Cursor, VS Code with Copilot, and JetBrains IDEs.
Do I need specific dependencies for Ruby-Mcp-Server?
Check the install command and Works With section. Most code skills only require the AI assistant and your codebase.
How do I install Ruby-Mcp-Server?
Copy the install command from the Terminal tab and run it. The skill downloads to ./skills/ruby-mcp-server/SKILL.md, ready to use.
Can I customize this skill for my team?
Absolutely. Edit the SKILL.md file to add team-specific instructions, examples, or workflows.
⚠️ Common Mistakes to Avoid
Skipping usability testing
AI-generated designs should be validated with real users before development.
Skipping validation
Always test AI-generated code changes, even for simple refactors.
Missing dependency updates
Check if the skill requires updated dependencies or new packages.