@leashmarket/mcp-core is the shared kernel that all Leash MCP adapters build on.
It defines the LeashHost runtime contract, the LeashTool primitive, and the
canonical LEASH_TOOLS list — keeping each adapter thin and free of duplicated logic.
Install
Concepts
LeashHost
The LeashHost interface is the only contract an adapter must satisfy. It carries
everything the tools need at runtime: credentials, network, signer, and API base URL.
LeashTool / defineTool
Each tool is a typed triple: a name, a Zod input schema, and a handler that receives
(host, args) and returns a LeashToolResult.
LEASH_TOOLS
The full set of built-in tools exported as an array. Adapters iterate this list to
register every capability without importing each tool individually.
leash_create_payment_link accepts optional protocol
(x402 | mpp, default x402), method (GET | POST), and
upstream_url. When upstream_url is set, the hosted payment link
monetizes that existing endpoint and forwards paid calls there after settlement.
For POST endpoints, pass expected_request_body as any JSON object to
describe what buyers should send to the hosted paywall URL.
leash_pay_payment_link accepts optional method
(GET | POST) and body (string, e.g. JSON) for POST paywalls — same
dual-protocol behaviour as the CLI leash pay command.
Agent API-key tools: leash_create_agent_api_key,
leash_list_agent_api_keys, and leash_revoke_agent_api_key let a configured
agent bootstrap its own agent scoped API key by signing with the local
executive keypair. The created key is bound to the active agent mint, owned by
the executive public key, and returns plaintext only once.
Built-in tools
| Tool name | Description |
|---|---|
leash_discover | Browse the Leash + pay-skills provider catalog |
leash_create_agent_api_key | Create an agent-scoped API key with X-Leash-Sig |
leash_list_agent_api_keys | List this agent’s API keys (no plaintext) |
leash_revoke_agent_api_key | Disable an agent-owned API key |
leash_pay_payment_link | Pay an x402 or MPP payment link with the agent’s treasury |
leash_pay_skills_endpoints | Fetch endpoint list for a pay-skills provider |
leash_create_payment_link | Create a new payable link for your own endpoints |
leash_receipts | List receipts for the agent |
leash_get_receipt | Look up a single receipt by ID |
leash_check_balances | Check treasury USDC / token balances |
leash_withdraw_treasury | Withdraw funds from the treasury |
leash_get_identity | Resolve the on-chain identity for an agent |
leash_resolve_identity | Resolve a public identity by mint, handle, or domain |
leash_verify_identity | Verify an identity selector, or request an allow/warn/deny decision |
leash_register_agent | Register a new agent on-chain |
leash_set_spend_limit | Update the agent’s spend delegation limit |
leash_get_spend_limit | Read the current spend limit |
leash_reputation | Fetch reputation scores for a provider |
leash_transaction_history | Paginated on-chain transaction history |
leash_daily_transactions | Daily aggregated transaction stats |
Helpers
The@leashmarket/mcp-core/helpers sub-export provides pure utilities with no
runtime dependencies on MCP or Claude.
probePaymentLink(url)
Sends a probe GET and classifies a 402 response as x402 (payment-required
header) or MPP (problem+json with challengeId). Returns a normalised preview:
protocol:'x402' | 'mpp'network,pay_to,asset,amount_atomic,currency- optional
description; for MPP,challenge_id
fetchDiscover(apiUrl, opts)
Queries the Leash discover endpoint and returns a list of DiscoverItem results.
fetchIdentityProfile(apiUrl, opts) / fetchIdentityVerify(apiUrl, opts)
Resolve or verify a public agent identity by mint, handle, or verified domain.
When you include intent, capability, or thresholds, fetchIdentityVerify
uses POST /v1/identity/verify and returns the same allow/warn/deny decision
shape as the public API.
Adapters built on this package
| Package | Runtime |
|---|---|
@leashmarket/mcp | MCP stdio / SSE server (Claude Desktop, Cursor, …) |
@leashmarket/cli | leash CLI — uses MCP tools directly in your terminal |
