@standardbeagle/mcp-tui 0.1.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 MCP-TUI Contributors
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,208 @@
1
+ # MCP-TUI
2
+
3
+ A Go-based test client for Model Context Protocol (MCP) servers with both interactive TUI and CLI modes.
4
+
5
+ ## Features
6
+
7
+ - **Interactive TUI Mode**: Browse and interact with MCP servers using a terminal user interface
8
+ - **CLI Mode**: Scriptable command-line interface for automation
9
+ - **Multiple Transport Types**: Support for stdio, SSE, and HTTP connections
10
+ - **Server Inspection**: List available tools, resources, and prompts
11
+ - **Dynamic Tool Forms**: Automatically generated forms based on tool schemas
12
+ - **Tool Execution**: Call MCP tools with properly validated arguments
13
+ - **Type Conversion**: Automatic conversion of string inputs to required types (numbers, booleans, arrays)
14
+ - **Progress Tracking**: Real-time progress display for long-running operations with elapsed time
15
+ - **Scrollable Output**: Large results can be scrolled with arrow keys, PgUp/PgDn
16
+ - **Clipboard Support**: Paste with right-click (Windows Terminal) or terminal's paste shortcut
17
+
18
+ ## Installation
19
+
20
+ ### Via Go Install
21
+
22
+ ```bash
23
+ go install github.com/standardbeagle/mcp-tui@latest
24
+ ```
25
+
26
+ ### Via npm/npx
27
+
28
+ ```bash
29
+ # Install globally
30
+ npm install -g @standardbeagle/mcp-tui
31
+
32
+ # Or use directly with npx
33
+ npx @standardbeagle/mcp-tui
34
+ ```
35
+
36
+ ### Build from Source
37
+
38
+ ```bash
39
+ git clone https://github.com/standardbeagle/mcp-tui.git
40
+ cd mcp-tui
41
+ go build -o mcp-tui .
42
+ ```
43
+
44
+ ## Usage
45
+
46
+ ### Interactive Mode (Default)
47
+
48
+ Start the interactive TUI:
49
+
50
+ ```bash
51
+ mcp-tui
52
+ ```
53
+
54
+ Use Tab to switch between connection types (STDIO/SSE/HTTP), enter connection details, and navigate with arrow keys.
55
+
56
+ #### Testing with Sample Server
57
+
58
+ To test with the official MCP sample server:
59
+
60
+ 1. In the TUI, select STDIO connection
61
+ 2. Enter command: `npx`
62
+ 3. Enter args: `@modelcontextprotocol/server-everything stdio`
63
+ 4. Press Enter to connect
64
+
65
+ The sample server includes tools that demonstrate various MCP features:
66
+ - **echo**: Simple text echo
67
+ - **add**: Number addition (demonstrates type conversion)
68
+ - **longRunningOperation**: Configurable delay (tests progress tracking)
69
+ - **sampleLLM**: LLM sampling demonstration
70
+ - **printEnv**: Shows environment variables
71
+ - **getTinyImage**: Returns an image
72
+ - **annotatedMessage**: Demonstrates content annotations
73
+
74
+ ### CLI Mode
75
+
76
+ The CLI mode provides Git-like subcommands for interacting with MCP servers.
77
+
78
+ #### Basic Connection Options
79
+
80
+ All commands require connection parameters:
81
+ - `--type`: Server type (stdio, sse, or http)
82
+ - `--cmd`: Command for stdio servers
83
+ - `--args`: Arguments for stdio command (comma-separated)
84
+ - `--url`: URL for SSE or HTTP servers
85
+ - `--json`: Output results in JSON format
86
+
87
+ #### Tool Commands
88
+
89
+ List available tools:
90
+ ```bash
91
+ mcp-tui --cmd npx --args "@modelcontextprotocol/server-everything,stdio" tool list
92
+ ```
93
+
94
+ Get detailed information about a tool:
95
+ ```bash
96
+ mcp-tui --cmd npx --args "@modelcontextprotocol/server-everything,stdio" tool describe echo
97
+ ```
98
+
99
+ Call a tool with arguments:
100
+ ```bash
101
+ mcp-tui --cmd npx --args "@modelcontextprotocol/server-everything,stdio" tool call echo message="Hello World"
102
+ mcp-tui --cmd npx --args "@modelcontextprotocol/server-everything,stdio" tool call add a=5 b=3
103
+ ```
104
+
105
+ #### Resource Commands
106
+
107
+ List available resources:
108
+ ```bash
109
+ mcp-tui --cmd python --args "server.py" resource list
110
+ ```
111
+
112
+ Read a resource by URI:
113
+ ```bash
114
+ mcp-tui --cmd python --args "server.py" resource read "file:///path/to/resource"
115
+ ```
116
+
117
+ #### Prompt Commands
118
+
119
+ List available prompts:
120
+ ```bash
121
+ mcp-tui --url "http://localhost:8000" --type http prompt list
122
+ ```
123
+
124
+ Get a prompt with arguments:
125
+ ```bash
126
+ mcp-tui --url "http://localhost:8000" --type http prompt get complex_prompt temperature=0.7 style=formal
127
+ ```
128
+
129
+ #### JSON Output
130
+
131
+ All commands support JSON output for scripting:
132
+ ```bash
133
+ # Get tools as JSON
134
+ mcp-tui --cmd npx --args "@modelcontextprotocol/server-everything,stdio" --json tool list
135
+
136
+ # Pipe to jq for processing
137
+ mcp-tui --cmd npx --args "@modelcontextprotocol/server-everything,stdio" --json tool list | jq '.[].name'
138
+ ```
139
+
140
+ ## Connection Types
141
+
142
+ - **stdio**: Connect to MCP servers via standard input/output
143
+ - **sse**: Connect via Server-Sent Events
144
+ - **http**: Connect via HTTP streaming
145
+
146
+ ## Requirements
147
+
148
+ - Go 1.20+ (for building from source)
149
+ - Node.js 14+ (for npm installation)
150
+
151
+ ## Dependencies
152
+
153
+ - [bubbletea](https://github.com/charmbracelet/bubbletea) - TUI framework
154
+ - [lipgloss](https://github.com/charmbracelet/lipgloss) - Terminal styling
155
+ - [cobra](https://github.com/spf13/cobra) - CLI framework
156
+ - [mcp-go](https://github.com/mark3labs/mcp-go) - MCP protocol implementation
157
+
158
+ ## Interactive Controls
159
+
160
+ - **Tab**: Switch connection types
161
+ - **Arrow Keys/j/k**: Navigate menus
162
+ - **Enter**: Select/Execute
163
+ - **q/Ctrl+C**: Quit
164
+ - **Backspace**: Edit input fields
165
+
166
+ ## Publishing
167
+
168
+ ### For Go Module Maintainers
169
+
170
+ 1. Update the module path in `go.mod` to your GitHub repository
171
+ 2. Tag a release:
172
+ ```bash
173
+ git tag v0.1.0
174
+ git push origin v0.1.0
175
+ ```
176
+ 3. The module will be available via `go install github.com/standardbeagle/mcp-tui@latest`
177
+
178
+ ### For npm Package Maintainers
179
+
180
+ 1. Update the repository URLs in `package.json`
181
+ 2. Build binaries for all platforms
182
+ 3. Create a GitHub release with the binaries
183
+ 4. Publish to npm:
184
+ ```bash
185
+ npm publish
186
+ ```
187
+
188
+ ## Building Release Binaries
189
+
190
+ To build binaries for multiple platforms:
191
+
192
+ ```bash
193
+ # Linux amd64
194
+ GOOS=linux GOARCH=amd64 go build -o dist/mcp-tui_linux_amd64 .
195
+
196
+ # macOS amd64
197
+ GOOS=darwin GOARCH=amd64 go build -o dist/mcp-tui_darwin_amd64 .
198
+
199
+ # macOS arm64
200
+ GOOS=darwin GOARCH=arm64 go build -o dist/mcp-tui_darwin_arm64 .
201
+
202
+ # Windows amd64
203
+ GOOS=windows GOARCH=amd64 go build -o dist/mcp-tui_windows_amd64.exe .
204
+ ```
205
+
206
+ ## License
207
+
208
+ MIT
package/bin/mcp-tui.js ADDED
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { execFile } = require('child_process');
4
+ const path = require('path');
5
+ const fs = require('fs');
6
+ const os = require('os');
7
+
8
+ // Determine the binary name based on the platform
9
+ function getBinaryName() {
10
+ const platform = os.platform();
11
+ const arch = os.arch();
12
+
13
+ let binaryName = 'mcp-tui';
14
+
15
+ if (platform === 'win32') {
16
+ binaryName += '.exe';
17
+ }
18
+
19
+ return binaryName;
20
+ }
21
+
22
+ // Get the path to the binary
23
+ function getBinaryPath() {
24
+ const binaryName = getBinaryName();
25
+ const binaryDir = path.join(__dirname, '..', 'binaries');
26
+ const binaryPath = path.join(binaryDir, binaryName);
27
+
28
+ return binaryPath;
29
+ }
30
+
31
+ // Execute the binary
32
+ function runBinary() {
33
+ const binaryPath = getBinaryPath();
34
+
35
+ // Check if binary exists
36
+ if (!fs.existsSync(binaryPath)) {
37
+ console.error(`Error: Binary not found at ${binaryPath}`);
38
+ console.error('Please run "npm install" to download the binary.');
39
+ process.exit(1);
40
+ }
41
+
42
+ // Make sure the binary is executable (Unix-like systems)
43
+ if (process.platform !== 'win32') {
44
+ try {
45
+ fs.chmodSync(binaryPath, 0o755);
46
+ } catch (err) {
47
+ console.error(`Error setting executable permissions: ${err.message}`);
48
+ }
49
+ }
50
+
51
+ // Pass through all arguments
52
+ const args = process.argv.slice(2);
53
+
54
+ // Execute the binary
55
+ const child = execFile(binaryPath, args, { stdio: 'inherit' });
56
+
57
+ child.on('error', (err) => {
58
+ console.error(`Error executing binary: ${err.message}`);
59
+ process.exit(1);
60
+ });
61
+
62
+ child.on('exit', (code) => {
63
+ process.exit(code);
64
+ });
65
+ }
66
+
67
+ // Run the binary
68
+ runBinary();
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@standardbeagle/mcp-tui",
3
+ "version": "0.1.0",
4
+ "description": "A Terminal User Interface (TUI) and CLI for Model Context Protocol (MCP) servers",
5
+ "main": "index.js",
6
+ "bin": {
7
+ "mcp-tui": "bin/mcp-tui.js"
8
+ },
9
+ "scripts": {
10
+ "postinstall": "node scripts/install.js",
11
+ "test": "echo \"Error: no test specified\" && exit 1"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/standardbeagle/mcp-tui.git"
16
+ },
17
+ "keywords": [
18
+ "mcp",
19
+ "model-context-protocol",
20
+ "tui",
21
+ "terminal",
22
+ "cli",
23
+ "ai",
24
+ "llm"
25
+ ],
26
+ "author": "standardbeagle",
27
+ "license": "MIT",
28
+ "bugs": {
29
+ "url": "https://github.com/standardbeagle/mcp-tui/issues"
30
+ },
31
+ "homepage": "https://github.com/standardbeagle/mcp-tui#readme",
32
+ "dependencies": {
33
+ "node-fetch": "^3.3.2"
34
+ },
35
+ "files": [
36
+ "bin/",
37
+ "scripts/",
38
+ "README.md",
39
+ "LICENSE"
40
+ ],
41
+ "engines": {
42
+ "node": ">=14.0.0"
43
+ }
44
+ }
@@ -0,0 +1,143 @@
1
+ #!/usr/bin/env node
2
+
3
+ const os = require('os');
4
+ const path = require('path');
5
+ const fs = require('fs');
6
+ const https = require('https');
7
+ const { execSync } = require('child_process');
8
+
9
+ const REPO = 'standardbeagle/mcp-tui';
10
+ const VERSION = require('../package.json').version;
11
+
12
+ function getPlatformInfo() {
13
+ const platform = os.platform();
14
+ const arch = os.arch();
15
+
16
+ // Map Node.js platform/arch to Go's GOOS/GOARCH
17
+ const platformMap = {
18
+ 'darwin': 'darwin',
19
+ 'linux': 'linux',
20
+ 'win32': 'windows'
21
+ };
22
+
23
+ const archMap = {
24
+ 'x64': 'amd64',
25
+ 'arm64': 'arm64',
26
+ 'arm': 'arm'
27
+ };
28
+
29
+ return {
30
+ goos: platformMap[platform] || platform,
31
+ goarch: archMap[arch] || arch,
32
+ platform: platform,
33
+ arch: arch
34
+ };
35
+ }
36
+
37
+ function getBinaryName() {
38
+ const { platform } = getPlatformInfo();
39
+ let binaryName = 'mcp-tui';
40
+ if (platform === 'win32') {
41
+ binaryName += '.exe';
42
+ }
43
+ return binaryName;
44
+ }
45
+
46
+ async function downloadBinary() {
47
+ const { goos, goarch } = getPlatformInfo();
48
+ const binaryName = getBinaryName();
49
+
50
+ // Construct the download URL
51
+ const downloadUrl = `https://github.com/${REPO}/releases/download/v${VERSION}/mcp-tui_${VERSION}_${goos}_${goarch}.tar.gz`;
52
+
53
+ console.log(`Downloading mcp-tui binary for ${goos}/${goarch}...`);
54
+ console.log(`URL: ${downloadUrl}`);
55
+
56
+ const binariesDir = path.join(__dirname, '..', 'binaries');
57
+ const binaryPath = path.join(binariesDir, binaryName);
58
+
59
+ // Create binaries directory
60
+ if (!fs.existsSync(binariesDir)) {
61
+ fs.mkdirSync(binariesDir, { recursive: true });
62
+ }
63
+
64
+ // For development, try to build from source if available
65
+ if (fs.existsSync(path.join(__dirname, '..', '..', 'go.mod'))) {
66
+ console.log('Development mode: Building from source...');
67
+ try {
68
+ const projectRoot = path.join(__dirname, '..', '..');
69
+ execSync(`go build -o ${binaryPath} .`, {
70
+ cwd: projectRoot,
71
+ stdio: 'inherit'
72
+ });
73
+ console.log('Binary built successfully!');
74
+ return;
75
+ } catch (err) {
76
+ console.log('Failed to build from source, attempting download...');
77
+ }
78
+ }
79
+
80
+ // Download binary from releases
81
+ return new Promise((resolve, reject) => {
82
+ https.get(downloadUrl, (response) => {
83
+ if (response.statusCode === 302 || response.statusCode === 301) {
84
+ // Follow redirect
85
+ https.get(response.headers.location, (redirectResponse) => {
86
+ handleResponse(redirectResponse);
87
+ }).on('error', reject);
88
+ } else {
89
+ handleResponse(response);
90
+ }
91
+
92
+ function handleResponse(res) {
93
+ if (res.statusCode !== 200) {
94
+ reject(new Error(`Failed to download binary: ${res.statusCode}`));
95
+ return;
96
+ }
97
+
98
+ const tarPath = path.join(binariesDir, 'mcp-tui.tar.gz');
99
+ const file = fs.createWriteStream(tarPath);
100
+
101
+ res.pipe(file);
102
+
103
+ file.on('finish', () => {
104
+ file.close();
105
+
106
+ // Extract the tar.gz file
107
+ try {
108
+ execSync(`tar -xzf ${tarPath} -C ${binariesDir}`, {
109
+ stdio: 'inherit'
110
+ });
111
+
112
+ // Remove the tar file
113
+ fs.unlinkSync(tarPath);
114
+
115
+ // Make binary executable
116
+ if (process.platform !== 'win32') {
117
+ fs.chmodSync(binaryPath, 0o755);
118
+ }
119
+
120
+ console.log('Binary downloaded and extracted successfully!');
121
+ resolve();
122
+ } catch (err) {
123
+ reject(new Error(`Failed to extract binary: ${err.message}`));
124
+ }
125
+ });
126
+ }
127
+ }).on('error', reject);
128
+ });
129
+ }
130
+
131
+ // Main installation
132
+ async function install() {
133
+ try {
134
+ await downloadBinary();
135
+ } catch (err) {
136
+ console.error('Installation failed:', err.message);
137
+ console.error('\nYou can manually download the binary from:');
138
+ console.error(`https://github.com/${REPO}/releases`);
139
+ process.exit(1);
140
+ }
141
+ }
142
+
143
+ install();