### Get Documentation for Application Method Source: https://context7.com/tidewave-ai/tidewave_rails/llms.txt Use the `get_docs` tool to retrieve RDoc/YARD documentation for application-specific methods. ```bash curl -s -X POST http://localhost:3000/tidewave/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 18, "method": "tools/call", "params": { "name": "get_docs", "arguments": { "reference": "Order#charge!" } } }' | jq . ``` -------------------------------- ### MCP Endpoint - List Available Tools Source: https://context7.com/tidewave-ai/tidewave_rails/llms.txt This example demonstrates how to list all available MCP tools by sending a JSON-RPC request to the /tidewave/mcp endpoint. ```APIDOC ## POST /tidewave/mcp - List Tools ### Description Lists all available MCP tools that can be called by AI coding agents. ### Method POST ### Endpoint /tidewave/mcp ### Parameters #### Request Body - **jsonrpc** (string) - Required - Specifies the JSON-RPC version. - **id** (integer) - Required - The ID of the request. - **method** (string) - Required - The method to call, should be "tools/list". - **params** (object) - Optional - Parameters for the method, empty for "tools/list". ### Request Example ```json { "jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {} } ``` ### Response #### Success Response (200) - **jsonrpc** (string) - The JSON-RPC version. - **id** (integer) - The ID of the request. - **result** (object) - Contains the list of available tools. - **tools** (array) - An array of tool objects. - **name** (string) - The name of the tool. - **description** (string) - A description of the tool. - **inputSchema** (object) - The schema for the tool's input. #### Response Example ```json { "jsonrpc": "2.0", "id": 1, "result": { "tools": [ { "name": "execute_sql_query", "description": "...", "inputSchema": { ... } }, { "name": "get_docs", "description": "...", "inputSchema": { ... } }, { "name": "get_logs", "description": "...", "inputSchema": { ... } }, { "name": "get_models", "description": "...", "inputSchema": { ... } }, { "name": "get_source_location","description": "...", "inputSchema": { ... } }, { "name": "project_eval", "description": "...", "inputSchema": { ... } } ] } } ``` #### Error Response (e.g., 400 for invalid JSON-RPC) ```json { "jsonrpc": "2.0", "error": { "code": -32600, "message": "Invalid Request" }, "id": null } ``` ``` -------------------------------- ### Get Documentation for Standard Library Method Source: https://context7.com/tidewave-ai/tidewave_rails/llms.txt Use the `get_docs` tool to retrieve RDoc/YARD documentation for standard library methods. ```bash curl -s -X POST http://localhost:3000/tidewave/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 17, "method": "tools/call", "params": { "name": "get_docs", "arguments": { "reference": "String#gsub" } } }' | jq . ``` -------------------------------- ### MCP Endpoint - Call a Tool Source: https://context7.com/tidewave-ai/tidewave_rails/llms.txt This example shows how to call a specific MCP tool, such as 'execute_sql_query', by sending a JSON-RPC request to the /tidewave/mcp endpoint. ```APIDOC ## POST /tidewave/mcp - Call Tool ### Description Calls a specific MCP tool with provided arguments. ### Method POST ### Endpoint /tidewave/mcp ### Parameters #### Request Body - **jsonrpc** (string) - Required - Specifies the JSON-RPC version. - **id** (integer) - Required - The ID of the request. - **method** (string) - Required - The method to call, should be "tools/call". - **params** (object) - Required - Parameters for the method. - **name** (string) - Required - The name of the tool to call (e.g., "execute_sql_query"). - **arguments** (object) - Required - The arguments for the tool. ### Request Example ```json { "jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": { "name": "execute_sql_query", "arguments": { "query": "SELECT id, email, created_at FROM users ORDER BY created_at DESC LIMIT 5" } } } ``` ### Response #### Success Response (200) - **jsonrpc** (string) - The JSON-RPC version. - **id** (integer) - The ID of the request. - **result** (object) - The result of the tool execution. - **columns** (array) - An array of column names. - **rows** (array) - An array of row data. - **row_count** (integer) - The total number of rows returned. - **adapter** (string) - The database adapter name. - **database** (string) - The database name. #### Response Example ```json { "jsonrpc": "2.0", "id": 2, "result": { "columns": ["id", "email", "created_at"], "rows": [[1,"alice@example.com","2025-01-10T09:00:00Z"], ...], "row_count": 5, "adapter": "PostgreSQL", "database": "myapp_development" } } ``` ``` -------------------------------- ### Install Tidewave Gem Source: https://github.com/tidewave-ai/tidewave_rails/blob/main/README.md Add the tidewave gem to your project's development dependencies. Ensure you are using a recent version of rack-session if configuring for multiple hosts. ```shell bundle add tidewave --group development ``` -------------------------------- ### Standalone Tidewave MCP Server Setup Source: https://context7.com/tidewave-ai/tidewave_rails/llms.txt This configuration demonstrates how to use Tidewave as a standalone MCP server within a Rack application. It requires the 'tidewave' and 'fast-mcp' gems and sets up the FastMCP Rack middleware. ```ruby # Gemfile (standalone Rack app) gem "tidewave" gem "fast-mcp", "~> 1.6.0" # config.ru require "tidewave" require "fast_mcp" app = FastMcp.rack_middleware( ->(env) { [200, {}, ["OK"]] }, name: "tidewave", version: Tidewave::VERSION, path_prefix: "/tidewave/mcp", transport: Tidewave::StreamableHttpTransport ) do |server| server.register_tools(*Tidewave::Tools::Base.descendants) end run app ``` -------------------------------- ### Install and Configure Tidewave Gem Source: https://context7.com/tidewave-ai/tidewave_rails/llms.txt Add the tidewave gem to your Gemfile for the development group and configure its options in config/environments/development.rb or an initializer. All configuration options are available under config.tidewave. ```ruby gem "tidewave", group: :development ``` ```ruby Rails.application.configure do # Allow connections from non-localhost IPs (default: true in config, but # middleware blocks remote IPs unless explicitly enabled) config.tidewave.allow_remote_access = false # Choose ORM: :active_record (default) or :sequel config.tidewave.preferred_orm = :active_record # Override the logger (default: log/tidewave.log) config.tidewave.logger = Logger.new($stdout) # Silence a custom logger middleware (default: Rails::Rack::Logger) config.tidewave.logger_middleware = Rails::Rack::Logger # Set team configuration for Tidewave Web config.tidewave.team = { id: "my-company" } end ``` -------------------------------- ### Retrieve Tidewave Configuration Source: https://context7.com/tidewave-ai/tidewave_rails/llms.txt Fetch the current Tidewave configuration for the project by making a GET request to the /tidewave/config endpoint. This is used by Tidewave Web to identify the project. ```bash curl -s http://localhost:3000/tidewave/config | jq . ``` -------------------------------- ### Get Last N Log Entries Source: https://context7.com/tidewave-ai/tidewave_rails/llms.txt Retrieve the last N entries from the Rails log file. This is useful for quickly inspecting recent activity. ```bash curl -s -X POST http://localhost:3000/tidewave/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 9, "method": "tools/call", "params": { "name": "get_logs", "arguments": { "tail": 20 } } }' | jq . ``` -------------------------------- ### Execute SQL Query with Sequel Placeholders Source: https://context7.com/tidewave-ai/tidewave_rails/llms.txt When using Sequel, SQL queries use `?` for parameterized arguments. Ensure `config.tidewave.preferred_orm` is set to `:sequel`. ```bash curl -s -X POST http://localhost:3000/tidewave/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 21, "method": "tools/call", "params": { "name": "execute_sql_query", "arguments": { "query": "SELECT * FROM users WHERE id = ?", "arguments": [1] } } }' | jq . ``` -------------------------------- ### Enumerate All Database Models Source: https://context7.com/tidewave-ai/tidewave_rails/llms.txt List all database-backed model classes in the application, including their source file paths and definition line numbers. This requires eager-loading all models first. ```bash curl -s -X POST http://localhost:3000/tidewave/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 12, "method": "tools/call", "params": { "name": "get_models", "arguments": {} } }' | jq . ``` -------------------------------- ### Locate Instance Method Source Source: https://context7.com/tidewave-ai/tidewave_rails/llms.txt Use the `get_source_location` tool to find the file path and line number for an instance method. ```bash curl -s -X POST http://localhost:3000/tidewave/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 14, "method": "tools/call", "params": { "name": "get_source_location", "arguments": { "reference": "Order#total_price" } } }' | jq . ``` -------------------------------- ### Handle Documentation Not Found Source: https://context7.com/tidewave-ai/tidewave_rails/llms.txt When documentation for a reference cannot be found, the `get_docs` tool returns an error object. ```bash curl -s -X POST http://localhost:3000/tidewave/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 19, "method": "tools/call", "params": { "name": "get_docs", "arguments": { "reference": "NonExistent#method" } } }' | jq . ``` -------------------------------- ### Execute SQL Query using Tidewave Source: https://context7.com/tidewave-ai/tidewave_rails/llms.txt Use the 'execute_sql_query' tool via the MCP endpoint to run raw SQL queries. Supports parameterized queries with $1/$2 for PostgreSQL and ? for MySQL. Results are capped at 50 rows. ```bash # Simple SELECT curl -s -X POST http://localhost:3000/tidewave/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": { "name": "execute_sql_query", "arguments": { "query": "SELECT id, email, created_at FROM users ORDER BY created_at DESC LIMIT 5" } } }' | jq .result ``` -------------------------------- ### Configure Sequel ORM Source: https://context7.com/tidewave-ai/tidewave_rails/llms.txt Set `config.tidewave.preferred_orm` to `:sequel` to use Sequel as the ORM. This changes placeholder syntax for SQL queries. ```ruby config.tidewave.preferred_orm = :sequel ``` -------------------------------- ### Execute SQL Query with ActiveRecord Placeholders Source: https://context7.com/tidewave-ai/tidewave_rails/llms.txt When using ActiveRecord, SQL queries use `$1`, `$2`, etc. for parameterized arguments. ```bash curl -s -X POST http://localhost:3000/tidewave/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 20, "method": "tools/call", "params": { "name": "execute_sql_query", "arguments": { "query": "SELECT * FROM users WHERE id = $1", "arguments": [1] } } }' | jq . ``` -------------------------------- ### Configure Session Store for Multiple Hosts Source: https://github.com/tidewave-ai/tidewave_rails/blob/main/README.md Configure the session store in `config/initializers/development.rb` to allow your application to run embedded within Tidewave across multiple subdomains. This is crucial when using multiple hosts or subdomains during development and requires `rack-session` version 2.1.0 or later. ```ruby config.session_store :cookie_store, key: "__your_app_session", same_site: :none, secure: true, assume_ssl: true ``` -------------------------------- ### Execute SQL Query with Parameters (PostgreSQL) Source: https://context7.com/tidewave-ai/tidewave_rails/llms.txt Use this to execute SQL queries with parameterized arguments, preventing SQL injection. Ensure your database supports the specified placeholders (e.g., $1, $2 for PostgreSQL). ```bash curl -s -X POST http://localhost:3000/tidewave/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 3, "method": "tools/call", "params": { "name": "execute_sql_query", "arguments": { "query": "SELECT * FROM orders WHERE user_id = $1 AND status = $2", "arguments": [42, "pending"] } } }' | jq . ``` -------------------------------- ### Configure ActiveRecord ORM Source: https://context7.com/tidewave-ai/tidewave_rails/llms.txt Set `config.tidewave.preferred_orm` to `:active_record` to use ActiveRecord as the ORM. This is the default. ```ruby config.tidewave.preferred_orm = :active_record ``` -------------------------------- ### Locate Class Method Source Source: https://context7.com/tidewave-ai/tidewave_rails/llms.txt Use the `get_source_location` tool to find the file path and line number for a class method. ```bash curl -s -X POST http://localhost:3000/tidewave/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 15, "method": "tools/call", "params": { "name": "get_source_location", "arguments": { "reference": "User.authenticate" } } }' | jq . ``` -------------------------------- ### Config Endpoint Source: https://context7.com/tidewave-ai/tidewave_rails/llms.txt Retrieves the current Tidewave configuration for the project, used by Tidewave Web. ```APIDOC ## GET /tidewave/config ### Description Returns a JSON object describing the current project's Tidewave configuration. ### Method GET ### Endpoint /tidewave/config ### Response #### Success Response (200) - **project_name** (string) - The name of the project. - **framework_type** (string) - The type of framework (e.g., "rails"). - **tidewave_version** (string) - The installed Tidewave version. - **team** (object) - Team configuration details. - **id** (string) - The team ID. #### Response Example ```json { "project_name": "MyApp", "framework_type": "rails", "tidewave_version": "0.4.2", "team": { "id": "my-company" } } ``` ``` -------------------------------- ### Paginate Large SQL Result Sets Source: https://context7.com/tidewave-ai/tidewave_rails/llms.txt Retrieve paginated results from SQL queries by specifying LIMIT and OFFSET. This is useful for handling large datasets efficiently. ```bash curl -s -X POST http://localhost:3000/tidewave/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 4, "method": "tools/call", "params": { "name": "execute_sql_query", "arguments": { "query": "SELECT id, name FROM products LIMIT 50 OFFSET 100" } } }' | jq . ``` -------------------------------- ### Locate Model Class Source Source: https://context7.com/tidewave-ai/tidewave_rails/llms.txt Use the `get_source_location` tool to find the file path and line number for a model class definition. ```bash curl -s -X POST http://localhost:3000/tidewave/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 13, "method": "tools/call", "params": { "name": "get_source_location", "arguments": { "reference": "User" } } }' | jq . ``` -------------------------------- ### Evaluate Ruby Code with Arguments Source: https://context7.com/tidewave-ai/tidewave_rails/llms.txt Execute Ruby code that accepts arguments. These arguments are passed via the `arguments` array within the tool call and can be accessed using `arguments[index]`. ```bash curl -s -X POST http://localhost:3000/tidewave/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 6, "method": "tools/call", "params": { "name": "project_eval", "arguments": { "code": "User.find(arguments[0]).update!(role: arguments[1])", "arguments": [7, "admin"] } } }' | jq . ``` -------------------------------- ### Find Gem Dependency Root Path Source: https://context7.com/tidewave-ai/tidewave_rails/llms.txt Use the `get_source_location` tool with a `dep:` prefix to find the root directory of a gem dependency. ```bash curl -s -X POST http://localhost:3000/tidewave/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 16, "method": "tools/call", "params": { "name": "get_source_location", "arguments": { "reference": "dep:devise" } } }' | jq . ``` -------------------------------- ### Filter Log Entries with Regex Source: https://context7.com/tidewave-ai/tidewave_rails/llms.txt Fetch log entries and filter them using a case-insensitive regular expression. Specify the number of tail entries and the grep pattern. ```bash curl -s -X POST http://localhost:3000/tidewave/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 10, "method": "tools/call", "params": { "name": "get_logs", "arguments": { "tail": 50, "grep": "error" } } }' | jq . ``` -------------------------------- ### Configure Tidewave Team Settings Source: https://github.com/tidewave-ai/tidewave_rails/blob/main/README.md Set your Tidewave Team configuration, including the team ID. This is part of the general Tidewave configuration options available. ```ruby config.tidewave.team = { id: "my-company" } ``` -------------------------------- ### Permit Remote Access to Tidewave Source: https://context7.com/tidewave-ai/tidewave_rails/llms.txt Set `config.tidewave.allow_remote_access = true` in `config/environments/development.rb` to permit connections from non-localhost IP addresses. ```ruby config.tidewave.allow_remote_access = true ``` -------------------------------- ### Evaluate Simple Ruby Expression Source: https://context7.com/tidewave-ai/tidewave_rails/llms.txt Execute a simple Ruby expression within the Rails application context. The result is returned as a string. ```bash curl -s -X POST http://localhost:3000/tidewave/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 5, "method": "tools/call", "params": { "name": "project_eval", "arguments": { "code": "User.count" } } }' | jq . ``` -------------------------------- ### Evaluate Ruby Code for Structured JSON Output Source: https://context7.com/tidewave-ai/tidewave_rails/llms.txt Capture stdout, stderr, and the result of Ruby code evaluation in a structured JSON format. Useful for debugging and integrating tool output. ```bash curl -s -X POST http://localhost:3000/tidewave/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 7, "method": "tools/call", "params": { "name": "project_eval", "arguments": { "code": "puts User.first.inspect; User.first", "json": true, "timeout": 5000 } } }' | jq . ``` -------------------------------- ### Verify Tidewave Middleware in Rails Source: https://context7.com/tidewave-ai/tidewave_rails/llms.txt Use this command to check if Tidewave's middleware components are included in your Rails application's middleware stack. This helps in debugging and understanding the middleware order. ```bash rails middleware | grep -i tidewave ``` -------------------------------- ### Interact with Tidewave MCP Endpoint Source: https://context7.com/tidewave-ai/tidewave_rails/llms.txt The MCP endpoint is a POST-only JSON-RPC 2.0 service at /tidewave/mcp. Use curl to list available tools or execute them. Ensure correct JSON-RPC structure and POST method for requests. ```bash # List available MCP tools curl -s -X POST http://localhost:3000/tidewave/mcp \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}' | jq . ``` ```bash # Error: invalid JSON-RPC curl -s -X POST http://localhost:3000/tidewave/mcp \ -H "Content-Type: application/json" \ -d '{"not":"valid"}' | jq . ``` ```bash # Error: only POST is accepted curl -s -X GET http://localhost:3000/tidewave/mcp | jq . ``` -------------------------------- ### Evaluate Ruby Code with Timeout Source: https://context7.com/tidewave-ai/tidewave_rails/llms.txt Execute Ruby code with a specified timeout in milliseconds. If the code execution exceeds the timeout, a `Timeout::Error` is raised. ```bash curl -s -X POST http://localhost:3000/tidewave/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 8, "method": "tools/call", "params": { "name": "project_eval", "arguments": { "code": "sleep 10", "timeout": 2000 } } }' | jq . ``` -------------------------------- ### Add Tidewave Gem to Gemfile Source: https://github.com/tidewave-ai/tidewave_rails/blob/main/README.md Manually add the tidewave gem to the development group in your Gemfile. This is an alternative to using the `bundle add` command. ```ruby gem "tidewave", group: :development ``` -------------------------------- ### Filter Logs for Specific Controller Source: https://context7.com/tidewave-ai/tidewave_rails/llms.txt Retrieve log entries and filter them for a specific controller name using a case-insensitive regex. This helps in isolating logs related to a particular part of the application. ```bash curl -s -X POST http://localhost:3000/tidewave/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 11, "method": "tools/call", "params": { "name": "get_logs", "arguments": { "tail": 10, "grep": "OrdersController" } } }' | jq . ``` -------------------------------- ### Configure Custom Logger Middleware in Rails Source: https://context7.com/tidewave-ai/tidewave_rails/llms.txt If you replace the default Rails logger middleware, you can configure Tidewave to use your custom logger middleware. This is typically done in the environment configuration file. ```ruby # config/environments/production.rb — do NOT add tidewave here. # If attempted: # => RuntimeError: For security reasons, Tidewave is only supported in environments # where config.enable_reloading is true (typically development) # Custom logger middleware (if you replaced Rails::Rack::Logger) config.tidewave.logger_middleware = MyApp::CustomRequestLogger ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.