feat(mcp-actions): add server operation and session duration metrics (#32978)

Signed-off-by: Kurt King <kurtaking@gmail.com>
Co-authored-by: Kurt King <kurtaking@gmail.com>
This commit is contained in:
Ben Lambert
2026-02-24 17:18:02 +01:00
committed by GitHub
parent 1ee5b28e41
commit dc81af158f
8 changed files with 395 additions and 49 deletions
+8 -1
View File
@@ -75,7 +75,7 @@ export const myPlugin = createBackendPlugin({
When errors are thrown from MCP actions, the backend will handle and surface error message for any error from `@backstage/errors`. Unknown errors will be handled by `@modelcontextprotocol/sdk`'s default error handling, which may result in a generic `500 Server Error` being returned. As a result, we recommend using errors from `@backstage/errors` when applicable.
See https://backstage.io/api/stable/modules/_backstage_errors.html for a full list of supported errors.
See [Backstage Errors](https://backstage.io/docs/reference/errors/) for a full list of supported errors.
When writing MCP tools, use the appropriate error from `@backstage/errors` when applicable:
@@ -178,6 +178,13 @@ There's a few different ways to configure MCP tools, but here's a snippet of the
}
```
## Metrics
The MCP Actions Backend emits metrics for the following operations:
- `mcp.server.operation.duration`: The duration taken to process an individual MCP operation
- `mcp.server.session.duration`: The duration of the MCP session from the perspective of the server
## Development
This plugin backend can be started in a standalone mode from directly in this package with `yarn start`. It is a limited setup that is most convenient when developing the plugin backend itself.