4 pointsby moekiorg4 days ago1 comment
  • rco87863 days ago
    Very cool. How does activemcp figure out what tools I have defined? I haven't read the code, does it do a dynamic class lookup based on the tool name like rails does for controllers?

    What's the right way to start the server in an existing rails app? Do I just create the server and call start in an initializer or something?

    • moekiorg3 days ago
      Executed when a class inheriting from ActiveMcp::Tool is registered with its class name as the tool name and "tools/call" is requested in /mcp.

      Simply mount the engine in route.rb, define the tool and start it.

      • rco87863 days ago
        > start it.

        right I'm wondering where is the right place to start it! In an initializer?

        • moekiorg3 days ago
          No. Any file that runs MCP Server is fine anywhere. I am intending a workspace separate from the rails app. The MCP server should be run in a separate process from the rails app. At least until the streamable http transport is ready.

          https://github.com/modelcontextprotocol/specification/pull/2... https://spec.modelcontextprotocol.io/specification/2025-03-2...

          • rco87863 days ago
            > The MCP server should be run in a separate process from the rails app.

            Sorry super confused here. How can I do that while also booting up all the Rails stuff like the autoloader, db connections, etc?

            • moekiorg3 days ago
              Sorry for the misunderstanding, Active MCP requires two processes.

              1. mount the Engine and then `$ rails s` 2. `server.rb` to start the MCP server. `$ ruby path/to/server.rb`

              `server = ActiveMcp::Server.new(name: "ActiveMcp DEMO", uri: 'https://your-app.example.com/mcp' );server.start`

              Then, with an MCP client such as Claude Desktop, configure the following.

              `{"mcpServers": {"active-mcp-demo": {"command": "/path/to/ruby", "args": ["/path/to/server.rb"]}}}`