Skip to content

Commit f245b22

Browse files
committed
feat: enhance UI command with input prompts for server options; update API server documentation for port and host changes
1 parent bb28892 commit f245b22

4 files changed

Lines changed: 93 additions & 155 deletions

File tree

bin/UI.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,25 @@ export const builder = (yargs) => yargs.options(baseLite.getBuilder({
1818
desc: 'Server host (default: localhost)'
1919
}
2020
}, false)).wrap(160).example('hana-cli UI', baseLite.bundle.getText("UI")).wrap(160).epilog(buildDocEpilogue('UI', 'developer-tools', ['readMeUI', 'helpDocu'])).example('hana-cli server --port 8080', 'Start server on port 8080').example('hana-cli server --host 0.0.0.0 --port 8080', 'Start server on all interfaces')
21+
22+
export let inputPrompts = {
23+
port: {
24+
description: 'Server port (default: 3010)',
25+
type: 'number',
26+
required: false,
27+
ask: () => { }
28+
},
29+
host: {
30+
description: 'Server host (default: localhost)',
31+
type: 'string',
32+
required: false,
33+
ask: () => { }
34+
}
35+
}
36+
2137
export async function handler (argv) {
2238
const base = await import('../utils/base.js')
23-
base.promptHandler(argv, UI, {})
39+
base.promptHandler(argv, UI, inputPrompts, false)
2440
}
2541
export async function UI(prompts){
2642
const base = await import('../utils/base.js')

docs/03-features/api-server/index.md

Lines changed: 34 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -9,51 +9,32 @@ Start the API server:
99
```bash
1010
hana-cli server
1111

12-
# By default listens on http://localhost:3001
12+
# By default listens on http://localhost:3010
1313
```
1414

1515
Access the API:
1616

1717
```bash
1818
# List all tables
19-
curl http://localhost:3001/api/tables -H "Authorization: Bearer YOUR_TOKEN"
19+
curl http://localhost:3010/hana/tables
2020

2121
# Get table details
22-
curl http://localhost:3001/api/tables/MY_SCHEMA/MY_TABLE -H "Authorization: Bearer YOUR_TOKEN"
22+
curl http://localhost:3010/hana/tables/MY_SCHEMA/MY_TABLE
2323

2424
# Execute query
25-
curl -X POST http://localhost:3001/api/execute \
26-
-H "Authorization: Bearer YOUR_TOKEN" \
25+
curl -X POST http://localhost:3010/hana/querySimple \
2726
-H "Content-Type: application/json" \
28-
-d '{"sql": "SELECT * FROM MY_TABLE LIMIT 10"}'
27+
-d '{"q": "SELECT * FROM MY_TABLE LIMIT 10"}'
2928
```
3029

3130
## API Overview
3231

3332
The HANA CLI API server provides HTTP endpoints for all CLI commands.
3433

35-
### Server Modes
36-
37-
**CLI Mode** (default)
38-
```bash
39-
hana-cli [command] [options]
40-
```
41-
42-
**Web UI Mode** (interactive UI)
43-
```bash
44-
hana-cli [command] -w --port 3010
45-
```
46-
47-
**API Server Mode** (programmatic access)
48-
```bash
49-
hana-cli server --port 3001
50-
```
51-
5234
### Request Format
5335

5436
```json
55-
POST /api/execute HTTP/1.1
56-
Authorization: Bearer <token>
37+
POST /hana/execute HTTP/1.1
5738
Content-Type: application/json
5839

5940
{
@@ -68,6 +49,7 @@ Content-Type: application/json
6849
### Response Format
6950

7051
Success response:
52+
7153
```json
7254
{
7355
"success": true,
@@ -83,6 +65,7 @@ Success response:
8365
```
8466

8567
Error response:
68+
8669
```json
8770
{
8871
"success": false,
@@ -96,38 +79,36 @@ Error response:
9679

9780
### Connection
9881

99-
- `GET /api/connection` - Current connection info
100-
- `POST /api/connect` - Establish new connection
101-
- `POST /api/disconnect` - Close connection
82+
- `GET /hana/connection` - Current connection info
83+
- `POST /hana/connect` - Establish new connection
84+
- `POST /hana/disconnect` - Close connection
10285

10386
### Data Operations
10487

105-
- `GET /api/tables?schema=SCHEMA` - List tables
106-
- `GET /api/tables/SCHEMA/TABLE` - Table details
107-
- `GET /api/views?schema=SCHEMA` - List views
108-
- `POST /api/export` - Export data
109-
- `POST /api/import` - Import data
88+
- `GET /hana/tables?schema=SCHEMA` - List tables
89+
- `GET /hana/tables/SCHEMA/TABLE` - Table details
90+
- `GET /hana/views?schema=SCHEMA` - List views
91+
- `POST /hana/export` - Export data
92+
- `POST /hana/import` - Import data
11093

11194
### Schema Operations
11295

113-
- `GET /api/schemas` - List all schemas
114-
- `GET /api/objects?schema=SCHEMA` - List objects
115-
- `POST /api/compareSchema` - Compare schemas
116-
- `POST /api/schemaClone` - Clone schema
96+
- `GET /hana/schemas` - List all schemas
97+
- `GET /hana/objects?schema=SCHEMA` - List objects
98+
- `POST /hana/compareSchema` - Compare schemas
99+
- `POST /hana/schemaClone` - Clone schema
117100

118101
### Query Execution
119102

120-
- `POST /api/execute` - Run SQL query
121-
- `POST /api/callProcedure` - Execute stored procedure
122-
- `GET /api/query/:id/results` - Get query results
123-
- `POST /api/query/:id/cancel` - Cancel running query
103+
- `POST /hana/execute` - Run SQL query
104+
- `POST /hana/callProcedure` - Execute stored procedure
105+
- `GET /hana/query/:id/results` - Get query results
106+
- `POST /hana/query/:id/cancel` - Cancel running query
124107

125108
### System
126109

127-
- `GET /api/system/info` - System information
128-
- `GET /api/system/version` - Database version
129-
- `GET /api/health` - Health check
130-
- `GET /api/metrics` - Performance metrics
110+
- `GET /hana/health` - Health check
111+
- `GET /hana/metrics` - Performance metrics
131112

132113
## Authentication
133114

@@ -137,25 +118,12 @@ By default, run in **unsecured mode** (development/local):
137118
hana-cli server
138119
```
139120

140-
With token authentication:
141-
142-
```bash
143-
hana-cli server --token-required \
144-
--tokens "prod-token:secret123,dev-token:secret456"
145-
```
146-
147-
With API key:
148-
149-
```bash
150-
hana-cli server --api-key "my-app-api-key"
151-
```
152-
153121
## Configuration
154122

155123
### Port
156124

157125
```bash
158-
hana-cli server --port 3001
126+
hana-cli server --port 3010
159127
```
160128

161129
### Host
@@ -164,39 +132,16 @@ hana-cli server --port 3001
164132
hana-cli server --host 0.0.0.0 # Listen on all interfaces
165133
```
166134

167-
### Database
168-
169-
Use specific connection:
170-
171-
```bash
172-
hana-cli server -d host:port -u user -p password
173-
```
174-
175-
### CORS
176-
177-
Enable cross-origin requests:
178-
179-
```bash
180-
hana-cli server --cors "*"
181-
hana-cli server --cors "https://myapp.example.com"
182-
```
183-
184-
### Rate Limiting
185-
186-
```bash
187-
hana-cli server --rate-limit 100 # Max 100 requests per minute
188-
```
189-
190135
## Usage Examples
191136

192137
### Using with curl
193138

194139
```bash
195140
# Get tables
196-
curl "http://localhost:3001/api/tables?schema=MY_SCHEMA"
141+
curl "http://localhost:3010/hana/tables?schema=MY_SCHEMA"
197142

198143
# Export data with filters
199-
curl -X POST "http://localhost:3001/api/export" \
144+
curl -X POST "http://localhost:3010/hana/export" \
200145
-H "Content-Type: application/json" \
201146
-d '{
202147
"schema": "MY_SCHEMA",
@@ -206,7 +151,7 @@ curl -X POST "http://localhost:3001/api/export" \
206151
}'
207152

208153
# Execute query
209-
curl -X POST "http://localhost:3001/api/execute" \
154+
curl -X POST "http://localhost:3010/hana/execute" \
210155
-H "Content-Type: application/json" \
211156
-d '{
212157
"sql": "SELECT COUNT(*) FROM MY_TABLE"
@@ -219,12 +164,12 @@ curl -X POST "http://localhost:3001/api/execute" \
219164
const fetch = require('node-fetch');
220165

221166
// Get table list
222-
const response = await fetch('http://localhost:3001/api/tables?schema=MY_SCHEMA');
167+
const response = await fetch('http://localhost:3010/hana/tables?schema=MY_SCHEMA');
223168
const data = await response.json();
224169
console.log(data.data.rows);
225170

226171
// Execute query
227-
const queryResult = await fetch('http://localhost:3001/api/execute', {
172+
const queryResult = await fetch('http://localhost:3010/hana/execute', {
228173
method: 'POST',
229174
headers: { 'Content-Type': 'application/json' },
230175
body: JSON.stringify({
@@ -241,52 +186,20 @@ import json
241186

242187
# Get tables
243188
response = requests.get(
244-
'http://localhost:3001/api/tables',
189+
'http://localhost:3010/hana/tables',
245190
params={'schema': 'MY_SCHEMA'}
246191
)
247192
tables = response.json()['data']['rows']
248193
print(tables)
249194

250195
# Execute query
251196
result = requests.post(
252-
'http://localhost:3001/api/execute',
197+
'http://localhost:3010/hana/execute',
253198
json={'sql': 'SELECT * FROM MY_TABLE LIMIT 5'}
254199
)
255200
print(result.json())
256201
```
257202

258-
## Performance Considerations
259-
260-
### Connection Pooling
261-
262-
Server maintains connection pool:
263-
- Default pool size: 10 connections
264-
- Configure: `--pool-size 20`
265-
266-
### Query Timeout
267-
268-
Default timeout: 30 seconds
269-
270-
```bash
271-
hana-cli server --timeout 60
272-
```
273-
274-
### Result Caching
275-
276-
Cache recent queries:
277-
278-
```bash
279-
hana-cli server --cache-queries
280-
```
281-
282-
### Compression
283-
284-
Enable response compression:
285-
286-
```bash
287-
hana-cli server --compress
288-
```
289-
290203
## See Also
291204

292205
- [Web UI](../web-ui/)

docs/03-features/mcp/index.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ Complete documentation for the Model Context Protocol (MCP) server that enables
44

55
## Quick Start
66

7-
- **[MCP Quick Setup](../../01-getting-started/mcp-quickstart.md)** - Getting started with MCP server
87
- **[Server Usage Guide](./server-usage.md)** - Running and using the MCP server
98
- **[Architecture Overview](./architecture.md)** - How MCP works with HANA CLI
109

@@ -26,7 +25,7 @@ Complete documentation for the Model Context Protocol (MCP) server that enables
2625

2726
## For Developers
2827

29-
- [MCP Implementation Details](../../developer-notes/mcp-architecture.md)
28+
- [MCP Implementation Details](../../05-development/mcp-server)
3029
- [Troubleshooting](../../troubleshooting/mcp.md)
3130

3231
## Resources

0 commit comments

Comments
 (0)