httpcat-cli 0.0.7 → 0.0.10

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/README.md CHANGED
@@ -8,6 +8,7 @@ httpcat is a full-featured CLI tool that provides both interactive (with ASCII a
8
8
 
9
9
  - šŸŽØ **Interactive Shell** - Beautiful REPL with ASCII art cats and colored output
10
10
  - šŸ¤– **Headless Mode** - JSON output for scripting and LLM/agent integration
11
+ - šŸ”Œ **MCP Server** - Built-in Model Context Protocol server for AI assistant integration
11
12
  - šŸ’³ **x402 Payments** - Automatic payment handling via x402 protocol
12
13
  - šŸ” **Secure Config** - Local configuration storage in `~/.config/httpcat`
13
14
  - 🌐 **Multi-Network** - Support for Base Sepolia (testnet) and Base (mainnet)
@@ -73,20 +74,21 @@ $ httpcat
73
74
  > ^ < Your agent for token operations
74
75
 
75
76
  šŸ”— Connected to: base-sepolia
76
- 🌐 Agent: https://agent.httpcat.fun
77
+ 🌐 Agent: https://agent.402.cat
77
78
 
78
79
  httpcat> help
79
80
  Available Commands:
80
81
 
81
82
  create <name> <symbol> Create a new token
82
- buy <tokenId> <amount> Buy tokens ($0.05, $0.10, or $0.20)
83
- sell <tokenId> <amount|all> Sell tokens
84
- info <tokenId> Get token information
83
+ buy <id|name|symbol> <amount> Buy tokens ($0.05, $0.10, or $0.20)
84
+ sell <id|name|symbol> <amount|all> Sell tokens
85
+ info <id|name|symbol> Get token information
85
86
  list [--sort mcap|created] List all tokens
87
+ chat [token] Start streaming chat (optional: token symbol/name/address)
86
88
  balance Check wallet balance (ETH and USDC)
87
89
  health Check agent health
88
90
  config [--show|--set|--reset] Manage configuration
89
- network <name> Switch network
91
+ network Show current network
90
92
  help Show this help message
91
93
  exit Exit the shell
92
94
 
@@ -321,6 +323,37 @@ httpcat health
321
323
 
322
324
  **Cost:** $0.0001 USDC (or 402 response)
323
325
 
326
+ ### Chat
327
+
328
+ Start streaming chat with the httpcat community. Join general chat or token-specific discussions.
329
+
330
+ **Interactive:**
331
+
332
+ ```bash
333
+ httpcat> chat # Join general chat
334
+ httpcat> chat MTK # Join chat for token with symbol "MTK"
335
+ httpcat> chat "My Token" # Join chat for token with name "My Token"
336
+ httpcat> chat 0x1234... # Join chat for token at address
337
+ ```
338
+
339
+ **CLI:**
340
+
341
+ ```bash
342
+ httpcat chat
343
+ httpcat chat MTK
344
+ httpcat chat "My Token"
345
+ httpcat chat 0x1234...
346
+ httpcat --json chat MTK
347
+ ```
348
+
349
+ **Token Identifier:**
350
+
351
+ - Token symbol: `MTK` (case-insensitive)
352
+ - Token name: `"My Token"` (use quotes if it contains spaces)
353
+ - Token address: `0x1234...`
354
+
355
+ **Cost:** $0.01 USDC to join, $0.0001 USDC per message, 10 minute lease
356
+
324
357
  ### Configuration
325
358
 
326
359
  Manage your httpcat configuration.
@@ -341,6 +374,40 @@ httpcat config --show # Show current config (JSON)
341
374
  httpcat config --set network=base # Update a setting
342
375
  ```
343
376
 
377
+ ### MCP Server
378
+
379
+ Start the Model Context Protocol server for AI assistant integration.
380
+
381
+ **CLI:**
382
+
383
+ ```bash
384
+ httpcat mcp-server
385
+ ```
386
+
387
+ **Description:**
388
+
389
+ Starts an MCP server that exposes all httpcat CLI commands as MCP tools. The server communicates via stdio and can be used with MCP clients like Cursor or Claude Desktop.
390
+
391
+ **Configuration:**
392
+
393
+ Add to your MCP client config:
394
+
395
+ ```json
396
+ {
397
+ "mcpServers": {
398
+ "httpcat": {
399
+ "command": "npx",
400
+ "args": ["-y", "httpcat-cli", "mcp-server"],
401
+ "env": {
402
+ "HTTPCAT_PRIVATE_KEY": "0x..." // Optional
403
+ }
404
+ }
405
+ }
406
+ }
407
+ ```
408
+
409
+ See the [MCP Server section](#mcp-server-model-context-protocol) for detailed documentation.
410
+
344
411
  ## Headless Mode (JSON Output)
345
412
 
346
413
  Perfect for scripting, automation, or LLM/agent integration.
@@ -508,7 +575,7 @@ All commands with `--json` flag return structured JSON responses. The output fol
508
575
  {
509
576
  "status": "ok",
510
577
  "timestamp": "2025-11-22T10:30:00.000Z",
511
- "agent": "https://agent.httpcat.fun"
578
+ "agent": "https://agent.402.cat"
512
579
  }
513
580
  ```
514
581
 
@@ -529,7 +596,7 @@ All commands with `--json` flag return structured JSON responses. The output fol
529
596
  ```json
530
597
  {
531
598
  "name": "httpcat-cli",
532
- "version": "0.1.0"
599
+ "version": "0.0.8"
533
600
  }
534
601
  ```
535
602
 
@@ -576,6 +643,231 @@ if (( $(echo "$PNL > 0" | bc -l) )); then
576
643
  fi
577
644
  ```
578
645
 
646
+ ## MCP Server (Model Context Protocol)
647
+
648
+ httpcat includes a built-in MCP server that exposes all CLI commands as MCP tools, enabling seamless integration with AI assistants like Claude (via Claude Desktop) or Cursor.
649
+
650
+ ### Quick Start
651
+
652
+ **Start the MCP server:**
653
+
654
+ ```bash
655
+ httpcat mcp-server
656
+ ```
657
+
658
+ **Or use npx (no installation needed):**
659
+
660
+ ```bash
661
+ npx httpcat-cli mcp-server
662
+ ```
663
+
664
+ ### MCP Client Configuration
665
+
666
+ Add the httpcat MCP server to your MCP client configuration:
667
+
668
+ #### For Cursor
669
+
670
+ Add to your Cursor settings (`.cursor/mcp.json` or settings UI):
671
+
672
+ ```json
673
+ {
674
+ "mcpServers": {
675
+ "httpcat": {
676
+ "command": "npx",
677
+ "args": ["-y", "httpcat-cli", "mcp-server"],
678
+ "env": {
679
+ "HTTPCAT_PRIVATE_KEY": "0x..." // Optional - can also pass via tool params
680
+ }
681
+ }
682
+ }
683
+ }
684
+ ```
685
+
686
+ #### For Claude Desktop
687
+
688
+ Add to your Claude Desktop config (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS):
689
+
690
+ ```json
691
+ {
692
+ "mcpServers": {
693
+ "httpcat": {
694
+ "command": "npx",
695
+ "args": ["-y", "httpcat-cli", "mcp-server"],
696
+ "env": {
697
+ "HTTPCAT_PRIVATE_KEY": "0x..."
698
+ }
699
+ }
700
+ }
701
+ }
702
+ ```
703
+
704
+ #### Using Global Install
705
+
706
+ If you've installed httpcat globally:
707
+
708
+ ```json
709
+ {
710
+ "mcpServers": {
711
+ "httpcat": {
712
+ "command": "httpcat",
713
+ "args": ["mcp-server"],
714
+ "env": {
715
+ "HTTPCAT_PRIVATE_KEY": "0x..."
716
+ }
717
+ }
718
+ }
719
+ }
720
+ ```
721
+
722
+ ### Available MCP Tools
723
+
724
+ The MCP server exposes the following tools:
725
+
726
+ #### `create_token`
727
+
728
+ Create a new token on the bonding curve.
729
+
730
+ **Parameters:**
731
+
732
+ - `name` (string, required) - Token name (e.g., "My Token")
733
+ - `symbol` (string, required) - Token symbol/ticker (3-10 characters)
734
+ - `photoUrl` (string, optional) - Photo URL for token logo
735
+ - `bannerUrl` (string, optional) - Banner image URL
736
+ - `websiteUrl` (string, optional) - Website URL
737
+ - `privateKey` (string, optional) - Private key (overrides config/env)
738
+
739
+ **Cost:** $0.01 USDC
740
+
741
+ #### `buy_token`
742
+
743
+ Buy tokens from the bonding curve.
744
+
745
+ **Parameters:**
746
+
747
+ - `identifier` (string, required) - Token ID (UUID), name, or symbol
748
+ - `amount` (string, required) - Amount: "0.05", "0.10", or "0.20" (testnet) | "50", "100", or "200" (mainnet)
749
+ - `privateKey` (string, optional) - Private key (overrides config/env)
750
+
751
+ **Cost:** Amount + 1% fee
752
+
753
+ #### `sell_token`
754
+
755
+ Sell tokens back to the bonding curve.
756
+
757
+ **Parameters:**
758
+
759
+ - `identifier` (string, required) - Token ID (UUID), name, or symbol
760
+ - `amount` (string, required) - Amount: number (e.g., "1000"), percentage (e.g., "50%"), or "all"
761
+ - `privateKey` (string, optional) - Private key (overrides config/env)
762
+
763
+ **Cost:** 1% fee deducted from proceeds
764
+
765
+ #### `token_info`
766
+
767
+ Get detailed information about a token.
768
+
769
+ **Parameters:**
770
+
771
+ - `identifier` (string, required) - Token ID (UUID), name, or symbol
772
+ - `privateKey` (string, optional) - Private key (overrides config/env)
773
+
774
+ **Returns:** Token details, price, market cap, graduation progress, and your position (if you own tokens)
775
+
776
+ **Cost:** $0.0001 USDC
777
+
778
+ #### `list_tokens`
779
+
780
+ List all tokens with pagination and sorting.
781
+
782
+ **Parameters:**
783
+
784
+ - `page` (number, optional) - Page number (default: 1)
785
+ - `limit` (number, optional) - Items per page (default: 20, max: 100)
786
+ - `sort` (string, optional) - Sort by: "mcap", "created", or "name" (default: "mcap")
787
+ - `privateKey` (string, optional) - Private key (overrides config/env)
788
+
789
+ **Cost:** $0.0001 USDC
790
+
791
+ #### `check_balance`
792
+
793
+ Check wallet balance (ETH and USDC).
794
+
795
+ **Parameters:**
796
+
797
+ - `privateKey` (string, optional) - Private key (overrides config/env)
798
+
799
+ **Cost:** Free (no payment required)
800
+
801
+ #### `health_check`
802
+
803
+ Check if the httpcat agent is running and healthy.
804
+
805
+ **Parameters:**
806
+
807
+ - `privateKey` (string, optional) - Private key (overrides config/env)
808
+
809
+ **Cost:** $0.0001 USDC
810
+
811
+ ### Private Key Configuration
812
+
813
+ Private keys can be configured in three ways (priority order):
814
+
815
+ 1. **Tool parameter** - Pass `privateKey` in each tool call (highest priority)
816
+ 2. **Environment variable** - Set `HTTPCAT_PRIVATE_KEY` in the MCP client config
817
+ 3. **Config file** - Use `httpcat config` to set up `~/.config/httpcat/config.json`
818
+
819
+ **Security Recommendation:** Use the environment variable in your MCP client config rather than passing it in each tool call.
820
+
821
+ ### Example MCP Tool Usage
822
+
823
+ Once configured, AI assistants can use the tools like this:
824
+
825
+ ```
826
+ create_token(name="Moon Token", symbol="MOON", websiteUrl="https://moon.com")
827
+ buy_token(identifier="abc123-...", amount="0.20")
828
+ token_info(identifier="MOON")
829
+ list_tokens(sort="mcap", limit=10)
830
+ check_balance()
831
+ ```
832
+
833
+ ### Response Format
834
+
835
+ All MCP tools return structured JSON responses matching the CLI's JSON output format:
836
+
837
+ **Success:**
838
+
839
+ ```json
840
+ {
841
+ "success": true,
842
+ "operation": "tool_name",
843
+ "data": {
844
+ // Tool-specific data
845
+ }
846
+ }
847
+ ```
848
+
849
+ **Error:**
850
+
851
+ ```json
852
+ {
853
+ "success": false,
854
+ "operation": "tool_name",
855
+ "error": {
856
+ "message": "Error message",
857
+ "code": 1,
858
+ "details": {}
859
+ }
860
+ }
861
+ ```
862
+
863
+ ### Benefits
864
+
865
+ - **No Shell Access Required** - AI assistants can interact with httpcat without needing shell/terminal access
866
+ - **Structured Responses** - Consistent JSON output format for reliable parsing
867
+ - **Secure** - Private keys can be managed via environment variables or config
868
+ - **Always Up-to-Date** - Using `npx` ensures you always get the latest version
869
+ - **Zero Configuration** - Works out of the box with standard MCP clients
870
+
579
871
  ## Advanced Usage
580
872
 
581
873
  ### Environment Management
@@ -619,7 +911,7 @@ httpcat env use production
619
911
  #### Predefined Environments
620
912
 
621
913
  - **local** - `http://localhost:8787` (base-sepolia)
622
- - **sepolia** - `https://agent.httpcat.fun` (base-sepolia)
914
+ - **sepolia** - `https://agent.402.cat` (base-sepolia)
623
915
 
624
916
  #### Environment Priority
625
917
 
@@ -686,7 +978,7 @@ Config is stored at `~/.config/httpcat/config.json`:
686
978
  {
687
979
  "privateKey": "0x...",
688
980
  "network": "base-sepolia",
689
- "agentUrl": "https://agent.httpcat.fun",
981
+ "agentUrl": "https://agent.402.cat",
690
982
  "facilitatorUrl": "https://facilitators.x402scan.com",
691
983
  "defaultMaxPayment": "10.00",
692
984
  "preferences": {
@@ -859,5 +1151,5 @@ MIT
859
1151
  ## Support
860
1152
 
861
1153
  - Report issues: https://github.com/hathbanger/httpcat-cli/issues
862
- - httpcat agent: https://agent.httpcat.fun
1154
+ - httpcat agent: https://agent.402.cat
863
1155
  - x402 protocol: https://x402.org
@@ -0,0 +1,171 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Automated chat script for httpcat chat --json mode
5
+ *
6
+ * Usage:
7
+ * node chat-automation.js <token> [message1] [message2] ...
8
+ *
9
+ * Or pipe messages:
10
+ * echo -e "Hello\nWorld" | node chat-automation.js <token>
11
+ */
12
+
13
+ import { spawn } from 'child_process';
14
+ import { fileURLToPath } from 'url';
15
+ import { dirname, join } from 'path';
16
+
17
+ const __filename = fileURLToPath(import.meta.url);
18
+ const __dirname = dirname(__filename);
19
+
20
+ const token = process.argv[2];
21
+
22
+ if (!token) {
23
+ console.error('Usage: node chat-automation.js <token> [message1] [message2] ...');
24
+ console.error(' Or: echo -e "msg1\\nmsg2" | node chat-automation.js <token>');
25
+ process.exit(1);
26
+ }
27
+
28
+ // Get messages from command line args or stdin
29
+ const messages = process.argv.slice(3);
30
+
31
+ // Spawn httpcat chat process
32
+ const chatProcess = spawn('httpcat', ['chat', '--json', token], {
33
+ stdio: ['pipe', 'pipe', 'inherit'], // Capture stdout to parse JSON
34
+ shell: true,
35
+ });
36
+
37
+ // Handle JSON output from chat
38
+ let outputBuffer = '';
39
+ chatProcess.stdout.on('data', (data) => {
40
+ outputBuffer += data.toString();
41
+ const lines = outputBuffer.split('\n');
42
+ outputBuffer = lines.pop() || ''; // Keep incomplete line
43
+
44
+ for (const line of lines) {
45
+ if (!line.trim()) continue;
46
+
47
+ try {
48
+ const event = JSON.parse(line);
49
+
50
+ switch (event.type) {
51
+ case 'joined':
52
+ console.error(`āœ… Joined chat. Lease ID: ${event.leaseId}`);
53
+ // Send initial messages if provided
54
+ if (messages.length > 0) {
55
+ setTimeout(() => {
56
+ messages.forEach((msg, index) => {
57
+ setTimeout(() => {
58
+ if (chatProcess.stdin && !chatProcess.stdin.destroyed) {
59
+ chatProcess.stdin.write(msg + '\n');
60
+ }
61
+ }, index * 1000); // 1 second between messages
62
+ });
63
+ }, 2000); // Wait 2 seconds after joining
64
+ }
65
+ break;
66
+
67
+ case 'message':
68
+ const msg = event.data;
69
+ const author = msg.authorShort || msg.author?.slice(0, 6);
70
+ const time = new Date(msg.timestamp).toLocaleTimeString();
71
+ console.error(`[${time}] ${author}: ${msg.message}`);
72
+
73
+ // Auto-respond to messages containing "claude" (case-insensitive)
74
+ // Check if message is from someone else (not our own)
75
+ const isOwn = msg.author?.toLowerCase() === process.env.HTTPCAT_ADDRESS?.toLowerCase();
76
+ if (msg.message.toLowerCase().includes('claude') && !isOwn) {
77
+ setTimeout(() => {
78
+ const response = `Hello! I'm Claude, an AI assistant. How can I help you?`;
79
+ if (chatProcess.stdin && !chatProcess.stdin.destroyed) {
80
+ chatProcess.stdin.write(response + '\n');
81
+ }
82
+ }, 1000);
83
+ }
84
+ break;
85
+
86
+ case 'message_sent':
87
+ console.error(`āœ… Message sent: ${event.messageId}`);
88
+ break;
89
+
90
+ case 'lease_expired':
91
+ console.error('ā±ļø Lease expired. Sending /renew...');
92
+ if (chatProcess.stdin && !chatProcess.stdin.destroyed) {
93
+ chatProcess.stdin.write('/renew\n');
94
+ }
95
+ break;
96
+
97
+ case 'error':
98
+ console.error(`āŒ Error: ${event.error}`);
99
+ break;
100
+
101
+ case 'exiting':
102
+ console.error('šŸ‘‹ Chat session ended');
103
+ process.exit(0);
104
+ break;
105
+ }
106
+ } catch (error) {
107
+ // Not JSON, might be regular output - ignore or log
108
+ if (line.trim() && !line.startsWith('{')) {
109
+ console.error(line);
110
+ }
111
+ }
112
+ }
113
+ });
114
+
115
+ // Send messages from stdin if no command line args
116
+ if (messages.length === 0 && !process.stdin.isTTY) {
117
+ let stdinBuffer = '';
118
+
119
+ process.stdin.setEncoding('utf8');
120
+ process.stdin.on('data', (chunk) => {
121
+ stdinBuffer += chunk.toString();
122
+ const lines = stdinBuffer.split('\n');
123
+ stdinBuffer = lines.pop() || '';
124
+
125
+ for (const line of lines) {
126
+ const trimmed = line.trim();
127
+ if (trimmed) {
128
+ // Wait a bit for chat to be ready, then send
129
+ setTimeout(() => {
130
+ if (chatProcess.stdin && !chatProcess.stdin.destroyed) {
131
+ chatProcess.stdin.write(trimmed + '\n');
132
+ }
133
+ }, 2000);
134
+ }
135
+ }
136
+ });
137
+
138
+ process.stdin.on('end', () => {
139
+ // Keep process alive to receive messages
140
+ // User can Ctrl+C to exit
141
+ });
142
+ } else if (messages.length > 0) {
143
+ // Messages provided via command line - will be sent after joining
144
+ // (handled in the 'joined' event handler above)
145
+ }
146
+
147
+ // Handle process errors
148
+ chatProcess.on('error', (error) => {
149
+ console.error(`āŒ Failed to start chat process: ${error.message}`);
150
+ process.exit(1);
151
+ });
152
+
153
+ chatProcess.on('exit', (code) => {
154
+ if (code !== 0 && code !== null) {
155
+ console.error(`Chat process exited with code ${code}`);
156
+ }
157
+ process.exit(code || 0);
158
+ });
159
+
160
+ // Handle Ctrl+C
161
+ process.on('SIGINT', () => {
162
+ console.error('\nšŸ‘‹ Shutting down...');
163
+ if (chatProcess.stdin && !chatProcess.stdin.destroyed) {
164
+ chatProcess.stdin.write('/exit\n');
165
+ }
166
+ setTimeout(() => {
167
+ chatProcess.kill();
168
+ process.exit(0);
169
+ }, 1000);
170
+ });
171
+
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/commands/chat.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAW7C,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,WAAW,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,SAAS,GAAG,eAAe,GAAG,OAAO,CAAC;IAC5C,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAuDD,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,aAAa,EACrB,eAAe,CAAC,EAAE,MAAM,EACxB,MAAM,GAAE,OAAe,GACtB,OAAO,CAAC,cAAc,CAAC,CA+BzB;AAED,wBAAsB,eAAe,CACnC,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,iBAAiB,CAAC,CAa5B;AAED,wBAAsB,UAAU,CAC9B,MAAM,EAAE,aAAa,EACrB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,oBAAoB,CAAC,CAS/B;AAgND,wBAAsB,eAAe,CACnC,MAAM,EAAE,aAAa,EACrB,QAAQ,GAAE,OAAe,EACzB,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,IAAI,CAAC,CA+zDf;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAQjE"}