@nexusai6/mcpmeter-wrapper
v0.1.0
Published
MCP Meter wrapper for usage-based billing
Maintainers
Readme
@nexusai/mcpmeter-wrapper
MCP Meter wrapper for usage-based billing of MCP servers.
Installation
npm install @nexusai/mcpmeter-wrapperUsage
Wrap a single function
import { withMetering } from "@nexusai/mcpmeter-wrapper";
const myTool = withMetering(originalHandler, {
apiKey: "mpk_your_api_key_here",
serverId: "your_mcp_server_id",
});Manual reporting
import { reportCall } from "@nexusai/mcpmeter-wrapper";
await reportCall(
{ apiKey: "mpk_your_api_key_here", serverId: "your_mcp_server_id" },
"tool-name",
150, // duration in ms
{ userId: "123" } // optional metadata
);Configuration
| Option | Required | Default | Description |
|--------|----------|---------|-------------|
| apiKey | Yes | - | Your MCP Meter API key |
| serverId | Recommended | - | MCP Meter server ID. Required when using the default hosted endpoint. |
| endpoint | No | https://useaimeter.com/api/servers | MCP Meter API endpoint |
Features
- Fail-safe design: If MCP Meter is down, your server keeps running
- Zero latency impact: Async reporting, no blocking
- Simple setup: One line of code to wrap any function
