x402-bazaar 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +100 -0
- package/bin/cli.js +62 -0
- package/package.json +49 -0
- package/src/commands/config.js +137 -0
- package/src/commands/init.js +778 -0
- package/src/commands/status.js +63 -0
- package/src/detectors/environment.js +121 -0
- package/src/generators/env-file.js +32 -0
- package/src/generators/mcp-config.js +95 -0
- package/src/utils/logger.js +58 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 x402 Bazaar
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# x402-bazaar
|
|
2
|
+
|
|
3
|
+
> Connect your AI agent to the x402 Bazaar marketplace in one command.
|
|
4
|
+
|
|
5
|
+
x402 Bazaar is an autonomous marketplace where AI agents buy and sell API services using the HTTP 402 protocol with USDC payments on Base L2.
|
|
6
|
+
|
|
7
|
+
## Quick Start
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx x402-bazaar init
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
This single command will:
|
|
14
|
+
|
|
15
|
+
1. **Detect your environment** (Claude Desktop, Cursor, VS Code, Claude Code)
|
|
16
|
+
2. **Install the MCP server** and its dependencies
|
|
17
|
+
3. **Configure your wallet** (Coinbase API keys or read-only mode)
|
|
18
|
+
4. **Generate the config** and write it to the correct location
|
|
19
|
+
5. **Verify the connection** to the live marketplace
|
|
20
|
+
|
|
21
|
+
## Commands
|
|
22
|
+
|
|
23
|
+
### `npx x402-bazaar init`
|
|
24
|
+
|
|
25
|
+
Full interactive setup. Detects your AI client, installs the MCP server, configures payments, and verifies the connection.
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# Force a specific environment
|
|
29
|
+
npx x402-bazaar init --env claude-desktop
|
|
30
|
+
|
|
31
|
+
# Skip wallet setup (read-only browsing)
|
|
32
|
+
npx x402-bazaar init --no-wallet
|
|
33
|
+
|
|
34
|
+
# Use a custom server URL
|
|
35
|
+
npx x402-bazaar init --server-url https://your-server.com
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### `npx x402-bazaar config`
|
|
39
|
+
|
|
40
|
+
Generate an MCP configuration file interactively.
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# Generate and save to a file
|
|
44
|
+
npx x402-bazaar config --output mcp-config.json
|
|
45
|
+
|
|
46
|
+
# Force environment
|
|
47
|
+
npx x402-bazaar config --env cursor
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### `npx x402-bazaar status`
|
|
51
|
+
|
|
52
|
+
Check if the marketplace server is online and display stats.
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
npx x402-bazaar status
|
|
56
|
+
npx x402-bazaar status --server-url https://your-server.com
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Supported Environments
|
|
60
|
+
|
|
61
|
+
| Environment | Config Location |
|
|
62
|
+
|-------------|----------------|
|
|
63
|
+
| Claude Desktop | `%APPDATA%/Claude/claude_desktop_config.json` (Windows) |
|
|
64
|
+
| Claude Desktop | `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) |
|
|
65
|
+
| Cursor | `~/.cursor/mcp.json` |
|
|
66
|
+
| VS Code + Continue | `~/.continue/config.json` |
|
|
67
|
+
| Claude Code | `~/.claude.json` |
|
|
68
|
+
|
|
69
|
+
## What is x402 Bazaar?
|
|
70
|
+
|
|
71
|
+
x402 Bazaar is a marketplace where AI agents autonomously trade API services:
|
|
72
|
+
|
|
73
|
+
- **Agents pay with USDC** on Base L2 (Coinbase's Layer 2)
|
|
74
|
+
- **HTTP 402 protocol** — the server responds with payment details, the agent pays, then retries
|
|
75
|
+
- **Every payment is verifiable** on-chain via BaseScan
|
|
76
|
+
- **70+ services** available (search, AI, crypto, weather, and more)
|
|
77
|
+
|
|
78
|
+
### Pricing
|
|
79
|
+
|
|
80
|
+
| Action | Cost |
|
|
81
|
+
|--------|------|
|
|
82
|
+
| Browse marketplace info | Free |
|
|
83
|
+
| Search services | 0.05 USDC |
|
|
84
|
+
| List all services | 0.05 USDC |
|
|
85
|
+
| Register a new service | 1.00 USDC |
|
|
86
|
+
|
|
87
|
+
## Requirements
|
|
88
|
+
|
|
89
|
+
- Node.js >= 18
|
|
90
|
+
- npm or npx
|
|
91
|
+
|
|
92
|
+
## Links
|
|
93
|
+
|
|
94
|
+
- Website: https://x402bazaar.org
|
|
95
|
+
- Dashboard: https://x402-api.onrender.com/dashboard
|
|
96
|
+
- GitHub: https://github.com/Wintyx57
|
|
97
|
+
|
|
98
|
+
## License
|
|
99
|
+
|
|
100
|
+
MIT
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
import { initCommand } from '../src/commands/init.js';
|
|
5
|
+
import { configCommand } from '../src/commands/config.js';
|
|
6
|
+
import { statusCommand } from '../src/commands/status.js';
|
|
7
|
+
import chalk from 'chalk';
|
|
8
|
+
|
|
9
|
+
// Global error handler
|
|
10
|
+
process.on('unhandledRejection', (err) => {
|
|
11
|
+
console.error('');
|
|
12
|
+
console.error(chalk.red('Error: ' + (err.message || err)));
|
|
13
|
+
if (err.code === 'ERR_MODULE_NOT_FOUND') {
|
|
14
|
+
console.error(chalk.dim(' Run: npm install'));
|
|
15
|
+
}
|
|
16
|
+
process.exit(1);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const program = new Command();
|
|
20
|
+
|
|
21
|
+
program
|
|
22
|
+
.name('x402-bazaar')
|
|
23
|
+
.description(chalk.hex('#FF9900')('x402 Bazaar') + ' — Connect your AI agent to the marketplace in one command')
|
|
24
|
+
.version('1.0.0');
|
|
25
|
+
|
|
26
|
+
program
|
|
27
|
+
.command('init')
|
|
28
|
+
.description('Set up x402 Bazaar MCP server (detect environment, configure wallet, generate config)')
|
|
29
|
+
.option('--env <environment>', 'Force environment (claude-desktop, cursor, claude-code, vscode-continue, generic)')
|
|
30
|
+
.option('--no-wallet', 'Skip wallet configuration (read-only mode)')
|
|
31
|
+
.option('--server-url <url>', 'Custom server URL', 'https://x402-api.onrender.com')
|
|
32
|
+
.action(initCommand);
|
|
33
|
+
|
|
34
|
+
program
|
|
35
|
+
.command('config')
|
|
36
|
+
.description('Generate MCP configuration file for your environment')
|
|
37
|
+
.option('--env <environment>', 'Target environment (claude-desktop, cursor, claude-code, vscode-continue, generic)')
|
|
38
|
+
.option('--output <path>', 'Output file path')
|
|
39
|
+
.action(configCommand);
|
|
40
|
+
|
|
41
|
+
program
|
|
42
|
+
.command('status')
|
|
43
|
+
.description('Check connection to x402 Bazaar marketplace')
|
|
44
|
+
.option('--server-url <url>', 'Server URL to check', 'https://x402-api.onrender.com')
|
|
45
|
+
.action(statusCommand);
|
|
46
|
+
|
|
47
|
+
// Default: show help if no command given
|
|
48
|
+
if (process.argv.length <= 2) {
|
|
49
|
+
console.log('');
|
|
50
|
+
console.log(chalk.hex('#FF9900').bold(' x402 Bazaar') + chalk.dim(' — AI Agent Marketplace CLI'));
|
|
51
|
+
console.log('');
|
|
52
|
+
console.log(' Quick start:');
|
|
53
|
+
console.log(chalk.cyan(' npx x402-bazaar init') + chalk.dim(' Full interactive setup'));
|
|
54
|
+
console.log(chalk.cyan(' npx x402-bazaar status') + chalk.dim(' Check server connection'));
|
|
55
|
+
console.log(chalk.cyan(' npx x402-bazaar config') + chalk.dim(' Generate MCP config'));
|
|
56
|
+
console.log('');
|
|
57
|
+
console.log(chalk.dim(' Run with --help for all options'));
|
|
58
|
+
console.log('');
|
|
59
|
+
process.exit(0);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
program.parse();
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "x402-bazaar",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "CLI to set up x402 Bazaar MCP server for AI agents. One command to connect your agent to the marketplace.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "bin/cli.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"x402-bazaar": "./bin/cli.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"bin/",
|
|
12
|
+
"src/",
|
|
13
|
+
"README.md",
|
|
14
|
+
"LICENSE"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"start": "node bin/cli.js",
|
|
18
|
+
"test": "node bin/cli.js --help"
|
|
19
|
+
},
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=18.0.0"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"x402",
|
|
25
|
+
"mcp",
|
|
26
|
+
"ai-agents",
|
|
27
|
+
"marketplace",
|
|
28
|
+
"crypto",
|
|
29
|
+
"usdc",
|
|
30
|
+
"base",
|
|
31
|
+
"coinbase",
|
|
32
|
+
"claude",
|
|
33
|
+
"cursor",
|
|
34
|
+
"model-context-protocol"
|
|
35
|
+
],
|
|
36
|
+
"author": "x402 Bazaar",
|
|
37
|
+
"license": "MIT",
|
|
38
|
+
"homepage": "https://x402bazaar.org",
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "https://github.com/Wintyx57/x402-bazaar-cli"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"chalk": "^5.3.0",
|
|
45
|
+
"commander": "^12.1.0",
|
|
46
|
+
"inquirer": "^9.3.0",
|
|
47
|
+
"ora": "^8.0.1"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import inquirer from 'inquirer';
|
|
2
|
+
import { writeFileSync, existsSync, readFileSync } from 'fs';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { log } from '../utils/logger.js';
|
|
5
|
+
import { detectEnvironment, getDefaultInstallDir } from '../detectors/environment.js';
|
|
6
|
+
import { generateMcpConfig } from '../generators/mcp-config.js';
|
|
7
|
+
|
|
8
|
+
export async function configCommand(options) {
|
|
9
|
+
log.banner();
|
|
10
|
+
log.info('MCP Configuration Generator');
|
|
11
|
+
log.separator();
|
|
12
|
+
|
|
13
|
+
// Detect or ask for environment
|
|
14
|
+
let targetEnv = options.env;
|
|
15
|
+
|
|
16
|
+
if (!targetEnv) {
|
|
17
|
+
const environments = detectEnvironment();
|
|
18
|
+
const detected = environments.filter(e => e.detected);
|
|
19
|
+
|
|
20
|
+
const choices = [
|
|
21
|
+
...environments.map(e => ({
|
|
22
|
+
name: `${e.label}${e.detected ? chalk.hex('#34D399')(' (detected)') : ''}`,
|
|
23
|
+
value: e.name,
|
|
24
|
+
})),
|
|
25
|
+
{ name: 'Generic (print JSON to stdout)', value: 'generic' },
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
const { env } = await inquirer.prompt([
|
|
29
|
+
{
|
|
30
|
+
type: 'list',
|
|
31
|
+
name: 'env',
|
|
32
|
+
message: 'Which environment do you want to configure?',
|
|
33
|
+
choices,
|
|
34
|
+
default: detected.length > 0 ? detected[0].name : 'claude-desktop',
|
|
35
|
+
},
|
|
36
|
+
]);
|
|
37
|
+
targetEnv = env;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Ask for config values
|
|
41
|
+
const { serverUrl, maxBudget, network } = await inquirer.prompt([
|
|
42
|
+
{
|
|
43
|
+
type: 'input',
|
|
44
|
+
name: 'serverUrl',
|
|
45
|
+
message: 'x402 Bazaar server URL:',
|
|
46
|
+
default: 'https://x402-api.onrender.com',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
type: 'input',
|
|
50
|
+
name: 'maxBudget',
|
|
51
|
+
message: 'Max USDC budget per session:',
|
|
52
|
+
default: '1.00',
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
type: 'list',
|
|
56
|
+
name: 'network',
|
|
57
|
+
message: 'Network:',
|
|
58
|
+
choices: [
|
|
59
|
+
{ name: 'Base Mainnet (real USDC)', value: 'mainnet' },
|
|
60
|
+
{ name: 'Base Sepolia (testnet)', value: 'testnet' },
|
|
61
|
+
],
|
|
62
|
+
default: 'mainnet',
|
|
63
|
+
},
|
|
64
|
+
]);
|
|
65
|
+
|
|
66
|
+
// Ask for wallet config
|
|
67
|
+
const { walletMode } = await inquirer.prompt([
|
|
68
|
+
{
|
|
69
|
+
type: 'list',
|
|
70
|
+
name: 'walletMode',
|
|
71
|
+
message: 'Wallet configuration:',
|
|
72
|
+
choices: [
|
|
73
|
+
{ name: 'I have Coinbase API keys', value: 'existing' },
|
|
74
|
+
{ name: 'Read-only mode (browse only, no payments)', value: 'readonly' },
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
]);
|
|
78
|
+
|
|
79
|
+
let coinbaseApiKey = '';
|
|
80
|
+
let coinbaseApiSecret = '';
|
|
81
|
+
|
|
82
|
+
if (walletMode === 'existing') {
|
|
83
|
+
const walletAnswers = await inquirer.prompt([
|
|
84
|
+
{
|
|
85
|
+
type: 'input',
|
|
86
|
+
name: 'coinbaseApiKey',
|
|
87
|
+
message: 'Coinbase API Key:',
|
|
88
|
+
validate: (v) => v.length > 0 || 'API key is required',
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
type: 'password',
|
|
92
|
+
name: 'coinbaseApiSecret',
|
|
93
|
+
message: 'Coinbase API Secret:',
|
|
94
|
+
mask: '*',
|
|
95
|
+
validate: (v) => v.length > 0 || 'API secret is required',
|
|
96
|
+
},
|
|
97
|
+
]);
|
|
98
|
+
coinbaseApiKey = walletAnswers.coinbaseApiKey;
|
|
99
|
+
coinbaseApiSecret = walletAnswers.coinbaseApiSecret;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const installDir = getDefaultInstallDir();
|
|
103
|
+
|
|
104
|
+
// Generate config
|
|
105
|
+
const config = generateMcpConfig({
|
|
106
|
+
environment: targetEnv,
|
|
107
|
+
installDir,
|
|
108
|
+
serverUrl,
|
|
109
|
+
maxBudget,
|
|
110
|
+
network,
|
|
111
|
+
coinbaseApiKey,
|
|
112
|
+
coinbaseApiSecret,
|
|
113
|
+
readOnly: walletMode === 'readonly',
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
log.separator();
|
|
117
|
+
log.success('Generated configuration:');
|
|
118
|
+
console.log('');
|
|
119
|
+
console.log(JSON.stringify(config, null, 2));
|
|
120
|
+
console.log('');
|
|
121
|
+
|
|
122
|
+
// Output
|
|
123
|
+
const outputPath = options.output;
|
|
124
|
+
|
|
125
|
+
if (outputPath) {
|
|
126
|
+
writeFileSync(outputPath, JSON.stringify(config, null, 2));
|
|
127
|
+
log.success(`Config written to ${outputPath}`);
|
|
128
|
+
} else {
|
|
129
|
+
const environments = detectEnvironment();
|
|
130
|
+
const envInfo = environments.find(e => e.name === targetEnv);
|
|
131
|
+
if (envInfo) {
|
|
132
|
+
log.info(`To apply, paste this into: ${chalk.bold(envInfo.configPath)}`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
console.log('');
|
|
137
|
+
}
|