Fix #138: Feature: Built-in billing/monetization for MCP tools via Ag...#172
Open
JiwaniZakir wants to merge 1 commit intoQuantGeekDev:mainfrom
Open
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
pricingfield 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.tsToolPricinginterface (lines ~118–121) with optionalperCall: numberandfreeTier: numberfields.pricing?: ToolPricingproperty to both theToolProtocolinterface (inside theinputSchemablock, ~line 185) and theMCPToolabstract class (~line 235).toolDefinitiongetter spread (~line 871) to conditionally includepricingwhen the property is set and non-empty, consistent with howannotationsandexecutionare handled.tests/tools/tool-metadata.test.tsToolWithPricingfixture with{ perCall: 0.001, freeTier: 100 }andToolWithPartialPricingwith{ perCall: 0.005 }.pricingdescribe block: full pricing round-trips correctly intoolDefinition, partial pricing (onlyperCall) is preserved without dropping unset keys, and tools without apricingproperty do not emit the key at all.package-lock.jsonzodversion pin from^3.23.8to3.x.mcp-frameworkas a second bin alias pointing todist/cli/index.js.Testing
All three new unit tests pass with
npm test:The
pricingfield is purely additive and opt-in — existing tools with nopricingproperty continue to produce identicaltoolDefinitionoutput, verified by the third test againstBasicTool.This PR was created with AI assistance (Claude). The changes were reviewed by quality gates and a critic model before submission.