12 Commits

Author SHA1 Message Date
0xJacky 3e411d38dd Harden config write paths 2026-04-21 22:40:50 +08:00
Jacky d454a2a9d2 fix(mcp): prevent panic on nil interface conversion for tool arguments (#1622)
* fix(mcp): prevent panic on nil interface conversion for tool arguments

Add safe argument extraction helper functions in internal/mcp/args.go
that handle nil values gracefully instead of panicking on direct type
assertions.

This fixes the issue where MCP config tools panic with:
'interface conversion: interface {} is nil, not string'
when called via Claude Desktop with protocol version 2025-11-25.

Affected tools:
- nginx_config_list
- nginx_config_get
- nginx_config_add
- nginx_config_modify
- nginx_config_rename
- nginx_config_mkdir
- nginx_config_history
- nginx_config_enable

Fixes #36ec

Co-authored-by: Jacky <me@jackyu.cn>

* Add required argument validation to MCP config handlers to prevent data loss

The safe argument extraction helpers (mcp.GetString, etc.) return zero values
for nil/missing arguments, which could cause silent data loss. This adds
explicit validation for required arguments in:

- config_modify: validate relative_path and content
- config_add: validate name and content
- config_rename: validate orig_name and new_name
- config_mkdir: validate folder_name

This follows the same pattern already used in handleNginxConfigEnable.

* Add required argument validation to config_get and config_history handlers

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-04-04 10:51:50 +08:00
0xJacky 20412b5b54 refactor: configuration path resolution for sites and streams 2026-03-15 22:20:29 +08:00
0xJacky 413dc631ee feat: add WebSocketTrustedOrigins configuration and implement origin validation for WebSocket connections
- Introduced `WebSocketTrustedOrigins` setting in `app.example.ini` and corresponding documentation.
- Refactored WebSocket origin checks across multiple API endpoints to utilize the new middleware for improved security.
- Added tests for the new origin validation logic to ensure proper handling of trusted origins and node secret requests.
2026-03-14 23:37:10 +08:00
Felipe Gabriel f95836f779 Tool for enable config created and registered on mcp config (#1459)
* Tool for enable config created and registered on mcp config

* fix: Added protection for missing traversal path and windonws syslink path transformation on enable config cmp tool

* fix: Fix error to create dstDir if do not exists
2025-11-28 21:19:47 +08:00
0xJacky c355cb8e65 feat: add llm sessions and update related logic 2025-09-02 08:01:09 +00:00
0xJacky a982c04898 enhance: llm and code completion 2025-09-01 10:52:43 +08:00
0xJacky 2d4deedf4a feat(config): add Name attribute to config assignment in EditConfig and handleNginxConfigModify functions #1273 2025-07-30 21:23:06 +08:00
Jacky 7069cb16d0 refactor(nginx): replace direct reload calls with unified control method for better error handling 2025-05-28 01:35:21 +00:00
Jacky 1e34d9e29e chore: update deps 2025-05-26 04:02:32 +00:00
Jacky 58f5d6d132 refactor(nginx): simplify control error handling 2025-05-13 21:14:36 +08:00
Jacky e8ee931e16 feat: mcp server 2025-04-29 17:41:09 +08:00