Conversation
Greptile SummaryThis PR substantially improves MCP (Model Context Protocol) reliability and UX, and fixes several tool-use correctness issues in the streaming pipeline. Key changes:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant UI as ChatPage / useChat
participant Store as mcpStore
participant Client as MCPClient
participant Server as MCP Server
UI->>Store: ensureConnected()
Store->>Store: filter enabled & not connected
Store->>Client: connectServer(id)
Client->>Server: POST (initialize)
Server-->>Client: session ID + capabilities
Client->>Server: GET SSE stream
Server-->>Client: open SSE connection
Client-->>Store: onStatusChange("connected")
Store->>Client: listAllTools()
Client-->>Store: tool definitions
Store-->>UI: MCP tools available
UI->>Store: callMCPTool(serverId, toolName, args)
Store->>Client: client.callTool(toolName, args)
Client->>Server: POST (tool call)
alt Success
Server-->>Client: tool result
Client-->>Store: result
Store-->>UI: { success: true, artifacts }
else Session expired (404/410)
Server-->>Client: 404/410
Client-->>Store: throw "session expired"
Store->>Client: connectServer(id) [reconnect]
Client->>Server: POST (re-initialize)
Server-->>Client: new session
Store->>Client: retry callTool
Client-->>Store: result
Store-->>UI: { success: true, artifacts }
end
Note over Client,Server: SSE error → exponential backoff reconnect (max 5 attempts)
Prompt To Fix All With AIThis is a comment left during a code review.
Path: ui/src/stores/conversationStore.ts
Line: 251-257
Comment:
**`content` fallback silently overridden by `...updates` spread**
`content: updates.content ?? ""` is set on line 253, but then `...updates` on line 257 re-spreads the same key — if `updates.content` is `undefined`, the spread wins and the field ends up as `undefined`, defeating the `?? ""` fallback.
All current callers always provide a string `content`, so this is harmless today, but it is fragile. Moving the spread before the explicit fields makes the intent clear and guarantees the fallback applies:
```suggestion
messages.splice(insertIndex, 0, {
id: crypto.randomUUID(),
role: "assistant",
...updates,
content: updates.content ?? "",
model,
timestamp: new Date(),
});
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: src/config/server.rs
Line: 477-479
Comment:
**CSP `http:` scheme allows arbitrary insecure connections**
The new `connect-src 'self' https: http: wss: ws:` is much broader than the previous explicit allowlist. Including bare `http:` means the browser UI may send authenticated requests (with bearer tokens or cookies) to any plaintext HTTP endpoint, which is exploitable by a network-level attacker. The comment explains the motivation (user-configured MCP servers at arbitrary URLs), but it's worth considering a narrower alternative: keep `https:` / `wss:` for all remote endpoints and add `http://localhost http://127.0.0.1` (or the loopback CIDR if supported) for local-only MCP servers. This would still serve the Ollama / local-MCP use case without opening the full `http:` scheme to the whole internet.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: ui/src/components/MCPConfigModal/MCPConfigModal.tsx
Line: 404-413
Comment:
**`bearerToken` excluded from test-status reset watch**
The `useEffect` resets the test result only when `url` or `headers` change, but `bearerToken` also determines the outcome of `handleTestConnection`. If a user tests with a valid token and sees "success", then changes the token to an invalid value without touching the URL or headers, the stale success badge persists — misleading them into thinking the new token works.
The fix is to also watch the `bearerToken` field so any change to it clears the previous test result, the same way URL and headers changes do.
How can I resolve this? If you propose a fix, please make it concise.Reviews (2): Last reviewed commit: "Enable server when added" | Re-trigger Greptile |
| fn default_csp() -> Option<String> { | ||
| Some("default-src 'self'; script-src 'self' blob: 'unsafe-eval' https://cdn.jsdelivr.net; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:; font-src 'self' data:; media-src 'self' blob:; connect-src 'self' https://cdn.jsdelivr.net https://*.wikipedia.org https://www.wikidata.org; worker-src 'self' blob:; frame-src 'self' blob:; object-src 'none'; base-uri 'self'".to_string()) | ||
| Some("default-src 'self'; script-src 'self' blob: 'unsafe-eval' https://cdn.jsdelivr.net; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:; font-src 'self' data:; media-src 'self' blob:; connect-src 'self' https: http: wss: ws:; worker-src 'self' blob:; frame-src 'self' blob:; object-src 'none'; base-uri 'self'".to_string()) | ||
| } |
There was a problem hiding this comment.
CSP
http: scheme allows arbitrary insecure connections
The new connect-src 'self' https: http: wss: ws: is much broader than the previous explicit allowlist. Including bare http: means the browser UI may send authenticated requests (with bearer tokens or cookies) to any plaintext HTTP endpoint, which is exploitable by a network-level attacker. The comment explains the motivation (user-configured MCP servers at arbitrary URLs), but it's worth considering a narrower alternative: keep https: / wss: for all remote endpoints and add http://localhost http://127.0.0.1 (or the loopback CIDR if supported) for local-only MCP servers. This would still serve the Ollama / local-MCP use case without opening the full http: scheme to the whole internet.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/config/server.rs
Line: 477-479
Comment:
**CSP `http:` scheme allows arbitrary insecure connections**
The new `connect-src 'self' https: http: wss: ws:` is much broader than the previous explicit allowlist. Including bare `http:` means the browser UI may send authenticated requests (with bearer tokens or cookies) to any plaintext HTTP endpoint, which is exploitable by a network-level attacker. The comment explains the motivation (user-configured MCP servers at arbitrary URLs), but it's worth considering a narrower alternative: keep `https:` / `wss:` for all remote endpoints and add `http://localhost http://127.0.0.1` (or the loopback CIDR if supported) for local-only MCP servers. This would still serve the Ollama / local-MCP use case without opening the full `http:` scheme to the whole internet.
How can I resolve this? If you propose a fix, please make it concise.
No description provided.