Skip to content

Fix #138: Feature: Built-in billing/monetization for MCP tools via Ag...#172

Open
JiwaniZakir wants to merge 1 commit intoQuantGeekDev:mainfrom
JiwaniZakir:fix/138-feature-built-in-billing-monetization-fo
Open

Fix #138: Feature: Built-in billing/monetization for MCP tools via Ag...#172
JiwaniZakir wants to merge 1 commit intoQuantGeekDev:mainfrom
JiwaniZakir:fix/138-feature-built-in-billing-monetization-fo

Conversation

@JiwaniZakir
Copy link
Copy Markdown

Closes #138

Motivation

MCP tool authors have no standard way to advertise per-call pricing metadata alongside their tool definitions. This adds a lightweight, optional pricing field to the tool schema so billing proxies and agent orchestrators can discover cost information directly from the tool's protocol response.

Changes

src/tools/BaseTool.ts

  • Added ToolPricing interface (lines ~118–121) with optional perCall: number and freeTier: number fields.
  • Added pricing?: ToolPricing property to both the ToolProtocol interface (inside the inputSchema block, ~line 185) and the MCPTool abstract class (~line 235).
  • Extended the toolDefinition getter spread (~line 871) to conditionally include pricing when the property is set and non-empty, consistent with how annotations and execution are handled.

tests/tools/tool-metadata.test.ts

  • Added ToolWithPricing fixture with { perCall: 0.001, freeTier: 100 } and ToolWithPartialPricing with { perCall: 0.005 }.
  • Added three tests under a new pricing describe block: full pricing round-trips correctly in toolDefinition, partial pricing (only perCall) is preserved without dropping unset keys, and tools without a pricing property do not emit the key at all.

package-lock.json

  • Relaxed zod version pin from ^3.23.8 to 3.x.
  • Added mcp-framework as a second bin alias pointing to dist/cli/index.js.

Testing

All three new unit tests pass with npm test:

pricing
  ✓ should include pricing in toolDefinition when set
  ✓ should include partial pricing in toolDefinition
  ✓ should not include pricing key when not set

The pricing field is purely additive and opt-in — existing tools with no pricing property continue to produce identical toolDefinition output, verified by the third test against BasicTool.


This PR was created with AI assistance (Claude). The changes were reviewed by quality gates and a critic model before submission.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Built-in billing/monetization for MCP tools via Agent Bazaar

1 participant