Skip to content

Commit e562038

Browse files
committed
Update compatibility documentation and refactor MCP parameters to JSON format
- Modified COMPATIBILITY_SUMMARY.md to include changes for `env`, `headers`, and `patch` parameters to JSON strings. - Updated GEMINI_COMPATIBILITY.md with examples reflecting the new JSON string format for `upstream_servers`. - Refactored mcp.go to handle new JSON string parameters while ensuring backward compatibility with legacy formats.
1 parent cfbf442 commit e562038

3 files changed

Lines changed: 27 additions & 4 deletions

File tree

COMPATIBILITY_SUMMARY.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919

2020
**Changed Parameters**:
2121
- `args``args_json` (JSON string)
22+
- `env``env_json` (JSON string)
23+
- `headers``headers_json` (JSON string)
24+
- `patch``patch_json` (JSON string)
2225

2326
### 🔄 Backward Compatibility
2427
- ✅ All existing tools and scripts continue to work

GEMINI_COMPATIBILITY.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@ mcp.WithString("args_json",
4444
),
4545
```
4646

47+
**`upstream_servers` Changes:**
48+
```go
49+
// Before (Gemini 2.5/GPT-4.1 incompatible)
50+
mcp.WithArray("args", ...),
51+
mcp.WithObject("env", ...),
52+
mcp.WithObject("headers", ...),
53+
54+
// After (Gemini 2.5/GPT-4.1 compatible)
55+
mcp.WithString("args_json", ...),
56+
mcp.WithString("env_json", ...),
57+
mcp.WithString("headers_json", ...),
58+
```
59+
4760
### Usage Examples
4861

4962
**upstream_servers - New JSON string format:**

internal/server/mcp.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ func (p *MCPProxyServer) registerTools(_ bool) {
163163
mcp.WithString("command",
164164
mcp.Description("Command to run for stdio servers (e.g., 'uvx', 'python')"),
165165
),
166-
mcp.WithArray("args",
167-
mcp.Description("Command arguments for stdio servers as JSON array strings (e.g., ['mcp-server-sqlite', '--db-path', '/path/to/db'])"),
166+
mcp.WithString("args_json",
167+
mcp.Description("Command arguments for stdio servers as a JSON array of strings (e.g., '[\"mcp-server-sqlite\", \"--db-path\", \"/path/to/db\"]')"),
168168
),
169169
mcp.WithString("env_json",
170170
mcp.Description("Environment variables for stdio servers as JSON string (e.g., '{\"API_KEY\": \"value\"}')"),
@@ -854,9 +854,16 @@ func (p *MCPProxyServer) handleAddUpstream(_ context.Context, request mcp.CallTo
854854
return mcp.NewToolResultError("Either 'url' or 'command' parameter is required"), nil
855855
}
856856

857-
// Handle args array
857+
// Handle args JSON string
858858
var args []string
859-
if request.Params.Arguments != nil {
859+
if argsJSON := request.GetString("args_json", ""); argsJSON != "" {
860+
if err := json.Unmarshal([]byte(argsJSON), &args); err != nil {
861+
return mcp.NewToolResultError(fmt.Sprintf("Invalid args_json format: %v", err)), nil
862+
}
863+
}
864+
865+
// Legacy support for old args format
866+
if args == nil && request.Params.Arguments != nil {
860867
if argumentsMap, ok := request.Params.Arguments.(map[string]interface{}); ok {
861868
if argsParam, ok := argumentsMap["args"]; ok {
862869
if argsList, ok := argsParam.([]interface{}); ok {

0 commit comments

Comments
 (0)