A Ruby gem for integrating Large Language Models (LLMs) via the Model Context Protocol (MCP) into development workflows.
A Ruby gem that exposes Large Language Models (LLMs) via the Model Context Protocol (MCP), enabling seamless integration of AI capabilities into your development workflow.
llm-mcp creates an MCP server that provides standardized access to various LLM providers (OpenAI, Google Gemini, and OpenAI-compatible APIs) while supporting advanced features like session management, conversation persistence, and integration with external MCP tools.
Add this line to your application's Gemfile:
gem 'llm-mcp'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install llm-mcp
Set up your API keys based on the provider you want to use:
# For OpenAI
export OPENAI_API_KEY="your-openai-api-key"
# For Google Gemini
export GEMINI_API_KEY="your-gemini-api-key"
# or
export GOOGLE_API_KEY="your-google-api-key"
Start an MCP server that exposes an LLM:
# Using OpenAI
llm-mcp mcp-serve --provider openai --model gpt-4
# Using Google Gemini
llm-mcp mcp-serve --provider google --model gemini-1.5-flash
# Using a custom OpenAI-compatible API
llm-mcp mcp-serve --provider openai --model llama-3.1-8b --base-url https://api.groq.com/openai/v1
llm-mcp mcp-serve \
--provider openai \
--model gpt-4 \
--verbose \ # Enable verbose logging
--json-log-path logs/llm.json \ # Log to JSON file
--session-id my-project \ # Resume a specific session
--session-path ~/my-sessions \ # Custom session storage location
--append-system-prompt "You are a Ruby expert" \ # Add to system prompt
--skip-model-validation # Skip model name validation
llm-mcp can connect to other MCP servers, allowing the LLM to use their tools:
~/.mcp/config.json
):{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["@modelcontextprotocol/server-filesystem", "/tmp"]
},
"github": {
"command": "mcp-github",
"env": {
"GITHUB_TOKEN": "your-github-token"
}
},
"http-api": {
"url": "https://api.example.com/mcp/sse",
"transport": "sse",
"headers": {
"Authorization": "Bearer your-token"
}
}
}
}
llm-mcp mcp-serve \
--provider openai \
--model gpt-4 \
--mcp-config ~/.mcp/config.json
Now the LLM can use tools from the connected MCP servers in its responses!
task
Send a request to the LLM and get a response.
Parameters:
prompt
(required): The message or question for the LLMtemperature
(optional): Control randomness (0.0-2.0, default: 0.7)max_tokens
(optional): Maximum response lengthExample Request:
{
"method": "tools/call",
"params": {
"name": "task",
"arguments": {
"prompt": "Explain the concept of dependency injection",
"temperature": 0.7,
"max_tokens": 500
}
}
}
reset_session
Clear the conversation history and start fresh.
Example Request:
{
"method": "tools/call",
"params": {
"name": "reset_session",
"arguments": {}
}
}
Sessions automatically persist conversations to disk, allowing you to:
Sessions are stored in ~/.llm-mcp/sessions/
by default, with each session saved as a JSON file.
Session files contain:
Enable JSON logging for comprehensive debugging:
llm-mcp mcp-serve \
--provider openai \
--model gpt-4 \
--json-log-path logs/llm.json \
--verbose
Logs include:
Add to your Claude Desktop configuration (~/Library/Application Support/Claude/claude_desktop_config.json
):
{
"mcpServers": {
"llm-mcp": {
"command": "llm-mcp",
"args": ["mcp-serve", "--provider", "openai", "--model", "gpt-4"],
"env": {
"OPENAI_API_KEY": "your-api-key"
}
}
}
}
require 'mcp-client'
client = MCP::Client.new
client.connect_stdio('llm-mcp', 'mcp-serve', '--provider', 'openai', '--model', 'gpt-4')
# Use the task tool
response = client.call_tool('task', {
prompt: "Write a haiku about Ruby programming",
temperature: 0.9
})
puts response.content
Create a powerful AI assistant by combining llm-mcp with other MCP servers:
{
"mcpServers": {
"llm": {
"command": "llm-mcp",
"args": ["mcp-serve", "--provider", "openai", "--model", "gpt-4", "--mcp-config", "mcp-tools.json"]
},
"filesystem": {
"command": "mcp-filesystem",
"args": ["/project"]
},
"git": {
"command": "mcp-git"
}
}
}
After checking out the repo, run bin/setup
to install dependencies. Then, run rake test
to run the tests.
# Install dependencies
bundle install
# Run tests
bundle exec rake test
# Run linter
bundle exec rubocop -A
# Install gem locally
bundle exec rake install
Bug reports and pull requests are welcome on GitHub at https://github.com/parruda/llm-mcp.
The gem is available as open source under the terms of the MIT License.
Tool platform by IBM to build, test and deploy tools for any data source
Gentoro generates MCP Servers based on OpenAPI specifications.
Interact with Homebrew (the package manager for macOS and Linux) using natural language commands.
Connects to the React Native application debugger to retrieve console logs from Metro.
An MCP server that provides control over Android devices through ADB. Offers device screenshot capture, UI layout analysis, package management, and ADB command execution capabilities.
A server for blockchain interactions, offering Ethereum vanity address generation, 4byte lookup, ABI encoding, and multi-chain RPC calls.
Execute shell commands without permission prompts.
A server for splitting and extracting parts of OpenAPI specifications using Redocly CLI.
An MCP server for ESP-IDF workflows, enabling project builds, firmware flashing, and automated issue resolution from build logs.
Gru-sandbox(gbox) is an open source project that provides a self-hostable sandbox for MCP integration or other AI agent usecases.