Skip to content

Commit e1f0f3b

Browse files
authored
docs: update project docs (#82)
* docs: update project docs and README
1 parent 6f04b66 commit e1f0f3b

File tree

6 files changed

+408
-1
lines changed

6 files changed

+408
-1
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
- **📁 Directory Bubbling**: Intelligent discovery of project-scoped MCP configs from nested directories
2929
- **🔄 Process Detection**: Real-time status of running MCP servers
3030
- **🔒 Credential Analysis**: Security analysis of environment variables and API keys
31+
- **🌐 URL Hostname Extraction**: Clean display of hostnames for URL-based MCP servers
3132
- **🌍 Cross-Platform**: Support for Windows and macOS (Linux support coming soon)
3233
- **⚡ High Performance**: Fast discovery with intelligent caching and optimization
3334

@@ -51,6 +52,20 @@ cd ~/projects/my-project/backend/services/api
5152
npx ls-mcp # Automatically finds .vscode/mcp.json from project root
5253
```
5354

55+
### URL Hostname Extraction
56+
57+
The tool now displays clean hostnames for URL-based MCP servers instead of full URLs:
58+
59+
```bash
60+
# Before: Full URLs cluttered the SOURCE column
61+
SOURCE | STATUS | NAME | TRANSPORT
62+
http://localhost:3000/mcp || local-server | http
63+
64+
# After: Clean hostnames for better readability
65+
SOURCE | STATUS | NAME | TRANSPORT
66+
localhost || local-server | http
67+
```
68+
5469
### Debug Mode
5570

5671
To enable verbose debugging output, set the `NODE_DEBUG` environment variable:
@@ -63,6 +78,17 @@ NODE_DEBUG=ls-mcp npx ls-mcp
6378
NODE_DEBUG=* npx ls-mcp
6479
```
6580

81+
## Documentation
82+
83+
For detailed information about the project architecture and features:
84+
85+
- **[Project Overview](./docs/project.md)**: Comprehensive project analysis and architecture
86+
- **[Design Documentation](./docs/design.md)**: Technical design decisions and implementation details
87+
- **[Requirements](./docs/requirements.md)**: Functional and non-functional requirements
88+
- **[Directory Bubbling](./docs/directory-bubbling.md)**: Intelligent directory traversal feature
89+
- **[URL Hostname Extraction](./docs/url-hostname-extraction.md)**: Clean display of hostnames for URL-based servers
90+
- **[Credential Detection](./docs/credential-detection.md)**: Security analysis features
91+
6692
## Contributing
6793

6894
Please consult [CONTRIBUTING](./.github/CONTRIBUTING.md) for guidelines on contributing to this project.

docs/design.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ When MCP server configurations don't explicitly specify a `type` field, the syst
333333
"web-server": {
334334
"url": "https://example.com/mcp"
335335
// No type field → automatically inferred as "http"
336+
// Hostname "example.com" will be displayed in SOURCE column
336337
}
337338
}
338339
}
@@ -387,6 +388,58 @@ When MCP server configurations don't explicitly specify a `type` field, the syst
387388
- **Intelligent Defaults**: Reasonable assumptions based on configuration patterns
388389
- **Comprehensive Coverage**: Handles all common MCP server configuration scenarios
389390

391+
## URL Hostname Extraction
392+
393+
### Overview
394+
The URL hostname extraction feature (Feature #80) improves the readability of MCP server configurations by displaying only the hostname portion for URL-based servers in the SOURCE column.
395+
396+
### Implementation Details
397+
398+
#### 1. Hostname Extraction Logic
399+
```typescript
400+
export function extractHostname(urlString: string): string {
401+
try {
402+
// Handle URLs without protocol by adding a default one
403+
let urlToParse = urlString
404+
if (!urlToParse.includes('://')) {
405+
urlToParse = `http://${urlToParse}`
406+
}
407+
const url = new URL(urlToParse)
408+
return url.hostname
409+
} catch (error) {
410+
// If URL parsing fails, return the original string
411+
return urlString
412+
}
413+
}
414+
```
415+
416+
#### 2. Service Integration
417+
- **MCPConfigService**: Extracts hostname during server configuration conversion
418+
- **MCPServerManagerService**: Sets source field to hostname when URL is available
419+
- **Fallback Handling**: Returns original string if URL parsing fails
420+
421+
#### 3. URL Format Support
422+
- **HTTP/HTTPS**: Standard web protocols
423+
- **Custom Protocols**: Any protocol supported by Node.js URL constructor
424+
- **Protocol-less URLs**: Automatically adds `http://` for parsing
425+
- **IP Addresses**: Handles both IPv4 and IPv6 addresses
426+
- **Port Numbers**: Port information is stripped from display
427+
- **Query Parameters**: Query strings are ignored in hostname extraction
428+
429+
#### 4. Benefits
430+
- **Cleaner Output**: SOURCE column is more readable and concise
431+
- **Better UX**: Users can quickly identify server location without URL clutter
432+
- **Consistent Display**: All URL-based servers show consistent hostname format
433+
- **Robust Parsing**: Handles various URL formats gracefully with fallback
434+
435+
#### 5. Example Transformations
436+
```
437+
Before: "http://localhost:3000/mcp" → After: "localhost"
438+
Before: "https://api.example.com/v1/mcp" → After: "api.example.com"
439+
Before: "192.168.1.100:8080" → After: "192.168.1.100"
440+
Before: "invalid-url" → After: "invalid-url" (fallback)
441+
```
442+
390443
## Error Handling Strategy
391444

392445
### 1. Graceful Degradation

docs/directory-bubbling.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,28 @@ constructor () {
206206
- **Integration Tests**: Comprehensive testing of MCPConfigService integration
207207
- **Edge Cases**: Boundary conditions, error scenarios, symlink handling
208208

209+
### Test Architecture Improvements
210+
The directory bubbling tests have been significantly improved to address performance and reliability issues:
211+
212+
#### Before (Problematic Tests)
213+
- **Global Mocking**: Tests were mocking `fs.access` globally, causing conflicts
214+
- **Heavy Operations**: Tests called `getMCPFileGroups()` which performed real filesystem operations
215+
- **Hanging Tests**: Tests would hang indefinitely due to infinite loops and filesystem access
216+
- **Poor Isolation**: Tests were not properly isolated from system dependencies
217+
218+
#### After (Improved Tests)
219+
- **Direct Service Mocking**: Tests now mock `DirectoryBubbleService.prototype.findLocalConfigInParentDirectories` directly
220+
- **Lightweight Testing**: Tests focus on service configuration and integration rather than heavy filesystem operations
221+
- **Fast Execution**: Tests complete in ~5 seconds instead of hanging
222+
- **Proper Isolation**: Each test is properly isolated and tests specific functionality
223+
224+
#### Test Strategy
225+
- **Service Configuration Tests**: Verify that `enableDirectoryBubbling` is set correctly
226+
- **Service Creation Tests**: Ensure services can be instantiated with different options
227+
- **Integration Tests**: Verify proper wiring between MCPConfigService and DirectoryBubbleService
228+
- **Error Handling Tests**: Test resilience when directory bubbling fails
229+
- **Mock Validation**: Verify that mocks are called appropriately based on configuration
230+
209231
### Test Scenarios
210232
- ✅ Config file in current directory
211233
- ✅ Config file in parent directory

docs/project.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The tool works by scanning for known MCP configuration files associated with var
1616

1717
3. **Process Detection:** For each configured MCP server, the tool checks if it is currently running. It does this by executing system commands (`ps` on macOS and `powershell` on Windows) to get a list of all active processes. It then compares the command from the MCP configuration with the running processes to determine the server's status. The tool includes specific logic to handle common ways of running MCP servers, such as using `uvx` or `npx`.
1818

19-
4. **Output Rendering:** Finally, all the gathered information is displayed in a formatted table in the console. The table shows the server's status (running or stopped), name, source (the command used to start it), and transport protocol.
19+
4. **Output Rendering:** Finally, all the gathered information is displayed in a formatted table in the console. The table shows the server's status (running or stopped), name, source (the command used to start it or hostname for URL-based servers), and transport protocol.
2020

2121
## Project Structure
2222

@@ -67,6 +67,7 @@ This architecture ensures maintainability and clear separation of concerns betwe
6767
- **Transport Handling**: Fixed transport counting by properly mapping `type` field to `transport` field at the data layer
6868
- **Extended Transport Support**: Added support for `streamable-http` type, treating it as synonym for `http`
6969
- **Transport Inference**: Implemented intelligent automatic detection of transport types when not explicitly specified
70+
- **URL Hostname Extraction**: Implemented feature #80 to display only hostnames for URL-based MCP servers in the SOURCE column, improving readability
7071
- **Directory Bubbling**: Implemented intelligent directory traversal for local MCP config files, providing better DX when running from nested project subdirectories
7172
- **Test Isolation**: Fixed critical issue where tests were accessing real files outside the project directory
7273
- **Type Safety**: Created comprehensive TypeScript types for all services
@@ -86,6 +87,45 @@ This architecture ensures maintainability and clear separation of concerns betwe
8687
- **Linux Support**: Architecture supports adding Linux support in future iterations
8788
- **Plugin System**: Extensible design for custom AI application definitions
8889

90+
## URL Hostname Extraction Feature
91+
92+
### Overview
93+
The URL hostname extraction feature improves the readability of MCP server configurations by displaying only the hostname for URL-based servers instead of the full URL in the SOURCE column.
94+
95+
### How It Works
96+
1. **URL Detection**: When an MCP server configuration contains a `url` field, the system automatically extracts the hostname portion
97+
2. **Hostname Extraction**: Uses Node.js built-in `URL` constructor to parse URLs and extract the hostname
98+
3. **Fallback Handling**: If URL parsing fails, the original string is displayed as a fallback
99+
4. **Protocol Handling**: Automatically adds `http://` protocol if none is specified for proper parsing
100+
101+
### Example Scenarios
102+
103+
#### Before (Full URL Display)
104+
```
105+
SOURCE | STATUS | NAME | TRANSPORT
106+
http://localhost:3000/mcp | ❌ | local-server | http
107+
https://api.example.com | ❌ | api-server | http
108+
```
109+
110+
#### After (Hostname Display)
111+
```
112+
SOURCE | STATUS | NAME | TRANSPORT
113+
localhost | ❌ | local-server | http
114+
api.example.com | ❌ | api-server | http
115+
```
116+
117+
### Benefits
118+
- **Cleaner Output**: SOURCE column is more readable and concise
119+
- **Better UX**: Users can quickly identify the server location without URL clutter
120+
- **Consistent Display**: All URL-based servers show consistent hostname format
121+
- **Robust Parsing**: Handles various URL formats including those without protocols
122+
123+
### Implementation Details
124+
- **Utility Function**: `extractHostname()` in `src/utils/url-utils.ts`
125+
- **Service Integration**: Integrated into both `MCPConfigService` and `MCPServerManagerService`
126+
- **Error Handling**: Graceful fallback to original string if parsing fails
127+
- **Protocol Support**: Handles HTTP, HTTPS, and custom protocols
128+
89129
## Directory Bubbling Feature
90130

91131
### Overview

docs/requirements.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ The following AI applications are currently supported:
5454
- **Must** maintain clean separation between external config format and internal data model
5555
- **Must** automatically infer transport types when `type` field is not explicitly set:
5656
- **Must** infer `http` transport when `url` property is present
57+
- **Must** extract and display only hostname for URL-based MCP servers in the SOURCE column (Feature #80)
5758
- **Must** infer transport from `args` array keywords (`stdio`, `http`, `sse`)
5859
- **Must** default to `stdio` transport when `command` is present but no other indicators found
5960

0 commit comments

Comments
 (0)