Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .amazonq/rules/nevermined-payments.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Provide correct patterns for integrating Nevermined payment infrastructure into
## Instructions

- **TypeScript SDK**: `@nevermined-io/payments` on npm
- **Python SDK**: `payments-py` on PyPI (with extras: `payments-py[fastapi]`, `payments-py[strands]`)
- **Python SDK**: `payments-py` on PyPI (with extras: `payments-py[mcp]`, `payments-py[fastapi]`, `payments-py[strands]`)
- Always use environment variables: `NVM_API_KEY`, `NVM_ENVIRONMENT`, `NVM_PLAN_ID`, `NVM_AGENT_ID`
- Use `verifyPermissions` / `settlePermissions` for x402 (not the deprecated `isValidRequest`)
- Use `buildPaymentRequired()` (TS) or `build_payment_required()` (Python) for 402 responses
Expand Down
2 changes: 1 addition & 1 deletion .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This repository contains documentation for Nevermined, an AI payment infrastruct
## SDK Packages

- **TypeScript**: `@nevermined-io/payments` on npm
- **Python**: `payments-py` on PyPI (with extras: `payments-py[fastapi]`, `payments-py[strands]`)
- **Python**: `payments-py` on PyPI (with extras: `payments-py[mcp]`, `payments-py[fastapi]`, `payments-py[strands]`)

## Required Environment Variables

Expand Down
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This repository contains documentation for Nevermined, an AI payment infrastruct
## SDK Packages

- **TypeScript**: `@nevermined-io/payments` on npm
- **Python**: `payments-py` on PyPI (extras: `payments-py[fastapi]`, `payments-py[strands]`)
- **Python**: `payments-py` on PyPI (extras: `payments-py[mcp]`, `payments-py[fastapi]`, `payments-py[strands]`)

## Required Environment Variables

Expand Down
2 changes: 1 addition & 1 deletion docs/integrations/agent-integration.mdx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
title: "AI Agents integration"
description: "Learn how to integrate Nevermined Payments Library with your AI agents."

Check warning on line 3 in docs/integrations/agent-integration.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrations/agent-integration.mdx#L3

Did you really mean 'Nevermined'?
icon: "laptop"
---

Integrating Nevermined Payments Library with your existing AI Agents is a straightforward process that can be accomplished with just a few steps.

Check warning on line 7 in docs/integrations/agent-integration.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrations/agent-integration.mdx#L7

Did you really mean 'Nevermined'?

<Note>
In this page we are going to describe the whole process, but if you have any
Expand All @@ -15,11 +15,11 @@

In this tutorial we are going to use a client application sending requests to an AI Agent (Weather MCP server). This MCP server will be only accessible by users who purchased the access to it.

During the tutorial we are going to see how the client application can be connected to Nevermined, how a user can purchase access to the MCP server, and how the requests can be sent to it. Finally we will see how the MCP server can authorize user requests processing only the prompts sent by subscribed users.

Check warning on line 18 in docs/integrations/agent-integration.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrations/agent-integration.mdx#L18

Did you really mean 'Nevermined'?

### 1. Generate the NVM API Keys

Creating a new Nevermined API Key is a simple process that can be done via the [Nevermined App](https://nevermined.app):

Check warning on line 22 in docs/integrations/agent-integration.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrations/agent-integration.mdx#L22

Did you really mean 'Nevermined'?

<Note>
Do this process two times — you will need one API Key for the client
Expand Down Expand Up @@ -47,10 +47,10 @@

<Tabs>
<Tab title="TypeScript">```bash yarn add @nevermined-io/payments ```</Tab>
<Tab title="Python">```bash pip install -e payments-py ```</Tab>
<Tab title="Python">```bash pip install payments-py ```</Tab>
</Tabs>

And later we are going to configure the Payments Library and connect to Nevermined. We are going to use here **the first of the API Keys** generated in the previous step.

Check warning on line 53 in docs/integrations/agent-integration.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrations/agent-integration.mdx#L53

Did you really mean 'Nevermined'?

<Tabs>
<Tab title="TypeScript">
Expand All @@ -60,7 +60,7 @@
const payments = Payments.getInstance({
nvmApiKey: process.env.NVM_API_KEY,
environment: 'sandbox'
})

Check warning on line 63 in docs/integrations/agent-integration.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrations/agent-integration.mdx#L63

Did you really mean 'payments_py'?
```
</Tab>
<Tab title="Python">
Expand All @@ -86,7 +86,7 @@

### 4. Purchase Access to the MCP Server

Once the client application is set up, the next step is to allow users to purchase access to the MCP server. This can be done using the Nevermined App or the Payments Library.

Check warning on line 89 in docs/integrations/agent-integration.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrations/agent-integration.mdx#L89

Did you really mean 'Nevermined'?

### 5. Configure the AI Agent to validate client requests

Expand Down
6 changes: 2 additions & 4 deletions docs/integrations/mcp.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "Model Context Protocol (MCP)"
description: "Learn how to protect your MCP servers with Nevermined Payments Library."

Check warning on line 3 in docs/integrations/mcp.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrations/mcp.mdx#L3

Did you really mean 'Nevermined'?

icon: "laptop"
---
Expand All @@ -11,9 +11,9 @@
If you are using an AI assistant for development, this page provides comprehensive context to streamline the integration process. Simply share this documentation URL with your LLM or copy the page content as a knowledge base.
</Note>

Nevermined Payments Library provides robust tools to add a paywall to your [Model Context Protocol (MCP)](https://spec.modelcontextprotocol.io/) server. This allows you to monetize your AI tools, resources, and prompts by restricting access to subscribers with valid payment plans.

Check warning on line 14 in docs/integrations/mcp.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrations/mcp.mdx#L14

Did you really mean 'Nevermined'?

The integration is designed to be seamless, whether you are using a high-level framework like the official MCP SDKs or a custom low-level JSON-RPC router.

Check warning on line 16 in docs/integrations/mcp.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrations/mcp.mdx#L16

Did you really mean 'SDKs'?

- **Paywall Protection**: Wrap your handlers with `withPaywall` to automatically verify payment tokens and check for valid subscriptions.
- **Credit Burning**: Automatically burn credits after a successful API call, with support for both fixed and dynamic costs.
Expand All @@ -22,7 +22,7 @@

## What is MCP?

As Large Language Models (LLMs) and AI agents become more sophisticated, their greatest limitation is their isolation. By default, they lack access to real-time information, private data sources, or the ability to perform actions in the outside world. The Model Context Protocol (MCP) was designed to solve this problem by creating a standardized communication layer for AI.

Check warning on line 25 in docs/integrations/mcp.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrations/mcp.mdx#L25

Did you really mean 'LLMs'?

Think of MCP as a universal language that allows any AI agent to ask a server, "What can you do?" and "How can I use your capabilities?". It turns a closed-off model into an agent that can interact with the world through a secure and discoverable interface. An MCP server essentially publishes a "menu" of its services, which can include:

Expand All @@ -30,17 +30,17 @@
* **Resources**: These are stable pointers to data, identified by a URI. While a tool call might give a human-readable summary, a resource link (`weather://today/Paris`) provides the raw, structured data (like a JSON object) that an agent can parse and use for further tasks.
* **Prompts**: These are pre-defined templates that help guide an agent's behavior, ensuring it requests information in the correct format or follows a specific interaction pattern.

## Why integrate MCP with Nevermined Payments Library?

Check warning on line 33 in docs/integrations/mcp.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrations/mcp.mdx#L33

Did you really mean 'Nevermined'?

While MCP provides a powerful standard for *what* an AI agent can do, it doesn't specify *who* is allowed to do it or *how* those services are paid for. This is where Nevermined Payments Library comes in. By integrating Nevermined, you can transform your open MCP server into a secure, monetizable platform.

Check warning on line 35 in docs/integrations/mcp.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrations/mcp.mdx#L35

Did you really mean 'Nevermined'?

Check warning on line 35 in docs/integrations/mcp.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrations/mcp.mdx#L35

Did you really mean 'Nevermined'?

Check warning on line 35 in docs/integrations/mcp.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrations/mcp.mdx#L35

Did you really mean 'monetizable'?

The core idea is to place a "paywall" in front of your MCP handlers. This paywall acts as a gatekeeper, intercepting every incoming request to a tool, resource, or prompt. Before executing your logic, it checks the user's payment token to verify they have a valid subscription and sufficient credits through the Nevermined protocol. If they don't, the request is blocked. If they do, the request proceeds, and after your handler successfully completes, the paywall automatically deducts the configured number of credits.

Check warning on line 37 in docs/integrations/mcp.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrations/mcp.mdx#L37

Did you really mean 'Nevermined'?

This integration allows you to build a sustainable business model around your AI services. You can offer different subscription tiers (plans), charge dynamically based on usage, and maintain a complete audit trail of every transaction, all without cluttering your core application logic with complex payment code.

## OAuth 2.1 Support for Remote MCP Servers

Nevermined Payments Library implements **complete OAuth 2.1 authentication** for MCP servers, acting as both:

Check warning on line 43 in docs/integrations/mcp.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrations/mcp.mdx#L43

Did you really mean 'Nevermined'?
- **OAuth Authorization Server** (RFC 8414)
- **OAuth Protected Resource Server** (RFC 8414)
- **OpenID Connect Provider** (OIDC Discovery 1.0)
Expand All @@ -49,7 +49,7 @@

## Simplified API: Complete MCP Server in Minutes

The Nevermined Payments Library provides a high-level API that handles everything for you:

Check warning on line 52 in docs/integrations/mcp.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrations/mcp.mdx#L52

Did you really mean 'Nevermined'?
- ✅ MCP Server creation
- ✅ Express.js setup with CORS
- ✅ OAuth 2.1 endpoints (auto-generated)
Expand Down Expand Up @@ -131,9 +131,9 @@

**That's it!** Your MCP server is now:
- ✅ Running with OAuth 2.1 authentication
- ✅ Protected by Nevermined paywall

Check warning on line 134 in docs/integrations/mcp.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrations/mcp.mdx#L134

Did you really mean 'Nevermined'?
- ✅ Compatible with Claude Desktop and any MCP client
- ✅ Monetizable with automatic credit deduction

Check warning on line 136 in docs/integrations/mcp.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrations/mcp.mdx#L136

Did you really mean 'Monetizable'?

### What `payments.mcp.start()` Does for You

Expand Down Expand Up @@ -271,12 +271,10 @@
</Tab>
<Tab title="Python">
- Python >= 3.10
- FastMCP (`mcp` package) + Uvicorn
- `payments-py` (Nevermined SDK)
- `payments-py[mcp]` (includes MCP SDK, Uvicorn, and Nevermined SDK)

```bash
pip install mcp uvicorn python-dotenv
pip install -e payments-py
pip install payments-py[mcp] python-dotenv
```
</Tab>
</Tabs>
Expand Down Expand Up @@ -499,7 +497,7 @@

### 4) Connecting MCP Clients

Once your server is running with `payments.mcp.start()`, connecting clients is straightforward. **Nevermined handles OAuth authentication automatically** - clients just need to know the server URL.

Check warning on line 500 in docs/integrations/mcp.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrations/mcp.mdx#L500

Did you really mean 'Nevermined'?

#### Claude Desktop

Expand Down Expand Up @@ -697,7 +695,7 @@
| Error Code | Description |
|------------|-------------|
| `-32003` | Payment Required - No token / Invalid token / Insufficient credits |
| `-32002` | Misconfiguration - Server setup error |

Check warning on line 698 in docs/integrations/mcp.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrations/mcp.mdx#L698

Did you really mean 'Misconfiguration'?
| `-32603` | Internal Error - Handler execution failed |

---
Expand Down