Merged
Conversation
Replace the two-process bridge architecture (MCP server + rails runner) with an embedded executor that runs ActiveRecord queries directly. This eliminates the need for a YAML config file, bridge process management, and the JSON-lines protocol — one command, no config, real results. EmbeddedExecutor implements 9 Tier 1 tools (count, sample, find, pluck, aggregate, association_count, schema, recent, status) with real AR queries. Unsupported Tier 2-4 tools return clean error responses for incremental follow-up. All queries are wrapped in SafeContext (rolled- back transactions + statement timeout) with ModelValidator column checks and an aggregate function whitelist. Three invocation paths: - stdio: `bundle exec rake codebase_index:console` - rails runner: `bundle exec rails runner exe/codebase-console` - HTTP middleware: mount via `console_mcp_enabled` config flag
97005a2 to
5f09a09
Compare
added 2 commits
February 27, 2026 18:46
Two bugs found during live validation against compose-dev admin (mcp 0.7.1): - MCP::Tool::Response API changed from `is_error:` (0.6.0) to `error:` (0.7.1). Updated both error response paths in send_to_bridge. - Tier1 tool builders return symbol-keyed hashes. The bridge path stringifies via JSON round-trip, but the embedded executor expected string keys. Added deep_stringify_keys to replicate the JSON serialization behavior.
Owner
Author
Code reviewFound 2 issues:
codebase_index/codebase_index.gemspec Lines 39 to 41 in 56586c3
Generated with Claude Code If this code review was useful, please react with 👍. Otherwise, react with 👎. |
- Add codebase-console to spec.executables (was missing, breaking the pattern set by all other exe/ entries) - Add @param connection to Server.build_embedded YARD - Update register_tier*_tools @param conn_mgr type to include EmbeddedExecutor alongside ConnectionManager - Fix random_function @return from NamedFunction to SqlLiteral
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
unsupportederrors for incremental follow-up.Consumer setup (the payoff)
Stdio (Claude Code / Cursor):
{ "mcpServers": { "codebase-console": { "command": "bundle", "args": ["exec", "rake", "codebase_index:console"], "cwd": "/path/to/rails/app" } } }Docker:
{ "mcpServers": { "codebase-console": { "command": "docker", "args": ["exec", "-i", "my_container", "bundle", "exec", "rake", "codebase_index:console"] } } }HTTP (always-on, zero latency):
What's NOT changed
Existing bridge architecture (ConnectionManager, Bridge, exe/codebase-console-mcp, console.yml) stays intact for backward compatibility and Docker/SSH remote mode.
Test plan
bundle exec rake codebase_index:consolestarts, responds to MCP initialize, tool calls return real data🤖 Generated with Claude Code