Skip to content

Commit c47f05c

Browse files
author
Jose Bovet Derpich
committed
Merge branch 'main' of https://github.com/jbovet/mcp-cli
2 parents 317ce0f + e07e2cc commit c47f05c

File tree

2 files changed

+138
-58
lines changed

2 files changed

+138
-58
lines changed

.github/workflows/lint-pr.yaml

Lines changed: 0 additions & 47 deletions
This file was deleted.

README.md

Lines changed: 138 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
# MCP CLI
22

3-
A command-line interface for interacting with the [MCP Registry Service](https://github.com/modelcontextprotocol/registry).
3+
A command-line interface for interacting with the [MCP Registry Service](https://github.com/modelcontextprotocol/registry) and connecting directly to MCP servers.
44

55
## Features
66

7-
- List registered MCP servers
8-
- Get detailed server information by ID or name
9-
- Check service health and status
10-
- Service ping functionality
11-
- Pagination support for listing servers
12-
- Pattern matching for server searches
7+
- **Registry Service Integration:**
8+
- List registered MCP servers
9+
- Get detailed server information by ID or name
10+
- Check service health and status
11+
- Service ping functionality
12+
- Pagination support for listing servers
13+
- Pattern matching for server searches
14+
15+
- **Direct MCP Server Connection:**
16+
- Connect to MCP servers via stdio transport
17+
- Connect to HTTP-based MCP servers
18+
- Interactive mode for real-time server exploration
19+
- Tool execution with argument parsing
20+
- Resource reading capabilities
21+
- Prompt listing and interaction
1322

1423
## Installation
1524

@@ -25,7 +34,7 @@ The binary will be created in `bin/mcp-cli`.
2534

2635
## Usage
2736

28-
### Basic Commands
37+
### Registry Service Commands
2938

3039
```sh
3140
# List all servers
@@ -47,16 +56,105 @@ mcp-cli health
4756
mcp-cli ping
4857
```
4958

59+
### Direct MCP Server Connection
60+
61+
#### Stdio Transport (Local Processes)
62+
63+
```sh
64+
# Connect to a Python MCP server
65+
mcp-cli connect --type stdio --command "python" --args "server.py"
66+
67+
# Connect to a Node.js MCP server with environment variables
68+
mcp-cli connect --type stdio --command "node" --args "server.js" --env "DEBUG=1"
69+
70+
# Connect using command string parsing
71+
mcp-cli connect --type stdio --command "python /path/to/server.py --port 8080"
72+
73+
# Interactive mode for exploration
74+
mcp-cli connect --type stdio --command "python server.py" --interactive
75+
```
76+
77+
#### HTTP Transport (Remote Servers)
78+
79+
```sh
80+
# Connect to HTTP MCP server
81+
mcp-cli connect --type http --url "http://localhost:8080/mcp"
82+
83+
# Connect to HTTPS MCP server
84+
mcp-cli connect --type streamable --url "https://api.example.com/mcp"
85+
86+
# Interactive mode with HTTP server
87+
mcp-cli connect --type http --url "http://localhost:8080/mcp" --interactive
88+
```
89+
90+
#### Interactive Mode Commands
91+
92+
When running with `--interactive`, you can use these commands:
93+
94+
```sh
95+
# List server capabilities
96+
tools # List available tools
97+
resources # List available resources
98+
prompts # List available prompts
99+
100+
# Execute operations
101+
call <tool-name> [args...] # Call a tool with arguments
102+
read <resource-uri> # Read a resource by URI
103+
104+
# Navigation
105+
help # Show help message
106+
quit/exit # Exit interactive mode
107+
```
108+
109+
#### Example Interactive Session
110+
111+
```sh
112+
> tools
113+
Available tools (3):
114+
1. validate_api - Validate API specifications
115+
2. format_code - Format source code
116+
3. analyze_logs - Analyze log files
117+
118+
> call validate_api openapi.yaml
119+
Tool 'validate_api' result:
120+
✅ Tool executed successfully:
121+
API specification is valid
122+
Found 12 endpoints
123+
No validation errors
124+
125+
> resources
126+
Available resources (2):
127+
1. file://config.json (Configuration) - Server configuration
128+
2. file://schema.yaml (Schema) - API schema definition
129+
130+
> read file://config.json
131+
Resource content:
132+
Text (application/json): {"server": {"port": 8080}}
133+
134+
> quit
135+
Goodbye!
136+
```
137+
50138
### Global Flags
51139

52140
- `--url`: Base URL of the MCP Registry Service (default: http://localhost:8080)
53141
- `--verbose, -v`: Enable verbose output
54142

55-
### Server Listing Options
143+
### Registry Service Options
56144

57145
- `--limit`: Maximum number of servers to return (1-100)
58146
- `--cursor`: Pagination cursor for fetching next page
59147

148+
### Connect Command Options
149+
150+
- `--type`: Transport type (`stdio`, `http`, `streamable`)
151+
- `--url`: Server URL for HTTP-based connections
152+
- `--command`: Command to execute for stdio connections
153+
- `--args`: Arguments for the command (can be repeated)
154+
- `--env`: Environment variables for the command (can be repeated)
155+
- `--timeout`: Connection timeout (default: 60s)
156+
- `--interactive`: Run in interactive mode
157+
60158
## Development
61159

62160
### Requirements
@@ -87,12 +185,41 @@ make clean
87185

88186
```
89187
cmd/ - Command implementations
188+
connect.go - MCP server connection command
189+
get.go - Registry "get" command group
190+
server.go - Individual server details
191+
servers.go - Server listing
192+
health.go - Health check command
193+
ping.go - Ping command
90194
pkg/ - Core packages
91-
client/ - API client implementation
195+
client/ - Registry API client implementation
92196
models/ - Data models
197+
adapter/ - MCP server adapters (stdio, HTTP)
198+
adapter.go - Core adapter interfaces
199+
stdio.go - Stdio transport implementation
200+
http.go - HTTP transport implementation
201+
factory.go - Adapter factory and utilities
93202
bin/ - Build output
94203
```
95204

205+
## Use Cases
206+
207+
### Registry Integration
208+
- Discover available MCP servers in the registry
209+
- Get detailed information about server capabilities
210+
- Monitor registry service health
211+
212+
### Direct Server Testing
213+
- Test MCP server implementations during development
214+
- Validate tool and resource functionality
215+
- Interactive debugging and exploration
216+
- Automated testing and validation scripts
217+
218+
### CI/CD Integration
219+
- Health checks in deployment pipelines
220+
- Automated server capability validation
221+
- Registry service monitoring
222+
96223
## License
97224

98-
MIT License - see [LICENSE.md](LICENSE.md) for details.
225+
MIT License - see [LICENSE.md](LICENSE.md) for details.

0 commit comments

Comments
 (0)