
模型上下文协议的Ruby实现
概览
轻松将AI模型连接到您的Ruby应用中。无需复杂协议,无需集成烦恼,也无需兼容性问题——只有美丽且富有表现力的Ruby代码。 AI模型强大,但它们需要与你的应用交互才能真正发挥作用。传统方法意味着要应对以下问题: - 🔄 复杂的通信协议和自定义JSON格式 - 🔌 与不同模型提供商的集成挑战 - 🧩 应用与AI工具的兼容性问题 - 🧠 管理AI交互与数据之间的状态 Fast MCP通过提供一个干净、以Ruby为核心的模型上下文协议实现,解决了所有这些问题,使AI集成变得愉快而非负担。 - 🛠️ - 让 AI 模型安全地调用你的 Ruby 函数,并通过 Dry-Schema 进行深入的参数验证。- 📚 - 在你的应用和 AI 模型之间共享数据 - 🔄 - 根据需求选择 STDIO、HTTP 或 SSE - 🧩 与 Rails、Sinatra 或任何 Rack 应用无缝兼容。
概述(AI 翻译)
轻松将AI模型连接到您的Ruby应用中 没有复杂的协议,没有集成的麻烦,没有兼容性问题——只有美丽且富有表现力的Ruby代码。
🌟 几分钟内即可将服务器与大型语言模型连接起来
AI模型强大,但它们需要与你的应用交互才能真正发挥作用。传统方法意味着要应对以下问题:
- 🔄 复杂的通信协议和自定义JSON格式
- 🔌 与不同模型供应商的集成挑战
- 🧩 你的应用与AI工具之间的兼容性问题
- 🧠 管理AI交互与数据之间的状态
Fast MCP通过提供一个干净、以Ruby为核心的模型上下文协议实现,解决了所有这些问题,使AI集成变得愉快而非负担。
✨ 特色
- 🛠️ 工具API - 让AI模型安全地调用你的Ruby函数,并通过Dry-Schema进行深入的参数验证。
- 📚 资源API - 在你的应用和AI模型之间共享数据
- 🔄 多重传输 - 根据需求选择STDIO、HTTP或SSE
- 🧩 框架集成 - 与Rails、Sinatra或任何Rack应用无缝配合。
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
Fast MCP 🚀
🌟 Interface your Servers with LLMs in minutes
AI models are powerful, but they need to interact with your applications to be truly useful. Traditional approaches mean wrestling with:
- 🔄 Complex communication protocols and custom JSON formats
- 🔌 Integration challenges with different model providers
- 🧩 Compatibility issues between your app and AI tools
- 🧠 Managing the state between AI interactions and your data
Fast MCP solves all these problems by providing a clean, Ruby-focused implementation of the Model Context Protocol, making AI integration a joy, not a chore.
✨ Features
- 🛠️ Tools API - Let AI models call your Ruby functions securely, with in-depth argument validation through Dry-Schema.
- 📚 Resources API - Share data between your app and AI models
- 🔄 Multiple Transports - Choose from STDIO, HTTP, or SSE based on your needs
- 🧩 Framework Integration - Works seamlessly with Rails, Sinatra or any Rack app.
- 🔒 Authentication Support - Secure your AI-powered endpoints with ease
- 🚀 Real-time Updates - Subscribe to changes for interactive applications
- 🎯 Dynamic Filtering - Control tool/resource access based on request context (permissions, API versions, etc.)
💎 What Makes FastMCP Great
# Define tools for AI models to use
server = FastMcp::Server.new(name: 'popular-users', version: '1.0.0')
# Define a tool by inheriting from FastMcp::Tool
class CreateUserTool < FastMcp::Tool
description "Create a user"
# These arguments will generate the needed JSON to be presented to the MCP Client
# And they will be validated at run time.
# The validation is based off Dry-Schema, with the addition of the description.
arguments do
required(:first_name).filled(:string).description("First name of the user")
optional(:age).filled(:integer).description("Age of the user")
安装
npx @modelcontextprotocol/inspector examples/server_with_stdio_transport.rb配置
{
"mcpServers": {
"my-great-server": {
"command": "ruby",
"args": ["/Users/path/to/your/awesome/fast-mcp/server.rb"]
}
}
}