File Inventory

This is the real feature surface you need to account for when exporting MCP into another project.

Core Shared Runtime

File or area Role Export status
app/middleware/mcp/base_rack_app.rb Shared Rack transport, auth entry point, rate limiting, transport reuse Copy and adapt
app/models/mcp/token.rb Token scopes, digest lookup, permissions, revocation, regeneration Copy and adapt
app/models/mcp/activity_log.rb Tool call audit trail Copy and adapt
app/models/mcp/tools/concerns/formattable.rb Shared response helpers Copy almost as-is
app/models/mcp/tools/concerns/listable.rb Pagination and text formatting for list tools Copy almost as-is
app/models/mcp/tools/concerns/approvable.rb Shared approve and reject flow Optional; depends on your domain
app/models/mcp/tools/concerns/tool_metadata.rb Permission DSL for domain and action Copy as-is

Organization MCP Runtime

File or area Role Export status
app/middleware/mcp/rack_app.rb Org token authorization and request lifecycle hooks Copy and adapt
app/models/mcp/organization_context.rb Thread-safe tenant context object Copy and adapt
app/models/mcp/base_tool.rb Shared base for tenant-scoped tools Copy and adapt
app/models/mcp/server_builder.rb Registers org tool namespaces and filters them by permissions Copy and adapt
app/models/mcp/tools/** Actual org-facing tools Rebuild per target project

Admin MCP Runtime

File or area Role Export status
app/middleware/mcp/admin_rack_app.rb Admin token authorization Optional
app/models/mcp/admin/base_tool.rb Base class for platform-wide tools Optional
app/models/mcp/admin/server_builder.rb Admin tool registration and filtering Optional
app/models/mcp/admin/tools/** Admin analytics and CRM tools Rebuild per target project

Token Management Surface

File or area Role Export status
app/controllers/organizations/marketplace/mcp_settings_controller.rb Org MCP settings page and activity tab Optional but recommended
app/controllers/organizations/marketplace/mcp_tokens_controller.rb Org token create, update, revoke, regenerate Optional but recommended
app/controllers/admin/mcp_settings_controller.rb Admin token CRUD and activity list Optional
app/policies/organizations/marketplace/mcp_settings_policy.rb Org policy guard Adapt
app/policies/organizations/marketplace/mcp_tokens_policy.rb Org token CRUD policy guard Adapt
app/views/organizations/marketplace/mcp_settings/** Org MCP settings UI Optional
app/views/organizations/marketplace/mcp_tokens/** Org token form and permission toggles Optional
app/views/admin/mcp_settings/** Admin settings and activity UI Optional

Routes And Dependency Hooks

File or area Role Export status
config/routes.rb Mounts /mcp and /admin/mcp, plus token management routes Copy and adapt
Gemfile Adds gem "mcp", "~> 0.10.0" Required
app/models/current.rb Holds mcp_request flag in this repository Optional but useful

Database Contract

In this repository, the final mcp_tokens contract is broader than the first migration because the model later gained scope, token_prefix, and optional organization support.

For a fresh export, build the target project around the current model contract rather than replaying this repo's migration history.

  • organization_id, nullable if admin tokens are supported
  • name, non-null
  • token_digest, non-null, unique
  • token_prefix, nullable but recommended
  • permissions, JSON, non-null, default {}
  • scope, non-null, default organization
  • last_used_at
  • revoked_at
  • timestamps
  • mcp_token_id, non-null
  • organization_id, nullable if admin tokens are supported
  • tool_name, non-null
  • domain, non-null
  • action_type, non-null
  • arguments, JSON
  • result_summary, JSON
  • status_code
  • timestamps

Live Tool Inventory Snapshot

Organization MCP domains

  • listings
  • documentation
  • forms
  • reviews
  • leads
  • pipelines
  • analytics
  • ai_activity

Current live code exposes 28 org tools.

Admin MCP domains

  • platform_stats
  • organizations
  • listings_stats
  • leads_stats
  • documentation_stats
  • submissions_stats
  • crm

Current live code exposes 16 admin tools.

Must-Copy Minimum Set

If you want a minimal but working export, start with these:

  1. Gemfile dependency on mcp
  2. app/middleware/mcp/base_rack_app.rb
  3. app/middleware/mcp/rack_app.rb
  4. app/models/mcp/token.rb
  5. app/models/mcp/activity_log.rb
  6. app/models/mcp/organization_context.rb
  7. app/models/mcp/base_tool.rb
  8. app/models/mcp/server_builder.rb
  9. app/models/mcp/tools/concerns/*
  10. target-specific tool classes
  11. routes that mount the Rack app

Everything else can be layered in after the endpoint already works.