atxp-call 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.
@@ -0,0 +1,9 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "WebFetch(domain:docs.atxp.ai)"
5
+ ],
6
+ "deny": [],
7
+ "ask": []
8
+ }
9
+ }
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 DNR
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
+ # atxp-call
2
+
3
+ A command-line tool for calling tools on ATXP MCP servers.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install
9
+ ```
10
+
11
+ ## Configuration
12
+
13
+ Before using `atxp-call`, you need to set up your ATXP connection string:
14
+
15
+ ```bash
16
+ export ATXP_CONNECTION="your-connection-string"
17
+ ```
18
+
19
+ Or create a `.env` file in the project directory:
20
+
21
+ ```
22
+ ATXP_CONNECTION=your-connection-string
23
+ ```
24
+
25
+ You can find your connection string at https://accounts.atxp.ai
26
+
27
+ ## Usage
28
+
29
+ ```bash
30
+ ./atxp-call.js <server> <tool> <arguments_json> [--x402] [--no-parse] [--verbose]
31
+ ```
32
+
33
+ Or if installed globally:
34
+
35
+ ```bash
36
+ atxp-call <server> <tool> <arguments_json> [--x402] [--no-parse] [--verbose]
37
+ ```
38
+
39
+ ### Required Arguments
40
+
41
+ - `server` - The server URL or identifier (https:// is prepended automatically if not present)
42
+ - `tool` - The tool name to invoke
43
+ - `arguments_json` - JSON string containing tool arguments
44
+
45
+ ### Optional Flags
46
+
47
+ - `--x402` - Enable x402 mode
48
+ - `--no-parse` - Return full result object instead of parsed text
49
+ - `--verbose` - Show verbose output from dependencies
50
+
51
+ ## Examples
52
+
53
+ ### ATXP MCP Servers
54
+
55
+ Search X (formerly Twitter) for posts:
56
+
57
+ ```bash
58
+ ./atxp-call.js x-live-search.mcp.atxp.ai x_live_search '{"query": "What are the latest updates from Space X?"}'
59
+ ```
60
+
61
+ Perform web search:
62
+
63
+ ```bash
64
+ ./atxp-call.js search.mcp.atxp.ai search '{"query": "latest AI developments"}'
65
+ ```
66
+
67
+ Crawl a webpage:
68
+
69
+ ```bash
70
+ ./atxp-call.js crawl.mcp.atxp.ai crawl '{"url": "https://example.com"}'
71
+ ```
72
+
73
+ Generate an image:
74
+
75
+ ```bash
76
+ ./atxp-call.js image.mcp.atxp.ai generate_image '{"prompt": "A sunset over mountains", "sync": true}'
77
+ ```
78
+
79
+ Execute code in a sandbox:
80
+
81
+ ```bash
82
+ ./atxp-call.js code.mcp.atxp.ai execute_code '{"language": "python", "code": "print(\"Hello, World!\")"}'
83
+ ```
84
+
85
+ Research a topic:
86
+
87
+ ```bash
88
+ ./atxp-call.js research.mcp.atxp.ai research '{"query": "quantum computing applications", "depth": "quick"}'
89
+ ```
90
+
91
+ See available MCP servers at: https://docs.atxp.ai/client/mcp_servers
92
+
93
+ ## Dependencies
94
+
95
+ - [@atxp/client](https://www.npmjs.com/package/@atxp/client) - ATXP client library
96
+ - [@atxp/x402](https://www.npmjs.com/package/@atxp/x402) - X402 protocol support
97
+
98
+ ## License
99
+
100
+ MIT
package/atxp-call.js ADDED
@@ -0,0 +1,170 @@
1
+ #!/usr/bin/env node
2
+
3
+ // Check for --verbose flag before loading any dependencies
4
+ const isVerbose = process.argv.includes('--verbose');
5
+
6
+ // Save original console and suppress output from dependencies unless --verbose is set
7
+ const originalConsole = {
8
+ log: console.log,
9
+ error: console.error,
10
+ warn: console.warn,
11
+ info: console.info,
12
+ debug: console.debug,
13
+ };
14
+
15
+ if (!isVerbose) {
16
+ const noop = () => {};
17
+ console.log = noop;
18
+ console.error = noop;
19
+ console.warn = noop;
20
+ console.info = noop;
21
+ console.debug = noop;
22
+ }
23
+
24
+ // Load environment variables from .env file if present
25
+ require('dotenv').config();
26
+
27
+ const { atxpClient, ATXPAccount } = require('@atxp/client');
28
+ const { wrapWithX402 } = require('@atxp/x402');
29
+
30
+ function printUsage() {
31
+ originalConsole.error('Usage: atxp-call <server> <tool> <arguments_json> [--x402] [--no-parse] [--verbose]');
32
+ originalConsole.error('');
33
+ originalConsole.error('Required arguments:');
34
+ originalConsole.error(' server - The server URL or identifier');
35
+ originalConsole.error(' tool - The tool name to invoke');
36
+ originalConsole.error(' arguments_json - JSON string containing tool arguments');
37
+ originalConsole.error('');
38
+ originalConsole.error('Optional flags:');
39
+ originalConsole.error(' --x402 - Enable x402 mode');
40
+ originalConsole.error(' --no-parse - Return full result object instead of parsed text');
41
+ originalConsole.error(' --verbose - Show verbose output from dependencies');
42
+ process.exit(1);
43
+ }
44
+
45
+ function parseArgs() {
46
+ const args = process.argv.slice(2);
47
+
48
+ if (args.length < 3) {
49
+ originalConsole.error('Error: Missing required arguments\n');
50
+ printUsage();
51
+ }
52
+
53
+ // Check for --x402 flag
54
+ const x402Index = args.indexOf('--x402');
55
+ const hasX402 = x402Index !== -1;
56
+
57
+ // Remove flag from args if present
58
+ if (hasX402) {
59
+ args.splice(x402Index, 1);
60
+ }
61
+
62
+ // Check for --no-parse flag
63
+ const noParseIndex = args.indexOf('--no-parse');
64
+ const hasNoParse = noParseIndex !== -1;
65
+
66
+ // Remove flag from args if present
67
+ if (hasNoParse) {
68
+ args.splice(noParseIndex, 1);
69
+ }
70
+
71
+ // Check for --verbose flag
72
+ const verboseIndex = args.indexOf('--verbose');
73
+ const hasVerbose = verboseIndex !== -1;
74
+
75
+ // Remove flag from args if present
76
+ if (hasVerbose) {
77
+ args.splice(verboseIndex, 1);
78
+ }
79
+
80
+ if (args.length !== 3) {
81
+ originalConsole.error('Error: Expected exactly 3 positional arguments\n');
82
+ printUsage();
83
+ }
84
+
85
+ let [server, tool, argumentsJson] = args;
86
+
87
+ // Prepend https:// if not already present
88
+ if (!server.startsWith('http://') && !server.startsWith('https://')) {
89
+ server = `https://${server}`;
90
+ }
91
+
92
+ // Validate arguments_json is valid JSON
93
+ let parsedArguments;
94
+ try {
95
+ parsedArguments = JSON.parse(argumentsJson);
96
+ } catch (error) {
97
+ originalConsole.error(`Error: arguments_json must be valid JSON: ${error.message}\n`);
98
+ printUsage();
99
+ }
100
+
101
+ return {
102
+ server,
103
+ tool,
104
+ argumentsJson,
105
+ parsedArguments,
106
+ x402: hasX402,
107
+ noParse: hasNoParse,
108
+ verbose: hasVerbose
109
+ };
110
+ }
111
+
112
+ async function main() {
113
+ const config = parseArgs();
114
+
115
+ // Validate ATXP_CONNECTION environment variable
116
+ const atxpConnectionString = process.env.ATXP_CONNECTION;
117
+ if (!atxpConnectionString) {
118
+ originalConsole.error('Error: ATXP_CONNECTION environment variable is not set\n');
119
+ originalConsole.error('Please set the ATXP_CONNECTION environment variable:');
120
+ originalConsole.error(' export ATXP_CONNECTION="your-connection-string"');
121
+ originalConsole.error('');
122
+ originalConsole.error('Or create a .env file in the current directory with:');
123
+ originalConsole.error(' ATXP_CONNECTION=your-connection-string');
124
+ originalConsole.error('');
125
+ originalConsole.error('You can find your connection string at https://accounts.atxp.ai');
126
+ originalConsole.error('');
127
+ process.exit(1);
128
+ }
129
+
130
+ const atxpConfig = {
131
+ mcpServer: config.server,
132
+ account: new ATXPAccount(atxpConnectionString),
133
+ };
134
+
135
+ // Create a client using the `atxpClient` function
136
+ const client = await atxpClient({
137
+ ...atxpConfig,
138
+ fetchFn: config.x402 ? wrapWithX402(atxpConfig) : undefined,
139
+ });
140
+ const result = await client.callTool({
141
+ name: config.tool,
142
+ arguments: config.parsedArguments,
143
+ });
144
+
145
+ // Output to stdout in CLI-idiomatic way
146
+ if (config.noParse) {
147
+ originalConsole.log(JSON.stringify(result, null, 2));
148
+ } else {
149
+ const text = result.content[0].text;
150
+
151
+ // Try to parse and pretty-print if it's JSON
152
+ try {
153
+ const parsed = JSON.parse(text);
154
+ originalConsole.log(JSON.stringify(parsed, null, 2));
155
+ } catch {
156
+ // Not JSON or invalid JSON, print as-is
157
+ originalConsole.log(text);
158
+ }
159
+ }
160
+ }
161
+
162
+ // Run if executed directly
163
+ if (require.main === module) {
164
+ main().catch(error => {
165
+ originalConsole.error('Error:', error.message);
166
+ process.exit(1);
167
+ });
168
+ }
169
+
170
+ module.exports = { parseArgs, main };
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "atxp-call",
3
+ "version": "1.0.0",
4
+ "description": "A command-line tool for calling tools on ATXP MCP servers",
5
+ "license": "MIT",
6
+ "author": "DNR",
7
+ "type": "commonjs",
8
+ "main": "atxp-call.js",
9
+ "bin": {
10
+ "atxp-call": "./atxp-call.js"
11
+ },
12
+ "keywords": [
13
+ "atxp",
14
+ "mcp",
15
+ "cli",
16
+ "tool"
17
+ ],
18
+ "scripts": {
19
+ "test": "echo \"Error: no test specified\" && exit 1"
20
+ },
21
+ "dependencies": {
22
+ "@atxp/client": "^0.7.4",
23
+ "@atxp/x402": "^0.7.4",
24
+ "dotenv": "^16.4.5"
25
+ }
26
+ }