402ai-mcp
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@402ai-mcpgenerate an image of a sunset over the ocean"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
402ai-mcp
MCP (Model Context Protocol) server for 402ai.net - a Lightning-paid API proxy. Provides catalog-aware tools with compact/full profiles, bearer-first authentication, and dynamic tool refresh notifications.
Please update me when there are feature changes.
Features
Two Tool Profiles: Compact (optimized for agents) or Full (comprehensive endpoint coverage)
Catalog Synchronization: Auto-fetches and tracks API catalog changes
Bearer Token Auth: First-class support for prepaid balance tokens
Dynamic Tool Updates: Notifies clients when catalog changes via MCP notifications
Smart Consolidation: Compact profile merges overlapping endpoints to reduce tool clutter
TypeScript Native: Full TypeScript implementation with type safety
Comprehensive Testing: Unit tests for catalog validation, deduplication, HTTP handling, and multipart uploads
Related MCP server: opendexter
Quick Start
Installation
npm install
npm run build
npm testRun via stdio
ALBOM_BEARER_TOKEN=<your_token> npm startNPM Package
npm install 402ai-mcpConfiguration
Configure via environment variables:
Variable | Default | Description |
|
| API base URL |
| (none) | Prepaid balance token (strongly recommended) |
| (none) | Client-side NWC connection URI used to auto-pay topup invoices locally |
|
| Trigger auto-topup when API responses report balance below this threshold |
|
| USD amount to add for each automatic topup |
|
| Max USD the MCP client will auto-top up over a rolling 24h window |
|
| Tool profile: |
|
| Include moderation tools |
|
| Include embedding tools |
|
| Include video generation tools |
|
| Expose |
|
| Catalog cache TTL |
|
| HTTP request timeout |
|
| Max retry attempts for failed requests |
|
| Max upload file size |
Tool Profiles
Compact Profile (Default)
Optimized for AI agents with minimal tool ambiguity. Consolidates overlapping endpoints into semantic tools:
Tool | Purpose | Maps to Endpoint |
| Get live API catalog |
|
| Generate text completions |
|
| Generate images |
|
| Edit images |
|
| Transcribe audio (with optional translation) |
|
| Generate speech |
|
| Generate videos (if enabled) |
|
| Content moderation (if enabled) |
|
| Create embeddings (if enabled) |
|
Consolidations:
Hides
/v1/chat/completionsin favor of/v1/responses(identical model sets)Folds
/v1/audio/translationsintoalbom_audio_transcribevia boolean flag
Full Profile
One tool per catalog endpoint for comprehensive coverage:
albom_openai_chat_completionsalbom_openai_responsesalbom_openai_images_generationsalbom_openai_images_editsalbom_openai_images_variationsalbom_openai_audio_speechalbom_openai_audio_transcriptionsalbom_openai_audio_translationsalbom_openai_embeddingsalbom_openai_moderationsalbom_openai_video_generationsalbom_catalog_getalbom_raw_call(ifALBOM_ALLOW_RAW_TOOL=true)
Authentication
Bearer Token (Recommended)
Set ALBOM_BEARER_TOKEN to your prepaid balance token. All requests will use Authorization: Bearer <token>.
Get a token:
# 1. Create topup invoice
curl -X POST https://402ai.net/api/v1/topup \
-H "Content-Type: application/json" \
-d '{"amount_sats":1000}'
# 2. Pay invoice with Lightning wallet, then claim
curl -X POST https://402ai.net/api/v1/topup/claim \
-H "Content-Type: application/json" \
-d '{"preimage":"<hex-preimage>"}'NWC Auto-Topup
Set ALBOM_NWC_URI to a nostr+walletconnect://... URI to let the MCP client auto-pay topup invoices locally. The NWC secret stays in the MCP client process and is never sent to the 402ai server.
When a tool response includes balance_sats or available_sats below ALBOM_NWC_THRESHOLD_SATS, the MCP client will:
POST /api/v1/topupwith{"amount_usd": ALBOM_NWC_TOPUP_USD}Pay the returned invoice over NWC with
pay_invoicePOST /api/v1/topup/claimwith the returned preimageUpdate the in-memory bearer token if the claim returns a newer token
Notes:
Auto-topup is client-side only. The NWC URI never touches the 402ai server.
ALBOM_NWC_MAX_DAILYis a rolling 24-hour USD spend cap for automatic topups.Auto-topup does not bootstrap a brand new account by itself. Start with a valid
ALBOM_BEARER_TOKEN, then NWC can keep that balance funded.
No Token (L402 Flow)
Without a token, calls will return 402 Payment Required with a Lightning invoice. The MCP server will surface this as an error with payment details.
Usage Examples
With Claude Desktop
Add to claude_desktop_config.json:
{
"mcpServers": {
"402ai": {
"command": "node",
"args": ["/path/to/402ai-mcp/dist/server.js"],
"env": {
"ALBOM_BEARER_TOKEN": "abl_your_token_here",
"ALBOM_NWC_URI": "nostr+walletconnect://...",
"ALBOM_NWC_THRESHOLD_SATS": "1000",
"ALBOM_NWC_TOPUP_USD": "2.00",
"ALBOM_NWC_MAX_DAILY": "10.00",
"ALBOM_TOOL_PROFILE": "compact"
}
}
}
}Programmatic Usage
import { createAlbomServer } from '402ai-mcp';
const server = createAlbomServer({
baseUrl: 'https://402ai.net',
bearerToken: process.env.ALBOM_BEARER_TOKEN,
toolProfile: 'compact'
});
// Start server
await server.run();Development
Build
npm run buildDocumentation Discipline
Keep ARCHITECTURE.md and WORKLOG.md accurate when tool behavior, transport assumptions, auth flows, or deployment expectations change.
Test
npm test # Run all tests
npm run test:watch # Watch modeDev Server
npm run dev # Watch and rebuild
npm run start:dev # Run without buildSmoke Test (Live API)
ALBOM_BEARER_TOKEN=<token> npm run smoke:liveArchitecture
Core Modules
catalog.ts: Fetches and validates/api/v1/catalog, detects changesconfig.ts: Environment variable configuration and validationdedup.ts: Model set deduplication logic (Jaccard similarity)httpClient.ts: HTTP client with retry logic, multipart support, bearer authtools/: Tool implementations for compact and full profilesresults.ts: Response normalization and error handlinguploads.ts: File upload handling (path and base64)server.ts: MCP server implementation
Catalog Sync
Fetches
/api/v1/catalogon startupCaches for
ALBOM_CATALOG_TTL_MSPeriodically refreshes and compares
Sends
notifications/tools/list_changedif catalog changesClients re-fetch tool definitions
Error Handling
HTTP errors are normalized to MCP-friendly format:
402 Payment Required: Returns payment details (invoice, amount, expires_in)400 Bad Request: Returns validation errors429 Rate Limited: Returns retry-after info5xx Server Error: Returns error messageNetwork errors: Automatic retry with exponential backoff
Testing
Test suite covers:
Catalog validation and normalization
Model set deduplication (Jaccard similarity)
HTTP error normalization
Multipart upload encoding (path + base64)
Tool list change detection
Bearer token authentication
Retry logic
Run tests:
npm testPublishing
# 1. Build and test
npm run build
npm test
# 2. Check package contents
npm pack --dry-run
# 3. Publish
npm login
npm version patch # or minor/major
npm publish --access publicProject Structure
.
├── src/
│ ├── catalog.ts # Catalog fetching and tracking
│ ├── config.ts # Environment configuration
│ ├── dedup.ts # Model set deduplication
│ ├── httpClient.ts # HTTP client with retries
│ ├── server.ts # MCP server implementation
│ ├── tools/ # Tool implementations
│ │ ├── compact.ts # Compact profile tools
│ │ ├── full.ts # Full profile tools
│ │ └── shared.ts # Shared tool utilities
│ ├── results.ts # Response normalization
│ ├── uploads.ts # File upload handling
│ ├── types.ts # TypeScript types
│ └── index.ts # Public exports
├── test/ # Test suite
├── scripts/ # Utility scripts
├── dist/ # Compiled output
└── 402AI_MCP_IMPLEMENTATION_SPEC.md # Design spec
Documentation:
└── 402AI_MCP_IMPLEMENTATION_SPEC.mdMCP Specification
This server implements MCP spec revision 2025-11-25.
Supported features:
Tools capability
Notifications capability (
tools/list_changed)Tool annotations (
title,readOnlyHint,idempotentHint)stdio transport
License
MIT - See LICENSE file.
Contributing
See WORKLOG.md for recent changes and development history.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
MCP server for AI dialogue using various LLM models via AceDataCloud
MCP server for Hailuo (MiniMax) AI video generation
MCP server for Qwen Image 3 AI image generation
MCP server for Wan AI video generation
Related MCP Servers
- FlicenseNot gradedqualityNot gradedmaintenanceAn MCP server that enables users to generate AI images using the Jimeng AI API with support for automatic status polling and local file saving. It allows for detailed parameter configuration including image dimensions, model selection, and prompt optimization.-

opendexterofficial
AlicenseNot gradedqualityCmaintenanceAn MCP server that enables AI agents to search, pay for, and call paid APIs using the x402 protocol, with automatic USDC settlement.2MIT
AiChat MCP Serverofficial
AlicenseBqualityAmaintenanceAn MCP server for AI dialogue via the AceDataCloud platform, supporting multi-model conversations including GPT-4/5, DeepSeek, Grok, and GLM.4MIT- AlicenseCqualityAmaintenanceAn MCP server that gives AI agents real-time market data, DeFi intelligence, and automatic tool discovery via plugins. Supports x402 micropayments and is always updated.23MIT