Назад к каталогу
fast-mcp

fast-mcp

Сообщество

от yjacquin

0.0
0 отзывов

A Ruby Implementation of the Model Context Protocol

Установка

npx @modelcontextprotocol/inspector examples/server_with_stdio_transport.rb

Описание

# Fast MCP 🚀 <div align="center"> <h3>Connect AI models to your Ruby applications with ease</h3> <p>No complex protocols, no integration headaches, no compatibility issues – just beautiful, expressive Ruby code.</p> </div> <p align="center"> <a href="https://badge.fury.io/rb/fast-mcp"><img src="https://badge.fury.io/rb/fast-mcp.svg" alt="Gem Version" /></a> <a href="https://github.com/yjacquin/fast-mcp/workflows/CI/badge.svg"><img src="https://github.com/yjacquin/fast-mcp/workflows/CI/badge.svg" alt="CI Status" /></a> <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT" /></a> <a href="code_of_conduct.md"><img src="https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg" alt="Contributor Covenant" /></a> <a href="https://discord.gg/9HHfAtY3HF"><img src = "https://dcbadge.limes.pink/api/server/https://discord.gg/9HHfAtY3HF?style=flat" alt="Discord invite link" /></a> </p> ## 🌟 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](https://github.com/modelcontextprotocol), 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](https://github.com/dry-rb/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 ```ruby # 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") required(:address).description("The shipping address").hash do required(:street).filled(:string).description("Street address") optional(:city).filled(:string).description("City name") optional(:zipcode).maybe(:string).description("Postal code") end end def call(first_name:, age: nil, address: {}) User.create!(first_name:, age:, address:) end end # Register the tool with the server server.register_tool(CreateUserTool) # Share data resources with AI models by inheriting from FastMcp::Resource class PopularUsers < FastMcp::Resource uri "myapp:///users/popular" resource_name "Popular Users" mime_type "application/json" def content JSON.generate(User.popular.limit(5).as_json) end end class User < FastMcp::Resource uri "myapp:///users/{id}" # This is a resource template resource_name "user" mime_type "application/json" def content id = params[:id] # params are computed from the uri pattern JSON.generate(User.find(id).as_json) end end # Register the resource with the server server.register_resources(PopularUsers, User) # Accessing the resource through the server server.read_resource(PopularUsers.uri) # Notify the resource content has been updated to clients server.notify_resource_updated(PopularUsers.variabilized_uri) # Notifiy the content of a resource from a template has been updated to clients server.notify_resource_updated(User.variabilized_uri(id: 1)) ``` ### 🎯 Dynamic Tool Filtering Control which tools and resources are available based on request context: ```ruby # Tag your tools for easy filtering class AdminTool < FastMcp::Tool tags :admin, :dangerous description "Perform admin operations" def call # Admin only functionality end end # Filter tools based on user permissions server.filter_tools do |request, tools| user_role = request.params['role'] case user_role when 'admin' tools # Admins see all tools when 'user' tools.reject { |t| t.tags.include?(:admin) } else tools.select { |t| t.tags.include

Отзывы (0)

Пока нет отзывов. Будьте первым!