Skip to content

GET /api/cbmcp/stats endpoint throws EventHandlerNotRegisteredException #17

@edyionescu

Description

@edyionescu

What are the steps to reproduce this issue?

  1. Install cbmcp (1.0.0-snapshot) with statsEnabled: true in ModuleConfig.bx
  2. Start a ColdBox application with the module loaded
  3. Make a GET request to http://<host>:<port>/api/cbmcp/stats (as documented in the official docs under Monitoring Tool Calls)

What happens?

ColdBox throws an EventHandlerNotRegisteredException:

The event: api.cbmcp is not a valid registered event.

What were you expecting to happen?

A JSON response containing MCP server usage metrics as described in the docs under "Monitoring Tool Calls":

GET /api/cbmcp/stats
Returns detailed metrics on tool calls, resources accessed, and performance data.


Any logs, error output, etc?

EventHandlerNotRegisteredException
The event: api.cbmcp is not a valid registered event.

Stack trace points to coldbox\system\web\services\HandlerService.cfc:513.


Any other comments?

The MCPServerStats class collects data correctly when statsEnabled: true, and MCPServer exposes getStats() and getStatsSummary() methods. The stats data is there, it just has no HTTP surface.

Workaround: Add the following route to the module's Router.bx before the toMCP catch-all:

route( "/stats", function( event, rc, prc ){
    return mcpServer( "cbMCP" ).getStats()
} )
route( "/" ).toMCP( "cbMCP" )

Note: this surfaces the endpoint at /cbmcp/stats rather than /api/cbmcp/stats, as the module entry point is cbmcp, not api/cbmcp.


What versions are you using?

Operating System: Windows 11 Pro 25H2
Package Version: 1.0.0-snapshot

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions